Added platform specific call: SDL_RenderGetD3DDevice()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
diff --git a/include/SDL_system.h b/include/SDL_system.h
index 68ff899..5c31937 100644
--- a/include/SDL_system.h
+++ b/include/SDL_system.h
@@ -29,11 +29,9 @@
#define _SDL_system_h
#include "SDL_stdinc.h"
-
-#if defined(__IPHONEOS__) && __IPHONEOS__
-#include "SDL_video.h"
#include "SDL_keyboard.h"
-#endif
+#include "SDL_render.h"
+#include "SDL_video.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
@@ -51,6 +49,10 @@ extern "C" {
*/
extern DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex( int displayIndex );
+/* Returns the D3D device associated with a renderer, or NULL if it's not a D3D renderer. */
+typedef struct IDirect3DDevice9 IDirect3DDevice9;
+extern DECLSPEC IDirect3DDevice9* SDLCALL SDL_RenderGetD3DDevice(SDL_Renderer * renderer);
+
#endif /* __WIN32__ */
diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c
index 73a2c82..2ac5974 100644
--- a/src/render/direct3d/SDL_render_d3d.c
+++ b/src/render/direct3d/SDL_render_d3d.c
@@ -1875,6 +1875,19 @@ D3D_DestroyRenderer(SDL_Renderer * renderer)
SDL_free(renderer);
}
+IDirect3DDevice9 *
+SDL_RenderGetD3DDevice(SDL_Renderer * renderer)
+{
+ D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
+
+ // Make sure that this is a D3D renderer
+ if (renderer->DestroyRenderer != D3D_DestroyRenderer) {
+ SDL_SetError("Renderer is not a D3D renderer");
+ return NULL;
+ }
+ return data->device;
+}
+
#endif /* SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED */
/* vi: set ts=4 sw=4 expandtab: */