Commit graph

69 commits

Author SHA1 Message Date
Sam Lantinga
f656316b9f Recreate render target textures when the D3D device is being reset, and notify the application using the SDL_RENDER_TARGETS_RESET event when this happens. 2014-02-10 10:02:51 -08:00
Sam Lantinga
018d3e8094 Fixed bug 2385 - error: unknown type name 'IDirect3DDevice9'
Sandu Liviu Catalin

I'm unable to compile the latest SDL (directly from the repository) even though I disabled every DirectX option since I don't need DirectX.

I allways het these errors:
D:\DevLibs\SDL\src\render\direct3d\SDL_render_d3d.c:1897:1: error: unknown type name 'IDirect3DDevice9'
D:\DevLibs\SDL\src\render\direct3d\SDL_render_d3d.c:1898:25: error: unknown type name 'SDL_Renderer'
2014-02-09 01:56:41 -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
Ryan C. Gordon
24aaf535bc Patched to compile...uh, everywhere. :) 2014-01-27 16:13:13 -05:00
Ryan C. Gordon
452acbeeab Patched to compile on Windows when not supporting Direct3D. 2014-01-27 16:10:15 -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
62ec6bf81c Backed out changeset e8f93c2ebda3 - it didn't actually do anything useful
--HG--
extra : rebase_source : d0465ebf6702a1152520fa9a6bfc2e10aac16711
2013-11-14 21:39:54 -08:00
Sam Lantinga
cb3d7d3831 Diagonal flipping with RenderCopyEx
Ivan Rubinson

As it turns out, it was impossible to render a texture flipped diagonally (both vertically and horizontally) with one RenderCopyEx call.
With help from #SDL @ freenode, we came up with a fix.
2013-11-13 21:50:59 -08:00
Sam Lantinga
a161479693 Fixed whitespace
--HG--
extra : rebase_source : 0d52de2be0171755128dd1e06b4722b4bad418a1
2013-10-21 22:08:56 -07:00
Sam Lantinga
473d52d092 Fixed bug 2162 - SDL_RenderClear not clearing entire render target
Kevin Wells

Overview:
SDL_RenderClear is only clearing part of a texture when it is the render target and a different size than the screen.

Steps to Reproduce:
1) This only occurs with the render driver set to direct3d, so: SDL_SetHint(SDL_HINT_RENDER_DRIVER,"direct3d")
Also, my window was 1280x720.

2) Create a texture for a render target with a resolution of 1024x1024:
texture=SDL_CreateTexture(main_window.renderer,SDL_PIXELFORMAT_RGBA8888,SDL_TEXTUREACCESS_TARGET,1024,1024);
SDL_SetTextureBlendMode(texture,SDL_BLENDMODE_BLEND);

3) Target the texture for rendering: SDL_SetRenderTarget(main_window.renderer,texture);

4) Set the draw color to whatever you want (problem occurs with both 0,0,0,0 and 0,0,0,255 among others) and then clear the render target:
SDL_SetRenderDrawColor(main_window.renderer,0,0,0,0);
SDL_RenderClear(main_window.renderer);

Actual Results:
Only about the top 3/4s of the texture gets cleared on calling SDL_RenderClear. The bottom 1/4 or so does not clear.

Expected Results:
Entire render target should be cleared.
2013-10-19 01:29:23 -07:00
Sam Lantinga
a999af88e9 Fixed building using MinGW
Our SDL_windows.h needed to be included before anything else so UNICODE is defined.
2013-10-17 23:02:29 -07:00
Sam Lantinga
06caf6a344 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
2ef24caf1d 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
f86e83feba 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
70c993af2b Added platform specific call: SDL_RenderGetD3DDevice() 2013-09-28 14:07:05 -07:00
Sam Lantinga
585fd26052 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
018c78cd9f Implemented SDL_UpdateYUVTexture() for Direct3D 2013-09-28 14:06:55 -07:00
Sam Lantinga
a759ac24a1 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
Sam Lantinga
0d7001777d 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
Sam Lantinga
08dfaaa2e6 Christoph Mallon: Remove pointless if (x) before SDL_free(x) 2013-08-29 08:29:21 -07:00
Gabriel Jacobo
298ce1c1a7 OCD fixes: Adds a space after /* (glory to regular expressions!) 2013-08-21 09:47:10 -03:00
Gabriel Jacobo
271e0d67c4 OCD fixes: Adds a space before */ 2013-08-21 09:43:09 -03:00
Gabriel Jacobo
5e78879e76 More non C89 compliant comments 2013-08-20 20:34:40 -03:00
Ryan C. Gordon
29ea6509bc Fixed leaking of pixel shader object in D3D renderer (thanks, Peter!).
Fixes Bugzilla #2047.
2013-08-19 11:02:44 -04:00
Sam Lantinga
f082b60d08 Fixed Windows build 2013-08-17 17:14:15 -07:00
Sam Lantinga
f2ddd7c822 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
Sam Lantinga
89c3ac1eab 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
Ryan C. Gordon
a052fa0ae8 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.

--HG--
extra : rebase_source : e01c4da3bae7f1628de7c049f31f1208dbbbb24c
2013-08-06 00:23:04 -04:00
Sam Lantinga
3334092bdc Fixed compiler warning with gcc 2013-07-30 00:02:45 -07:00
Sam Lantinga
08e8f26d62 Added Direct3D shader to hardware accelerate YV12 and IYUV textures. 2013-07-23 12:55:19 -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
a663b9c637 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
Philipp Wiesemann
c8c3817b12 Changed include directive to standard header. 2013-07-07 16:13:17 +02:00
Yuri K. Schlesner
5480cdd85c Re-apply texture filter when resetting direct3d renderer. 2013-05-29 06:31:48 -05: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
Sam Lantinga
cbe94acd8e Fixed bug 1838 - [Patch] Direct3D resource leak on SDL_DestroyRenderer() 2013-05-16 00:56:19 -07:00
Sam Lantinga
866f2e5f9e First pass on SDL render clip rect functionality 2013-05-04 04:46:00 -07: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
541a638836 Fixed compile errors on Windows 2013-03-06 09:45:53 -08:00
Sam Lantinga
4e631c1583 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
1a4596d798 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
Sam Lantinga
95dcfa4c28 Happy New Year! 2013-02-15 08:47:44 -08:00
Sam Lantinga
5f3f837a42 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
Sam Lantinga
f4294fd806 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
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
Ryan C. Gordon
386b1d15cf Whoops, removed wrong variable. 2012-08-24 19:39:51 -04:00
Ryan C. Gordon
816523a285 Fixed a bunch of compiler warnings with Cygwin/MingW. 2012-08-24 19:34:28 -04:00
Sam Lantinga
beb1db9b5b Fixed compiling with Visual Studio 2012-06-19 13:50:14 -04:00