Commit graph

89 commits

Author SHA1 Message Date
David Ludwig
86b7c57477 Fixed Bug 3147 - Windows: Crash when resizing Window since hg 333216331863
Thanks for the fix, Gab!
2016-06-24 22:17:56 -04:00
Sam Lantinga
7ee8dda270 Updated copyright to 2016 2016-01-02 10:10:34 -08:00
Sam Lantinga
ce7104f384 Fixed bug 2625 - Direct3D9 with SDL_TEXTUREACCESS_TARGET textures causes an application crash
Roberto

I have debugged the code checking the function calls when Direct3D is the renderer, remember that with software and OpenGL renderers, this issue is not happening.

- Create the texture:
SDL_Texture *pTex = SDL_CreateTexture(pRenderer, iFormat, SDL_TEXTUREACCESS_TARGET, pSurf->w, pSurf->h);

- Update the texture:
SDL_UpdateTexture(pTex, NULL, pSurf->pixels, pSurf->pitch);
  SDL_render.c, SDL_UpdateTexture(): return renderer->UpdateTexture(renderer, texture, rect, pixels, pitch);
    SDL_render_d3d.c, D3D_UpdateTexture(): if (D3D_UpdateTextureRep(data->device, &texturedata->texture, texture->format, rect->x, rect->y, rect->w, rect->h, pixels, pitch) < 0) {
      SDL_render_d3d.c, D3D_UpdateTextureRep(): if (D3D_CreateStagingTexture(device, texture) < 0) {
        SDL_render_d3d.c, D3D_CreateStagingTexture(): result = IDirect3DDevice9_CreateTexture(..., D3DPOOL_SYSTEMMEM, ...) --> FAIL! with INVALIDCALL code

After checking a bit the Microsoft documentation, I found this:

D3DUSAGE_RENDERTARGET can only be used with D3DPOOL_DEFAULT. (bb172625%28v=vs.85%29.aspx)

The call that fails, is using D3DUSAGE_RENDERTARGET with D3DPOOL_SYSTEMMEM which is unsupported, hence the INVALIDCALL return code.
2015-06-04 00:56:11 -07:00
Sam Lantinga
d727fa668a Fixed clip rectangle calculation when there is a viewport offset 2015-05-28 18:57:10 -07:00
Sam Lantinga
56b58afdbe Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
Sam Lantinga
cba9f49587 Fixed bug 2685 - SDL_RenderReadPixels() doesn't work with offscreen targets
Andreas Falkenhahn

SDL_RenderReadPixels() doesn't seem to work when trying to read pixels from a texture that has been created using SDL_TEXTUREACCESS_TARGET and has been selected as the render target using SDL_SetRenderTarget().

I am attaching a small program that demonstrates the issue. I get the following result here:

READ PIXEL RETURN: 0 --- COLOR CHECK: ff000000

But it should be:

READ PIXEL RETURN: 0 --- COLOR CHECK: ffff0000

Tested with SDL 2.0.3 on Windows 7.
2014-08-17 14:44:53 -07:00
Sam Lantinga
5619521805 Fixed bugs 2677 and 2625, made it possible to lock render targets in D3D 2014-08-16 23:17:47 -07:00
Sam Lantinga
9d42bf534d Fixed mingw64 build and warnings 2014-07-07 10:26:28 -07:00
Alfred Reynolds
156e48e6bf The YUV offset is 16 / 255, not 16 / 256 2014-07-03 10:22:12 -07:00
Sam Lantinga
4a1537da07 Setting the window size changes the fullscreen display mode, unless a window display mode has been set.
Testing:
* Ran testsprite2 --fullscreen, used Ctrl+ and Ctrl- to change window sizes, verified that the display mode changed as well.
2014-06-04 10:57:52 -07:00
Sam Lantinga
297d5c065a Fixed crash and lost pixel data when recovering from a lost device situation (e.g. alt-tab from fullscreen) 2014-06-04 10:57:40 -07:00
Sam Lantinga
7ab938363f Use D3D9Ex when available
This hopefully works around crashes in Intel D3D9 support in Windows 8.1.
2014-05-31 11:37:12 -07:00
Philipp Wiesemann
ed89f98f5b Changed C++ style comments. 2014-05-18 21:11:30 +02: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
d16a9a6781 Fixed D3D9 initialization on Windows 8, which doesn't have D3DX 2014-03-10 17:19:19 -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
0fe823b5cd Fixed crash if the input data pitch is larger than the locked texture pitch 2014-02-25 10:04:49 -08:00
Sam Lantinga
efdbdb5ae7 Fixed infinite recursion in D3D_Reset() 2014-02-20 21:07:56 -08:00
Sam Lantinga
6b4444c027 Fixed resetting the current render target if the D3D device is reset while using a non-default render target. 2014-02-17 22:20:33 -08:00
Sam Lantinga
9eb2cc5c7a Fixed crash if render target textures are used while the device is lost 2014-02-10 13:40:02 -08:00
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