Commit graph

97 commits

Author SHA1 Message Date
Ryan C. Gordon
de88474dda Initial merge of Emscripten port!
With this commit, you can compile SDL2 with Emscripten
( http://emscripten.org/ ), and make your SDL-based C/C++ program
into a web app.

This port was due to the efforts of several people, including: Charlie Birks,
Sathyanarayanan Gunasekaran, Jukka Jylänki, Alon Zakai, Edward Rudd,
Bruce Mitchener, and Martin Gerhardy. (Thanks, everyone!)

--HG--
extra : rebase_source : 97af74c8a5121e926ebe89f123536b5dd6681695
2014-12-18 00:19:52 -05:00
Philipp Wiesemann
d0d7ebee0f Fixed warnings about unused local variables. 2014-08-12 23:37:12 +02:00
Sam Lantinga
c7790bdb2b Added NV12 and NV21 texture support for OpenGL and OpenGL ES 2.0 renderers 2014-08-06 11:34:54 -07:00
Sam Lantinga
ad1fe92296 Fixed compiler warnings on iOS 2014-07-07 11:00:25 -07:00
Sam Lantinga
7db8668ef4 Fixed YUV texture update with a subrect in OpenGL ES 2.0 - thanks Sylvain! 2014-06-25 21:06:47 -07:00
Sam Lantinga
b84c11788e Fixed bug 2595 - Padded, non-contiguous YUV does not display correctly using OpenGL ES 2.0 renderer
Sylvain

Ok, I found out : GLES2_UpdateTexture is just not handling the YUV, I will attach a patch.
2014-06-25 00:58:40 -07:00
Gabriel Jacobo
efdc9c1d03 Fixes OpenGL ES 2 renderer (Thanks Sylvain Becker) 2014-06-23 09:25:27 -03:00
Sam Lantinga
6905c61819 Restore window OpenGL state if creating an OpenGL renderer fails 2014-06-22 02:48:43 -07:00
Sam Lantinga
2011e44843 Made SDL_PIXELFORMAT_ARGB8888 the default texture format for consistency across renderer implementations. 2014-06-21 21:46:42 -07:00
Sam Lantinga
6a296ae9f2 Fixed bug 2595 - Padded, non-contiguous YUV does not display correctly using OpenGL ES 2.0 renderer
Alvin

The new OpenGL ES 2.0 YUV Texture support does not correctly display padded, non-contiguous YUV data.

I am using SDL2 60edb019f0fe (as provided by 'hg id --id') from Mercurial.

The YUV data I am using is provided by the FFMPEG family of libraries. According to FFMPEG's documentation, "The linesize [pitch] may be larger than the size of usable data -- there may be extra padding present for performance reasons."

The dimensions of the video file that I am using are 480x360. What I get from FFMPEG is a Ypitch of 512, and Upitch and Vpitch are both 256.

When I pack new Y, U and V buffers with only the "usable" data (Ypitch is 480 and Upitch and Vpitch are both 240), and use those new buffers, the image is display correctly.

It appears that the Ypitch, Upitch and Vpitch parameters are not being used by SDL_UpdateYUVTexture().

I use SDL_PIXELFORMAT_YV12 for my YUV texture, however, the same results are seen when I use SDL_PIXELFORMAT_IYUV.

Not sure if this is related or not, but when I render the YUV texture (padded and unpadded) to a RGB24 texture, the resulting image is greyscale (or could by just the Y channel).

The URL field for this bug entry is set to my email (SDL mailing list archive) which includes an example image of what I see when rendering padded, non-contiguous YUV data.
2014-06-21 12:38:46 -07:00
Sam Lantinga
9043778f18 dront78 implemented YUV texture support for OpenGL ES 2.0 2014-06-07 11:36:08 -07:00
Jørgen P. Tjernø
431aca234b Render: Allow empty cliprect.
This fixes an issue where an empty cliprect is treated the same as a NULL
cliprect, causing the render backends to disable clipping.

Also adds a new API, SDL_RenderIsClipEnabled(render) that allows you to
differentiate between:
 - SDL_RenderSetClipRect(render, NULL)
 - SDL_Rect r = {0,0,0,0}; SDL_RenderSetClipRect(render, &r);

Fixes https://bugzilla.libsdl.org/show_bug.cgi?id=2504

--HG--
extra : amend_source : 9e5ac76e3f009d9ae49bc61c350df3ba891267b5
extra : histedit_source : b92b8be4d05b19a89fa0dee57f7ed6b1e924cb99%2Cce419f6ade87bafc78ff42702c1f263d2469e7e7
2014-04-19 13:15:41 -07:00
Sam Lantinga
e012b4eb5d Fixed renderer flags to include support for target textures after the renderer is created. 2014-03-09 22:48:38 -07:00
Sam Lantinga
a7d2ebb8d6 Integrated David Ludwig's support for Windows RT 2014-03-09 11:36:47 -07:00
Gabriel Jacobo
2e034c2a74 Improve window recreation logic in OpenGL* renderers 2014-02-27 20:21:46 -03:00
Gabriel Jacobo
83efc7045c Fixes #2308, recreate window if GL requirements for the renderer are not met
If the window has been created with values for SDL_GL_CONTEXT_PROFILE_MASK,
SDL_GL_CONTEXT_MAJOR_VERSION and SDL_GL_CONTEXT_MINOR_VERSION not matching those
required by the renderer, attempt to recreate the window.
This is needed on platforms where both GL and GLES 1/2 surfaces are supported
by the video backend, requiring that the window be recreated when switching
between context types.
2014-02-25 17:42:34 -03:00
CarniBlood
dedca211f8 fixed gles/gles2 renderer creation fail on Android when default major/minor version doesn't match 2013-12-19 06:01:18 +09:00
Sam Lantinga
46ee18a917 Fixed bug 2354 - [ES 2.0] SDL_RenderClear clears render target with wrong color
ny00

SDL_RenderClear clears a render target with the wrong color, if the opengles2 renderer driver is used and the target texture's format is SDL_PIXELFORMAT_ARGB8888.

The bug is *not* reproduced if SDL_PIXELFORMAT_ABGR8888 is used as the texture format (the first from the renderer's list).
It is further not reproduced using any of the following renderer drivers: opengl, opengles (apparently powered by Gallium3D), software.
Finally, the correct color can be drawn using SDL_RenderFillRect (instead of SDL_RenderClear).

A few details about the current setup:
- OS: Ubuntu 12.04 for x86_64
- GPU: GeForce GTX 460
- GPU driver version: 331.20-0ubuntu1~xedgers~precise1 (from the xorg-edgers PPA)


---

Seth Williams

Sam,

It appears that the clear just needs to take the render target format into consideration.

Seth.
2014-02-09 01:49:01 -08:00
Sam Lantinga
d7940a513e Fixed bug 2374 - Update copyright for 2014...
Is it that time already??
2014-02-02 00:53:27 -08:00
David Ludwig
a4f050087d WinRT: enable the OpenGL ES 2 SDL_Renderer backend, if and when OpenGL ES 2 support is compiled in 2013-11-29 00:19:46 -05:00
Ryan C. Gordon
82edee6971 Make internal SDL sources include SDL_internal.h instead of SDL_config.h
The new header will include SDL_config.h, but allows for other global stuff.

--HG--
extra : rebase_source : ddf4a4c0dc2c554b98c82700798f343cd91b16e3
2013-11-24 23:56:17 -05:00
Sam Lantinga
0a03232077 Fixed float to int conversion warning, which was a legitimate bug. 2013-12-23 17:15:32 -08:00
Sam Lantinga
31db3ac3c8 Do a 32-bit compare on RGBA values. Thsi should be inlined in optimized builds. 2013-10-05 12:29:05 -07:00
Ryan C. Gordon
0a999e88d1 Avoid redundant state changes in the GLES2 renderer. 2013-10-05 00:29:57 -04:00
Ryan C. Gordon
4cba5706bf Removed "u_colorTable" uniform from the GLES2 renderer. It's not used anywhere.
--HG--
extra : rebase_source : 52e7f708617733fe957c15f2ad752bf79b7c14cb
2013-10-04 11:25:14 -04:00
Sam Lantinga
325d333774 Added optional error checking for OpenGL ES 2.0 in the same style as the OpenGL renderer.
You can enable it like this: SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);
2013-10-03 20:48:52 -07:00
Ryan C. Gordon
715ccd02a5 Get rid of glGetError() calls in GLES2 renderer.
It's not usually useful, and it causes pipeline stalls.

--HG--
extra : rebase_source : fb1b9b3ffdee2a41fdaee5d30e7f218eacb2eaaa
2013-10-02 22:16:11 -04:00
Sam Lantinga
76f3df86db Fixed bug 2122 - SDL_CreateTexture allows illegal texture sizes
Lloyd Bryant

SDL_CreateTexture() is succeeding (i.e. returning a valid pointer) when the requested horizontal or vertical size of the texture exceeds the maximum allowed by the render.  This results in hard-to-understand errors showing up when later attempting to use that texture (such as with SDL_SetRenderTarget()).
2013-09-30 22:16:14 -07:00
Gabriel Jacobo
efb1f10b7c Fixes bug #2040, prepare SDL_GL_CONTEXT_EGL for deprecation on v2.1
SDL_GL_CONTEXT_EGL = 1 is now internally treated as profile_mask = SDL_GL_CONTEXT_PROFILE_ES
2013-08-29 15:02:32 -03:00
Sam Lantinga
08dfaaa2e6 Christoph Mallon: Remove pointless if (x) before SDL_free(x) 2013-08-29 08:29:21 -07:00
Gabriel Jacobo
df31e201cb Fix warning in GL ES2 renderer 2013-08-22 17:26:22 -03:00
Sam Lantinga
42c560b05d Check the return value of glGenTextures()
--HG--
extra : rebase_source : e079554f253890d862bfd5d51d7b229e3fcff3d9
2013-08-10 10:49:26 -07:00
Sam Lantinga
073d059fc9 Fixed bug 2008 - error typos in gles2 renderer
Martin Gerhardy

The attached patch fixes some typos in the SDL_SetError calls that are a little bit misleading.
2013-08-04 09:26:45 -07:00
Sam Lantinga
32188834b5 Updated blend semantics so blending uses the following formula:
dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA))
    dstA = srcA + (dstA * (1-srcA))
This allows proper compositing semantics without requiring premultiplied alpha.

Needs full unit test coverage and bug fixes!
2013-07-23 08:06:49 -07:00
Sam Lantinga
ee12cc8585 Fixed bug 1810 - xxx_RenderReadPixels - incorrect behaviour in certain conditions
PoopiSan

GLES2_RenderReadPixels, GLES_RenderReadPixels, GL_RenderReadPixels and possibly other backends is incorrectly implemented.

If the current target viewport is different than window size the function is reading garbage and according to the function documentation should work with any rendering target "Read pixels from the current rendering target.".

this seems to be caused by this line:

...
SDL_GetWindowSize(window, &w, &h);
2013-07-12 00:55:04 -07:00
Sam Lantinga
c55f53aa40 Fixed bug 1622 - SDL_RenderSetViewport with empty SDL_Rect raises wrong error for OpenGL rendering backend
It's now legal to set an empty viewport rect - it will prevent any rendering.

Also added an API to query the output size: SDL_GetRendererOutputSize()
2013-05-29 03:07:55 -07:00
Sam Lantinga
0cb6385637 File style cleanup for the SDL 2.0 release 2013-05-18 14:17:52 -07:00
Philipp Wiesemann
337c6acc60 Inlined expression for consistency in render source. 2013-05-13 22:45:06 +02:00
Philipp Wiesemann
df60747e3b Fixed bug 1844 - glScissor calls are wrong - Patch attached
Martin Gerhardy

the coordinate system from sdl is not correctly transformed to the coordinate system of opengl. glScissor expects them to be a little bit different. Attached is a patch that fixes this
2013-05-12 13:40:02 +02:00
Gabriel Jacobo
7065c6467d Fixes OpenGL* Clip Rect functions (by Emmanuel Gil Peyrot) 2013-05-10 10:31:01 -03:00
Sam Lantinga
866f2e5f9e First pass on SDL render clip rect functionality 2013-05-04 04:46:00 -07:00
Ryan C. Gordon
71b29b3822 Don't use glDisable(GL_TEXTURE_2D) in GLES2 renderer.
Fixes Bugzilla #1799.

--HG--
extra : rebase_source : bdcc78e0cbdb2879c7ae24666bea567ce24dcd74
2013-04-17 11:45:50 -04:00
Ryan C. Gordon
4f438b70a2 Make SDL_SetError and friends unconditionally return -1.
This lets us change things like this...

    if (Failed) {
        SDL_SetError("We failed");
        return -1;
    }

...into this...

    if (Failed) {
        return SDL_SetError("We failed");
    }


 Fixes Bugzilla #1778.
2013-03-31 12:48:50 -04:00
Sam Lantinga
4bb1b24573 Don't specify the texture unit when binding a texture, instead use whatever has been set up by the application.
This matches behavior in the OpenGL and OpenGL ES 1.1 renderers.
2013-03-03 11:25:43 -08:00
Sam Lantinga
7065167e8c Fixed bug 1728 - fixed compiler warnings 2013-02-26 03:34:34 -08:00
Sam Lantinga
95dcfa4c28 Happy New Year! 2013-02-15 08:47:44 -08:00
Sam Lantinga
22321b18ef Fixed direction of rotation with OpenGL ES 2 2013-01-27 15:52:56 -08:00
Sam Lantinga
f366b098d4 Added SDL_RenderSetScale() and SDL_RenderGetScale() 2012-10-01 20:59:33 -07:00
Sam Lantinga
f380ecb137 Removed executable bit from source files 2012-09-27 14:35:28 -07:00
Gabriel Jacobo
bd7b381374 Implements SDL_GL_BindTexture and SDL_GL_UnbindTexture (#1576) 2012-09-03 11:16:12 -03:00