Commit Graph

440 Commits

Author SHA1 Message Date
David Ludwig
6610782740 WinRT: fixed a line-rendering bug in the D3D 11.1 backend 2013-09-16 00:31:01 -04:00
David Ludwig
59362ee702 WinRT: made rendering work with orientation changes on Windows Phone
Pointer event geometry still needs to be adjusted on Windows Phone, to note.
2013-08-28 15:27:01 -04:00
David Ludwig
46a76134a3 WinRT: removed a comment regarding a dealt-with TODO 2013-08-28 12:45:43 -04:00
David Ludwig
9523f29d5c WinRT: rendering orientation fixes for Windows Phone, part 1
This change should allow apps to render correctly in Portrait mode, at minimum,

Support for orientation changes is pending.

Thanks to Pierre-Yves for assistance!
2013-08-28 12:38:30 -04:00
David Ludwig
2c2aedbcdb WinRT: fixed a potential memory-related crash in SDL_Renderer on Windows Phone 2013-08-28 11:46:02 -04:00
David Ludwig
93507125de WinRT: experimental and preliminary support for XAML-based overlays on Windows 8/RT
The XAML support here is still rudimentary.  Bugs do exist.  You've been warned.

XAML support in Windows Phone 8 is not yet available (in SDL/WinRT).
2013-08-27 21:21:09 -04:00
David Ludwig
df865dd615 WinRT: made all WinRT-related TODO comments use the same prefix, "TODO, WinRT" 2013-08-27 13:03:43 -04:00
David Ludwig
669aa12b7e WinRT: renamed SDL_SYSWM_WINDOWSRT to SDL_SYSWM_WINRT
This is part of an overall effort to use the name, "WinRT", rather than "WindowsRT" (or "Windows RT"), as the shorthand name often seems to mean something different than the longhand name.  (WinRT is an API, Windows RT is a product name)
2013-08-27 11:44:43 -04:00
David Ludwig
51cd30d786 WinRT: added a stub implementation of UpdateClipRect to the D3D 11.1 renderer 2013-08-13 20:33:15 -04:00
David Ludwig
1ae5d8dea3 WinRT: build fixes and additional WinRT-related integrations with SDL 2.0.0 2013-08-13 20:09:52 -04:00
David Ludwig
373ffd0dac WinRT: merged with SDL 2.0.0 codebase (aka. SDL hg rev d6a8fa507a45) 2013-08-12 22:29:55 -04:00
Sam Lantinga
53a86d45bd Check the return value of glGenTextures() 2013-08-10 10:49:26 -07:00
Sam Lantinga
dfac4af69a Reset the viewport when we reset the other D3D state.
From Sythical:

Hello, I've created a simple SDL2 application which draws a texture on the screen. The problem I'm having is that if I launch another program which loads the UAC popup or if I lock my PC and then login again, the application stops drawing the texture. I tried adding SDL_Delay(10000) after SDL_RenderPresent(renderer). This made the texture stay on the screen for a little bit but the texture wasn't drawn again after the delay. Here's my code:

#include "SDL.h"

int main(int argc, char *argv[])
{
    SDL_Renderer *renderer;
    SDL_Window *window;
    SDL_Surface *surface;
    SDL_Texture *rect_texture;
    SDL_Event main_event;
    SDL_Rect rect_data;
    int enable_vsync = 1;

    if(SDL_Init(SDL_INIT_VIDEO) < 0) return 1;

    window = SDL_CreateWindow("SDL2 Application", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 600, 600, SDL_WINDOW_RESIZABLE);

    renderer = SDL_CreateRenderer(window, -1, enable_vsync ? SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC : SDL_RENDERER_ACCELERATED);
    SDL_SetRenderDrawColor(renderer, 20, 20, 30, 255);

    surface = SDL_LoadBMP("icon.bmp");
    rect_texture = SDL_CreateTextureFromSurface(renderer, surface);

    rect_data.w = 32; rect_data.h = 32;
    rect_data.x = 300; rect_data.y = 300;

    while(main_event.type != SDL_QUIT)
    {
        SDL_PollEvent(&main_event);

        SDL_RenderClear(renderer);
        SDL_RenderCopy(renderer, rect_texture, NULL, &rect_data);
        SDL_RenderPresent(renderer);
    }

    SDL_DestroyTexture(rect_texture);
    SDL_DestroyRenderer(renderer);
    SDL_DestroyWindow(window);
    SDL_Quit();

    return 0;
}
2013-08-07 01:14:04 -07:00
Sam Lantinga
4b9d9d7d74 Fixed clobbering viewport when window is resized when using the software renderer. The viewport adjustment is already handled in the top level rendering code. 2013-08-06 22:31:11 -07:00
Ryan C. Gordon
6282a112e5 Removed anisotropic option from SDL_HINT_RENDER_SCALE_QUALITY.
Anisotropic filtering is meant to be used for textures at a stark
 angle, not perpendicular to the camera.
2013-08-06 00:23:04 -04:00
Sam Lantinga
2170675d1e 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
a082c12fd1 Fixed bug 1968 - SDL_RenderCopy stretch loses proportion on viewport boundaries for 3D renderers
driedfruit

SDL_RenderCopy clips dstrect against the viewport. Then it adjusts the
srcrect by "appropriate" amount of pixels. This amount is actually
wrong, quite a lot, because of the rounding errors introduced in the "*
factor / factor" scale.

            real_srcrect.x += (deltax * real_srcrect.w) / dstrect->w;
            real_srcrect.w += (deltaw * real_srcrect.w) / dstrect->w;

For example:

I have a 32 x 32 srcrect and a 64 x 64 dstrect. So far the
stretching is done perfectly, by a factor of 2.

Now, consider dstrect being clipped against the viewport, so it becomes
56 x 64. Now, the factor becomes 1.75 ! The adjustment to "srcrect"
can't handle this, cause srcrect is in integers.

And thus we now have incorrect mapping, with dstrect not being in the
right proportion to srcrect.

The problem is most evident when upscaling stuff, like displaying a 8x8
texture with a zoom of 64 or more, and moving it beyond the corners of
the screen. It *looks* really really bad.

Note: RenderCopyEX does no such clipping, and is right to do so. The fix would be to remove any such clipping from RenderCopy too. And then fix the software renderer, because it has the same fault, independently of RenderCopy.

[attached patch]
this leaves Software Renderer buggy, as it does it's own clipping later on
2013-08-01 09:15:36 -07:00
Sam Lantinga
ff814534d2 Fixed compiler warning with gcc 2013-07-30 00:02:45 -07:00
Sam Lantinga
cc357a636a A little cleanup on the cleanup, just for consistency. 2013-07-23 19:18:01 -07:00
Jørgen P. Tjernø
f87ccc3ea5 Fix build errors from last change. 2013-07-23 17:40:16 -07:00
Jørgen P. Tjernø
61b46199ac Fix some clang analyzer warnings.
This fixes some analyzer warnings and a couple of minor memory leaks.
2013-07-23 17:40:13 -07:00
Sam Lantinga
3d68d1d1ea Added Direct3D shader to hardware accelerate YV12 and IYUV textures. 2013-07-23 12:55:19 -07:00
Sam Lantinga
4862c1fc30 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
17747734e6 Fixed bug 1813 - MouseMotion relative values do not respect renderer LogicalSize
driedfruit

A trivial issue, the xrel and yrel values of MouseMotion event struct are not adjusted to renderer logical size.
2013-07-21 12:54:27 -07:00
Ryan C. Gordon
94f48a7a79 Include SDL_assert.h to fix broken build. 2013-07-20 21:22:37 -04:00
Ryan C. Gordon
f5dc9cbdd4 Don't allocate memory if we're just going to fail when checking parameters. 2013-07-20 21:19:20 -04:00
Ryan C. Gordon
458f6d50de Don't try to clear errors in GL_ActivateRenderer() before we MakeCurrent.
Otherwise, if we destroyed a different renderer, next time this one draws,
it'll clear errors forever (GL_INVALID_OPERATION for having no current
context, at least on Windows), hanging up the program in an infinite loop.

Fixes Bugzilla #1775.
2013-07-20 21:10:05 -04:00
Sam Lantinga
56ec88d00b Fixed bug 1977 - D3D_UpdateClipRect() sets the wrong width for the clip rect
Bithika Mookherjee

SDL_RenderSetClipRect() calls into renderer->UpdateClipRect(renderer).

I am not sure if UpdateClipRect() can point to a number of clip rect update functions, but on my platform it calls D3D_UpdateClipRect().

In that function, the rect to pass to IDirect3DDevice9_SetScissorRect() has it's right field set as:

    r.right = rect->w + rect->w;

But actually, this should be:

    r.right = rect->x + rect->w;
2013-07-19 22:43:14 -07:00
Ryan C. Gordon
a4b32eb96a Get rid of glGetError() calls in GLES2 renderer.
It's not usually useful, and it causes pipeline stalls.
2013-10-02 22:16:11 -04:00
Sam Lantinga
e0ecd82d03 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
Sam Lantinga
c049a88aca Call AddRef() on the device so it doesn't accidentally get released from underneath the caller. 2013-09-28 14:07:17 -07:00
Sam Lantinga
ac2735a4a4 Make it clear we're just returning a D3D9 device, allowing for new functions to get other D3D versions 2013-09-28 14:07:14 -07:00
Sam Lantinga
c045f564ad Added a hint to create the D3D device in thread-safe mode: SDL_HINT_RENDER_DIRECT3D_THREADSAFE 2013-09-28 14:07:08 -07:00
Sam Lantinga
4eac5bc7be Added platform specific call: SDL_RenderGetD3DDevice() 2013-09-28 14:07:05 -07:00
Sam Lantinga
c2caca9f44 Moved SDL_Direct3D9GetAdapterIndex() to SDL_windowsvideo.c since it doesn't belong in the window code. 2013-09-28 14:06:59 -07:00
Sam Lantinga
e90c3d6709 Implemented SDL_UpdateYUVTexture() for Direct3D 2013-09-28 14:06:55 -07:00
Sam Lantinga
5468c2d97f Added missing SDL_assert.h 2013-09-28 14:06:51 -07:00
Sam Lantinga
b7d5ed3b6f Added optimized YUV texture upload path with SDL_UpdateYUVTexture() 2013-09-28 14:06:47 -07:00
Sam Lantinga
dcaec5adaf Moved D3D_LoadDLL and SDL_Direct3D9GetAdapterIndex to SDL_windowswindow.c at Jorgen's insistence. That file is wrapped in a more appropriate define check so it will work if somebody builds a binary without D3D support.
Added a reference to SDL_Direct3D9GetAdapterIndex to SDL_test_common.c so SDL will fail to compile if the new symbol isn't included properly.

CR: Jorgen
2013-09-28 14:06:20 -07:00
Edward Rudd
fab88c0df2 add in High DPI support (aka Retina)
- based on Jørgen's patch with a few bug fixes
2013-09-20 13:43:00 -04:00
Sam Lantinga
c1a125c267 Added SDL_Direct3D9GetAdapterIndex(), which returns the adapter index you would pass into CreateDevice to get your device on the right monitor in full screen mode. This fixes the default adapter in SDL_render_d3d.c, which means that tests will work fullscreen off the main monitor now.
CR: Sam
2013-09-13 17:42:46 -07:00
Gabriel Jacobo
6b6b23633c 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
6d9d4b6eba Christoph Mallon: Remove pointless if (x) before SDL_FreeSurface(x) 2013-08-29 08:29:51 -07:00
Sam Lantinga
753aae78fc Christoph Mallon: Remove pointless if (x) before SDL_free(x) 2013-08-29 08:29:21 -07:00
Gabriel Jacobo
3d70638fcf Fix warning in GL ES2 renderer 2013-08-22 17:26:22 -03:00
Gabriel Jacobo
bc514bada3 Fixes for -Wdeclaration-after-statement 2013-08-21 10:12:16 -03:00
Gabriel Jacobo
8515791f86 OCD fixes: Adds a space after /* (glory to regular expressions!) 2013-08-21 09:47:10 -03:00
Gabriel Jacobo
871473e032 OCD fixes: Adds a space before */ 2013-08-21 09:43:09 -03:00
Gabriel Jacobo
f93c78450b More non C89 compliant comments 2013-08-20 20:34:40 -03:00
Ryan C. Gordon
ae735be7ec Fixed leaking of pixel shader object in D3D renderer (thanks, Peter!).
Fixes Bugzilla #2047.
2013-08-19 11:02:44 -04:00
Sam Lantinga
aaeb2536aa Fixed Windows build 2013-08-17 17:14:15 -07:00
Sam Lantinga
997833aa8a Do full state initialization in D3D_Reset(), this fixes blend mode issues when resizing the window on Windows 8. 2013-08-17 09:54:30 -07:00
Gabriel Jacobo
973b6fec27 Android quirk:Some devices don't report GL_OES_framebuffer_object but support it 2013-08-16 14:38:04 -03:00
Ryan C. Gordon
6d08ab8e93 Patched to compile. 2013-08-16 12:51:29 -04:00
Gabriel Jacobo
6af114230c [Bug 2042] OpenGL ES renderer tries to load OES functions unconditionally
Also, fail more gracefully when creating texture to avoid double free errors.
2013-08-16 13:37:27 -03:00
Sam Lantinga
c0d6bf12b0 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
824e95758a Don't crash if the current render target is destroyed. 2013-07-12 00:43:16 -07:00
Sam Lantinga
ce81311ab7 Check the parameters to SDL_UpdateTexture() 2013-07-11 22:04:16 -07:00
Philipp Wiesemann
1f5019fb44 Changed include directive to standard header. 2013-07-07 16:13:17 +02:00
Sam Lantinga
722a61f8df Fixed the logical size for rendering to texture, thanks to Mason Wheeler.
Mason Wheeler

The SDL_RenderGetLogicalSize function should always return the amount of pixels that are currently available for rendering to.  But after updating to the latest SDL2, I started getting crashes because it was returning (0,0) as the logical size!  After a bit of debugging, I tracked it down to the following code in SDL_SetRenderTarget:

    if (texture) {
        renderer->viewport.x = 0;
        renderer->viewport.y = 0;
        renderer->viewport.w = texture->w;
        renderer->viewport.h = texture->h;
        renderer->scale.x = 1.0f;
        renderer->scale.y = 1.0f;
        renderer->logical_w = 0;
        renderer->logical_h = 0;
    }

This is obviously wrong; 0 is never the correct value for a valid renderer.  Those last two lines should read:

        renderer->logical_w = texture->w;
        renderer->logical_h = texture->h;
2013-06-29 14:40:55 -07:00
Sam Lantinga
cee64ab8c3 Merged 2013-06-28 20:46:11 -07:00
Sam Lantinga
f212eb00a5 Fixed bug updating the clip rect for the software renderer 2013-06-27 11:27:19 -07:00
Sam Lantinga
3fdc17618c Fixed bug 1929 - SDL_Texture* from SDL_CreateTexture() causes GL_BindTexture() to segfault
Charles Huber

If SDL_CreateTexture() takes the !IsSupportedFormat() path it will return a SDL_Texture* with a NULL driverdata member.

If you then SDL_GL_BindTexture() this will cause a segfault in GL_BindTexture() when it unconditionally dereferences driverdata.
2013-06-25 20:21:31 -07:00
Sam Lantinga
6993e59213 Fixed some Visual Studio analyze warnings 2013-06-15 02:46:32 -07:00
Yuri K. Schlesner
ce7e01dd7b Re-apply texture filter when resetting direct3d renderer. 2013-05-29 06:31:48 -05:00
Sam Lantinga
028c19b92b When the window is resized, the viewport is automatically reset.
This resolves lots of confusion around resizable windows.  Most people don't expect a viewport to be implicitly set when the renderer is created and then not to be reset to the window size if the window is resized.

Added common test command line parameters --logical WxH and --scale N to test the render logical size and scaling APIs.
2013-05-29 03:22:19 -07:00
Sam Lantinga
23f33cb76c 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
4d9fee966f It turns out that GL_ARB_debug_output is really only useful on debug contexts, so for consistency and performance we'll only check and report errors on debug contexts.
I added a --gldebug command line option for the test programs to easily test this, and we may want a hint as well to enable OpenGL error checking.
2013-05-20 12:01:31 -07:00
Sam Lantinga
35f178cd7f Fixed declaration of GL_HandleDebugMessage 2013-05-19 22:57:01 -07:00
Sam Lantinga
a08ccfa9f8 Fixed windows build 2013-05-19 22:45:52 -07:00
Sam Lantinga
1063a72829 Fixed bug 1837 - Use error extension instead of glGetError()
Implemented support for GL_ARB_debug_output, but was unable to test it on Mac OS X.
2013-05-19 22:28:10 -07:00
Sam Lantinga
0d9b661db8 File style cleanup for the SDL 2.0 release 2013-05-18 14:17:52 -07:00
Sam Lantinga
d6adde2adb Fixed bug 1838 - [Patch] Direct3D resource leak on SDL_DestroyRenderer() 2013-05-16 00:56:19 -07:00
Philipp Wiesemann
a19135fd1a Inlined expression for consistency in render source. 2013-05-13 22:45:06 +02:00
Philipp Wiesemann
08e8e38c86 Fixed building on Visual Studio.
Buildbot
2013-05-12 14:25:38 +02:00
Philipp Wiesemann
de43af1b54 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
Philipp Wiesemann
539f60a57d Corrected spelling in internal include file. 2013-05-12 13:02:07 +02:00
Gabriel Jacobo
d36f97eb89 Fixed typo in GL_UpdateClipRect 2013-05-10 10:33:15 -03:00
Gabriel Jacobo
d4c2a87a5b Fixes OpenGL* Clip Rect functions (by Emmanuel Gil Peyrot) 2013-05-10 10:31:01 -03:00
Philipp Wiesemann
49b3851430 Fixed SDL_RenderSetClipRect() returning undefined instead of -1 on error. 2013-05-04 22:44:03 +02:00
Sam Lantinga
7253832be1 First pass on SDL render clip rect functionality 2013-05-04 04:46:00 -07:00
Sam Lantinga
c1bfee0f2d Fixed bug 1583 - Fix build for disabled SDL render subsystem
Marcus von Appen

If one wants to disable the SDL render subsystem, the build breaks on several platforms due to an empty render_drivers array in SDL_render.c.
2013-04-25 00:15:09 -07:00
Gabriel Jacobo
de33c6164e Fixes PSP_DestroyTexture release of data (don't release the SDL_Texture pointer) 2013-04-23 16:54:52 -03:00
Jørgen P. Tjernø
a228e5242a SDL_GL_DeleteContext would leave an invalid current_glctx.
Calling SDL_GL_DeleteContext wouldn't update current_glctx, so you could
end up with use-after-free and other goodies when you deleted a context.
2013-04-22 18:15:08 -07:00
David Ludwig
6bf31495f9 WinRT: merged with latest, official, SDL 2.x sources 2013-04-21 12:38:44 -04:00
David Ludwig
48c5ee264e WinRT: made SDL's inner WinRT CoreWindow be accessible to non-C++/CX code, in theory 2013-04-16 23:40:03 -04:00
Ryan C. Gordon
295c17e99b Don't use glDisable(GL_TEXTURE_2D) in GLES2 renderer.
Fixes Bugzilla #1799.
2013-04-17 11:45:50 -04:00
Andreas Schiffler
fc589bd617 Fix bug 1764: incorrect variable assignment in RenderDrawLinesWithRects 2013-04-17 07:35:30 -07:00
David Ludwig
49820874a9 WinRT: merged with latest, official, SDL 2.x sources (at rev. bea100d73d13) 2013-04-14 11:42:55 -04:00
David Ludwig
a46b1c6663 WinRT: added render-to-texture support for D3D 11.1, via SDL_SetRenderTarget 2013-04-13 23:03:46 -04:00
David Ludwig
922323a1cd WinRT: added texture channel color-modulation support for D3D 11.1 2013-04-07 22:35:58 -04:00
David Ludwig
50a881d724 WinRT: removed a bit of unused code from the D3D 11.1 renderer 2013-04-02 00:21:01 -04:00
David Ludwig
0c6e5ad1a9 WinRT: added rotation support to SDL_RenderCopyEx via D3D 11.1 2013-04-02 00:09:49 -04:00
David Ludwig
c2e89ec462 WinRT: implemented SDL_RenderCopyEx, w/ SDL_RendererFlip support, in D3D 11.1 2013-04-01 22:33:37 -04:00
David Ludwig
3ca7578363 WinRT: implemented SDL_RenderReadPixels in Direct3D 11.1 2013-04-01 21:34:47 -04:00
Ryan C. Gordon
16cdc59bab 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
David Ludwig
2a3066f606 WinRT: removed code that unnecessarily set a blank D3D 11.1 texture's contents 2013-03-31 11:44:50 -04:00
David Ludwig
b80d430b5c WinRT: added SDL_LockTexture and SDL_UnlockTexture support to the D3D 11.1 renderer 2013-03-31 11:16:31 -04:00
David Ludwig
f6c8097c65 WinRT: added point drawing support to the Direct3D 11.1 rendering backend 2013-03-24 21:57:40 -04:00
David Ludwig
2fef732bf6 WinRT: added line drawing support to the Direct3D 11.1 rendering backend 2013-03-24 21:19:26 -04:00
Sam Lantinga
f0af9a3e70 Removed Nintendo DS support since nobody has volunteered to maintain it for over a year. 2013-03-17 09:44:58 -07:00
Captain Lex
a18bccd5f3 Add PSP support 2013-03-17 20:07:02 +08:00
Sam Lantinga
d71696b7f5 Fixed compile errors on Windows 2013-03-06 09:45:53 -08:00
Sam Lantinga
86ff46800f Fixed warning messages when loading Direct3D DLL
kmx

I have investigated the warning "Failed loading D3DX9_*.dll" and come up with the enclosed patch (please forward it to relevant SDL2 mailing list/bugtracker).
2013-03-05 18:52:25 -08:00
Sam Lantinga
aba5889732 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
e6bf874eff Fixed formatting 2013-03-03 11:25:09 -08:00
Sam Lantinga
d76c7254dd Fixed bug 1728 - fixed compiler warnings 2013-02-26 03:34:34 -08:00
David Ludwig
3f580c9f17 WinRT: made the D3D 11.1 renderer respect the 'srcrect' parameter of SDL_RenderCopy 2013-02-24 12:27:28 -05:00
David Ludwig
583a3e4aee WinRT: allowed for querying of max texture size (via Direct3D 11.1) 2013-02-24 10:30:12 -05:00
David Ludwig
4e1f3a92f0 WinRT: made the Direct3D 11.1 renderer correctly report its status regarding render-to-texture (not supported, yet) 2013-02-24 10:14:23 -05:00
David Ludwig
cacc6d9d92 WinRT: moved the default vertex shader into the Direct3D 11.1 renderer's folder 2013-02-24 10:11:58 -05:00
David Ludwig
08b886ae9d WinRT: added support for alpha-blended texture rendering 2013-02-23 22:58:09 -05:00
David Ludwig
db53df0697 WinRT: merged with latest, official, SDL 2.x code 2013-02-23 20:01:46 -05:00
David Ludwig
4c4c4093c2 WinRT: another device-rotation and rendering fix 2013-02-19 22:07:07 -05:00
Sam Lantinga
509366e2ca Fixed bug 1474 - OpenGL renderer can't to display YV12 texture. 2013-02-19 07:05:15 -08:00
Sam Lantinga
6b574f11e2 Fixed bug 1722 - An attempt to release NULL Direct3d surface
Evgeny

static void
D3D_DestroyRenderer(SDL_Renderer * renderer)

has a critical problem. It may try to release IDirect3DSurface9 surface pointed
by NULL pointer. That leads to really wierd consequences on my system.

It happens when the previous call to IDirect3D9_CreateDevice() fails leaving
D3D_RenderData::defaultRenderTarget uninitialized.
2013-02-17 23:30:47 -08:00
David Ludwig
97ff4f43d7 WinRT: bug fixes for device orientation + Direct3D 11.1 rendering 2013-02-17 23:23:59 -05:00
David Ludwig
367c968fc2 WinRT: made SDL_RenderSetViewport work with the D3D 11.1 renderer 2013-02-17 11:09:07 -05:00
David Ludwig
2e34488cc1 WinRT: D3D 11.1 blending mode support added; FillRects coloring bug-fix 2013-02-16 16:53:06 -05:00
David Ludwig
fdd12e1d1a WinRT: took out an unneeded depth stencil view from the D3D 11.1 renderer 2013-02-16 16:13:48 -05:00
David Ludwig
b7dcf7fac4 WinRT: implemented SDL_RenderFillRect and SDL_RenderFillRects for the D3D 11.1 renderer 2013-02-16 09:10:43 -05:00
Sam Lantinga
019c60c1e8 Happy New Year! 2013-02-15 08:47:44 -08:00
David Ludwig
a20666df47 WinRT: made SDL_CreateRenderer default to using the SW renderer, for now 2013-02-12 21:26:04 -05:00
David Ludwig
f5cedaa6a9 WinRT: fixed one scaling bug (more remain) in the Direct3D 11.1 renderer 2013-02-12 21:25:26 -05:00
David Ludwig
0372a69347 WinRT: fixed bug: SDL_RenderCopy was always filling the entire screen 2013-02-12 20:49:26 -05:00
David Ludwig
d2b0f4d278 WinRT: made d3d 11.1 vertex buffers get created, and updated, when a render op is invoked 2013-02-12 19:08:35 -05:00
Sam Lantinga
972b2abc34 Fixed bug 1491 - Directx3d Crash on resize
Spinduluz

RenderTarget has to be released before a device reset is done. It's a
D3DPOOL_DEFAULT surface (resides in video memory and have to be recreated).
2013-02-11 21:12:14 -08:00
David Ludwig
41ed032ebf WinRT: made SDL_RenderClear display the correct color via Direct3D 11.1 2013-02-10 17:35:38 -05:00
David Ludwig
e73e2ca8d9 WinRT: consolidated all WinRT path-retrieval functions into one function 2013-02-09 22:48:19 -05:00
David Ludwig
5e09208ba1 WinRT: fixed a crash that occurred after rotating the host device 2013-02-09 20:30:53 -05:00
David Ludwig
f771aa94fd WinRT: made sure the device orientation transform gets applied (by the D3D 11.1 renderer) when drawing 2013-02-09 20:26:39 -05:00
David Ludwig
0230dbac69 WinRT: moved texture management code from SDL_winrtrenderer to the D3D 11.1 SDL_Renderer backend 2013-02-09 18:58:13 -05:00
David Ludwig
f97e0c55e1 WinRT: added SDL_WINDOWEVENT_RESIZED support, and moved window-resize-handling code from WinRT rendering code to D3D 11.1 code 2013-02-09 16:00:55 -05:00
David Ludwig
44ce12c509 WinRT: more code-moving from WinRT code to Direct3D 11.1 code 2013-02-09 15:43:13 -05:00
David Ludwig
b29972705a WinRT: made the Direct3D 11.1 renderer directly initialize more of itself, rather than deferring to code in the WinRT video driver 2013-02-09 15:22:49 -05:00
David Ludwig
12f2c72309 WinRT: more work on moving rendering code from SDL_winrtrenderer.* to SDL_render_d3d11* 2013-02-09 14:56:32 -05:00
David Ludwig
a89b0d79a9 WinRT: more code-moving from SDL_winrtrenderer* to SDL_render_d3d11* 2013-02-09 11:42:17 -05:00
David Ludwig
d839eb5eb2 WinRT: moved a bit more Direct3D 11.1 code into the SDL_Renderer backend 2013-02-02 21:05:32 -05:00
David Ludwig
4f6ffdc590 WinRT: started refactoring Direct3D 11.1 code into a new SDL_Renderer backend 2013-02-02 19:32:44 -05:00
Sam Lantinga
6c353b0768 Fixed direction of rotation with OpenGL ES 2 2013-01-27 15:52:56 -08:00
Sam Lantinga
f425fe1358 Improvements from Alfred:
- Added new SDL_HINT_ALLOW_TOPMOST hint, when set to "0" then never set the topmost bit on a window. Useful when debugging fullscreen issues.
- fixed crash in windows joystick scanning if we failed to load the xinput dll
- added support for SDL_WINDOW_FULLSCREEN_DESKTOP under windows
- synthesize relative mouse movements if directinput fails to send relative moves, happens under virtual box.
2012-12-31 09:30:15 -08:00
Sam Lantinga
e3c79c3a45 The logical size set for a render target is temporary and shouldn't conflict with the logical size set for a window. 2012-10-12 02:56:41 -07:00
Sam Lantinga
0ec818f3c0 Fixed a bug resetting the viewport with a render target. 2012-10-12 02:30:03 -07:00
Sam Lantinga
9a6b1c641a Added SDL_GetRenderTarget() API function
Also fixed a bug with setting logical size for a render target.
2012-10-12 02:20:10 -07:00
Ryan C. Gordon
6812b2e9cf Helps to initialize variables in the right function. :) 2012-10-03 20:02:13 -04:00
Ryan C. Gordon
f4c5703d8f Fixed compiler warning. 2012-10-03 19:20:53 -04:00
Sam Lantinga
04275d9bfb Fixed texture list when swapping textures (thanks Drake Wilson!) 2012-10-02 00:28:23 -07:00
Sam Lantinga
873ecde0ad Initialized default scale for software renderer (thanks Marcus von Appen!) 2012-10-01 23:28:19 -07:00
Sam Lantinga
a7dc767823 Fixed a compiler warning 2012-10-01 23:23:04 -07:00
Sam Lantinga
aab04f8c71 Added SDL_RenderSetLogicalSize() and SDL_RenderGetLogicalSize() 2012-10-01 22:30:07 -07:00
Sam Lantinga
f4bf4989ce The viewport is already scaled to the output coordinates 2012-10-01 21:57:09 -07:00
Sam Lantinga
8e121270fa Added SDL_RenderSetScale() and SDL_RenderGetScale() 2012-10-01 20:59:33 -07:00
Ryan C. Gordon
729074f469 Patched to compile on Visual Studio. 2012-09-28 14:17:30 -04:00
Sam Lantinga
e3d46eeb0a Fixed bug 1579 - Creating a texture with unsupported format may cause double-destruction
Alexander Hirsch 2012-08-25 20:01:29 PDT

When creating a SDL_Texture with unsupported format (I'll now refer to it as
texture A), SDL_CreateTexture will call SDL_CreateTexture again with
GetClosestSupportedFormat to set texture->native (which I will now refer to as
texture B).
This causes texture B to be put before A in renderer->textures.

If texture A is explicitly destroyed, everything is fine. Otherwise, upon
SDL_DestroyRenderer, the loop will first encounter texture B, destroy it, then
texture A, destroy that which will want to destroy texture->native and since it
is already destroyed set an error.

The solution could be as simple as swapping texture A with B after
texture->native gets set in SDL_CreateTextures.
2012-09-28 04:09:06 -07:00
Sam Lantinga
22025f3ce7 Fixed bug 1584 - Improved glError checks in the opengl renderer
Martin Gerhardy 2012-08-27 02:42:25 PDT

I've extended the gl error checks.

This is needed because on my system there are errors in the renderer that are
hard to find.

Also glError can return multiple errors. Even if SDL_SetError would only
contain the last one of course, the SDL log facilities are able to get the
output for each error.
2012-09-28 03:49:27 -07:00
Sam Lantinga
f02003f0ba Fixed memory leak in an error case 2012-09-28 02:43:13 -07:00
Sam Lantinga
b3d60cfcbb Removed executable bit from source files 2012-09-27 14:35:28 -07:00
Sam Lantinga
327faf465a Fixed bug 1591 - Renderer maximum texture size is incorrect when GL_ARB_texture_rectangle is active 2012-09-23 01:50:35 -07:00
Sam Lantinga
c76bdd4882 Fixed error message when destroying a software renderer, thanks to wahono for the patch. 2012-09-06 21:34:52 -07:00
Gabriel Jacobo
c576bf10be Return a valid error in SDL_GL_Bind/UnbindTexture, thank you buildbot! 2012-09-03 11:54:48 -03:00
Gabriel Jacobo
ceaf031283 Implements SDL_GL_BindTexture and SDL_GL_UnbindTexture (#1576) 2012-09-03 11:16:12 -03:00
Ryan C. Gordon
aa78574da8 Whoops, removed wrong variable. 2012-08-24 19:39:51 -04:00
Ryan C. Gordon
b9790162f5 Fixed a bunch of compiler warnings with Cygwin/MingW. 2012-08-24 19:34:28 -04:00
Gabriel Jacobo
5a63b930fa Fix for #1577, SDL_RenderCopyEx - Runtime check fails when dstrect == NULL and center == NULL
Thanks Michael Ehrmann.
2012-08-24 11:56:21 -03:00
Ryan C. Gordon
c71bcb5678 Removed some unused variables that gcc 4.6.1 complains about. 2012-08-09 14:14:41 -04:00
Ryan C. Gordon
7d67b05181 Fixed some minor compiler warnings. 2012-07-20 13:33:15 -04:00
Sam Lantinga
1d7093bd80 Switch the OpenGL ES renderers to request EGL OpenGL contexts 2012-07-18 15:20:32 -07:00
Sam Lantinga
32a20bfc64 Fixed orientation and color when rendering to texture 2012-06-22 11:38:49 -04:00
Gabriel Jacobo
a1de587006 Fixes #1523 by removing inconsistent use of texture->access 2012-06-21 11:16:14 -03:00
Sam Lantinga
e3179ba01b Fixed compiling with Visual Studio 2012-06-19 13:50:14 -04:00
Sam Lantinga
9a96b99516 Fixed SDL_config.h build include path 2012-06-01 20:31:50 -04:00
Gabriel Jacobo
2e96488df0 RenderCopyEx,rotation and flipping for all hardware/software backends (#1308) 2012-06-01 19:51:08 -03:00
Sam Lantinga
f7b34c87f6 Fixed bug 1419 - SDL_libgl2D.c breaks ndk-build
Philip Taylor 2012-02-15 10:43:47 PST

render/nds/SDL_libgl2D.c unconditionally includes NDS-only code. SDL's
Android.mk compiles source files matching

  $(wildcard $(LOCAL_PATH)/src/render/*/*.c)

which includes that file, causing build errors when running ndk-build.
2012-02-15 21:11:21 -05:00
Sam Lantinga
41dcf2a16e Updated Nintendo DS support
Frank Zago

This patch updates the DS port:
- do not use the now removed compat layer.
- integrate parts of libgl2D since I got permission from the author, and thus
removed an external dependancy,
- a few bugs fixes.

Now, the textures should be completely supported, except reading from them
which doesn't makes sense to have on the DS. Sound is still not supported.

If someone else wants to work on the missing pieces, feel free.
2012-02-12 21:04:01 -05:00
Sam Lantinga
333943e556 Fixed bug 1412 - Patch - Software renderer crash
Dimitris Zenios Date: 2012-02-06 15:12:37 GMT

Hi gus there is a bug when using software renderer and the window
surface gets destroyed (Fullscreen and back).The solution is easy
2012-02-07 19:34:24 -05:00
Sam Lantinga
c7588fa928 Fixed OpenGL ES 1.1 on Android
From Gabriel Jacobo:
What I did notice is that calling
data->glGetIntegerv(GL_FRAMEBUFFER_BINDING_OES, &value); doesn't produce any
result in Android GLES1.1 if the active framebuffer is the default one, ie,
whatever is in value stays unmodified.
2012-01-31 21:03:35 -05:00
Sam Lantinga
9470893698 Fixed magenta texture on iOS with OpenGL ES 2.0 2012-01-30 20:56:25 -05:00
Sam Lantinga
00da0cd57c Added glGenFramebuffers() to the function pointer list 2012-01-28 14:53:23 -05:00
Sam Lantinga
55ea8bdfd4 Fixed setting the orthographic projection when the viewport changes. 2012-01-28 14:05:48 -05:00
Sam Lantinga
f14f70bc64 Fixed loading textures when the window starts hidden.
The viewport automatically resets to the window size when you programmatically resize the window.
2012-01-22 21:46:06 -05:00
Sam Lantinga
b5844a1c07 Added a convenience function SDL_CreateWindowAndRenderer() 2012-01-22 19:22:53 -05:00
Sam Lantinga
b291116502 Renamed SetTargetTexture() to SetRenderTarget() 2012-01-22 01:26:28 -05:00
Sam Lantinga
dba1ccf43b Reorganized the render target code, moving the viewport handling to the general code and adding software implementation. 2012-01-21 22:22:30 -05:00
Sam Lantinga
7f8f4956c3 We've already crashed by this point if we don't have a renderer. The calling code should check this. 2012-01-21 18:30:50 -05:00
Sam Lantinga
1af7c2fe96 Added a renderer flag to expose whether a renderer supports render to texture. 2012-01-19 21:06:47 -05:00
Sam Lantinga
096d218036 Fix for building with Visual Studio 2012-01-19 20:25:09 -05:00
Sam Lantinga
9e37906060 Implementation of render targets, by Mason Wheeler and Gabriel Jacobo
Thanks guys!
2012-01-18 22:45:49 -05:00
Sam Lantinga
d06d970095 Fixed bug 1331 - SDL_CreateTextureFromSurface fails for OpenGL + Win XP 64 NVidia 285.58 with GL_INVALID_ENUM
I think this fixes the bug.  I'm not sure why it would fail, and it may have something to do with the version of OpenGL that we initialize and use by default. Regardless, this should take care of the problem.
2012-01-10 21:00:47 -05:00
Sam Lantinga
e56031aa50 X11 OpenGL ES minor corrections
Scott Percival 2012-01-08 04:21:22 PST

I tested the new build on my two ARM machines, and fixed a few bugs:
- if SDL_VIDEO_DRIVER_UIKIT, SDL_VIDEO_DRIVER_ANDROID or
SDL_VIDEO_DRIVER_PANDORA are specified, function pointers are grabbed from the
compile-linked library instead of through SDL_GL_GetProcAddress. (not sure if
this is the best way to go about it)
- removing "/usr/lib/" from all the library names (hey, with multiarch you
can't be too sure anymore)
- added glFinish to glesfuncs.h
- changed the eglGetProcAddress arg type to "const char *" as per the EGL spec
- filled in the stubs for X11_GLES_SetSwapInterval and X11_GLES_GetSwapInterval
2012-01-08 13:31:22 -05:00
Sam Lantinga
07f8710f47 Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Scott Percival 2011-07-03 06:41:51 PDT

This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.

The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION

So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.

The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.

I think that's about everything, let me know if there's anything I've
overlooked.
2012-01-08 02:23:37 -05:00
Sam Lantinga
ccc2bea519 Fixed crash if the rendering system couldn't create an OpenGL window. 2012-01-07 21:01:33 -08:00
Sam Lantinga
da31e3d3e3 Fixed tab spacing 2012-01-07 22:33:58 -05:00
Sam Lantinga
af8d572022 Better error messaging when SDL can't create a window surface. 2012-01-07 14:21:22 -05:00
Sam Lantinga
f4231277fb Fixed bug 1256 - Invalid window warning in GL_CreateRenderer
Martin Gerhardy 2011-07-27 02:26:06 PDT
the window reference is lost in the GL_CreateRenderer function. The attached
patch should fix this error.

#0  SDLSystem_LogOutputFunction (userdata=0x63b010, category=1,
priority=SDL_LOG_PRIORITY_ERROR, message=0x7fffffffcd00 "Invalid window") at
src/system/sdl/SDLSystem.cpp:8
#1  0x00007ffff7b1ddb3 in SDL_LogMessageV (category=1,
priority=SDL_LOG_PRIORITY_ERROR, fmt=<value optimized out>, ap=<value optimized
out>) at src/SDL_log.c:275
#2  0x00007ffff7b1df7c in SDL_LogError (category=<value optimized out>,
fmt=<value optimized out>) at src/SDL_log.c:212
#3  0x00007ffff7b1d582 in SDL_SetError (fmt=0x7ffff7baaff0 "") at
src/SDL_error.c:111
#4  0x00007ffff7b96f9e in SDL_GL_MakeCurrent (window=0x0, ctx=0xa62ce0) at
src/video/SDL_video.c:2484
#5  0x00007ffff7b4ba0c in GL_ActivateRenderer (renderer=0xa8f680) at
src/render/opengl/SDL_render_gl.c:195
#6  0x00007ffff7b4c59a in GL_ResetState (window=0x918010, flags=<value
optimized out>) at src/render/opengl/SDL_render_gl.c:214
#7  GL_CreateRenderer (window=0x918010, flags=<value optimized out>) at
src/render/opengl/SDL_render_gl.c:343
#8  0x00007ffff7b48053 in SDL_CreateRenderer (window=0x918010, index=<value
optimized out>, flags=2) at src/render/SDL_render.c:166
2012-01-07 02:32:08 -05:00
Sam Lantinga
caf36db44a Fixed bug 1344 - No OpenGL headers when compiling -> no working Software renderer at runtime neither
Make sure we have at least one render driver.
2012-01-07 01:13:15 -05:00
Sam Lantinga
e256711bb9 Happy New Year! 2011-12-31 09:28:07 -05:00
Sam Lantinga
41ea58b0ef Added the ability to update a subrect of a YV12/IYUV texture. 2011-12-30 18:19:35 -05:00
Sam Lantinga
e60d18d093 Fixed bug 1315 - Greenish video when video size smaller than texture
The incoming pixels are contiguous for the update rectangle.
2011-12-30 18:18:42 -05:00
Sam Lantinga
6b53a98d93 Fixed bug 1338 - Direct3D renderer should set D3DCREATE_FPU_PRESERVE for not behaving vastly different on doubles (causes 3rd party lib crashes!)
Jonas Thiem 2011-11-29 12:28:02 PST
Direct3D renderer should set D3DCREATE_FPU_PRESERVE for not behaving vastly
different to OpenGL/software rendering on doubles and break some libraries
really badly.

Most notable affected example: Lua, which does the most unpredictable things
which are really almost impossible to debug/find out for beginners who never
heard this culprit exists.

Since I believe all renderers should behave the same on that doubles simply
work as expected in a program, this should really be changed! (also this wasted
a few days of my life wondering why everything in my program was so broken)
2011-12-29 05:18:16 -05:00
Sam Lantinga
604270e214 Fixed bug 1335 - Added support for different pixel formats in OpenGL ES 2 renderer
Gueniffey 2011-11-23 04:06:31 PST

The attached patch adds native support for
SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888
2011-12-29 05:11:33 -05:00