Added platform specific call: SDL_RenderGetD3DDevice()
authorSam Lantinga <slouken@libsdl.org>
Sat, 28 Sep 2013 14:07:05 -0700
changeset 7763fc802d707136
parent 7762 51abf7664304
child 7764 0f48b5f28668
Added platform specific call: SDL_RenderGetD3DDevice()
include/SDL_system.h
src/render/direct3d/SDL_render_d3d.c
     1.1 --- a/include/SDL_system.h	Sat Sep 28 14:06:59 2013 -0700
     1.2 +++ b/include/SDL_system.h	Sat Sep 28 14:07:05 2013 -0700
     1.3 @@ -29,11 +29,9 @@
     1.4  #define _SDL_system_h
     1.5  
     1.6  #include "SDL_stdinc.h"
     1.7 -
     1.8 -#if defined(__IPHONEOS__) && __IPHONEOS__
     1.9 +#include "SDL_keyboard.h"
    1.10 +#include "SDL_render.h"
    1.11  #include "SDL_video.h"
    1.12 -#include "SDL_keyboard.h"
    1.13 -#endif
    1.14  
    1.15  #include "begin_code.h"
    1.16  /* Set up for C function definitions, even when using C++ */
    1.17 @@ -51,6 +49,10 @@
    1.18  */
    1.19  extern DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex( int displayIndex );
    1.20  
    1.21 +/* Returns the D3D device associated with a renderer, or NULL if it's not a D3D renderer. */
    1.22 +typedef struct IDirect3DDevice9 IDirect3DDevice9;
    1.23 +extern DECLSPEC IDirect3DDevice9* SDLCALL SDL_RenderGetD3DDevice(SDL_Renderer * renderer);
    1.24 +
    1.25  #endif /* __WIN32__ */
    1.26  
    1.27  
     2.1 --- a/src/render/direct3d/SDL_render_d3d.c	Sat Sep 28 14:06:59 2013 -0700
     2.2 +++ b/src/render/direct3d/SDL_render_d3d.c	Sat Sep 28 14:07:05 2013 -0700
     2.3 @@ -1875,6 +1875,19 @@
     2.4      SDL_free(renderer);
     2.5  }
     2.6  
     2.7 +IDirect3DDevice9 *
     2.8 +SDL_RenderGetD3DDevice(SDL_Renderer * renderer)
     2.9 +{
    2.10 +	D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
    2.11 +
    2.12 +	// Make sure that this is a D3D renderer
    2.13 +	if (renderer->DestroyRenderer != D3D_DestroyRenderer) {
    2.14 +		SDL_SetError("Renderer is not a D3D renderer");
    2.15 +		return NULL;
    2.16 +	}
    2.17 +	return data->device;
    2.18 +}
    2.19 +
    2.20  #endif /* SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED */
    2.21  
    2.22  /* vi: set ts=4 sw=4 expandtab: */