21 #include "../../SDL_internal.h" 26 #if SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED 28 #include "../../core/windows/SDL_windows.h" 33 #include "../SDL_sysrender.h" 34 #include "../SDL_d3dmath.h" 35 #include "../../video/windows/SDL_windowsvideo.h" 37 #if SDL_VIDEO_RENDER_D3D 38 #define D3D_DEBUG_INFO 43 #ifdef ASSEMBLE_SHADER 44 #pragma comment(lib, "d3dx9.lib") 58 typedef interface ID3DXBuffer ID3DXBuffer;
59 typedef interface ID3DXBuffer *LPD3DXBUFFER;
62 DEFINE_GUID(IID_ID3DXBuffer,
63 0x8ba5fb08, 0x5195, 0x40e2, 0xac, 0x58, 0xd, 0x98, 0x9c, 0x3a, 0
x1, 0
x2);
66 #define INTERFACE ID3DXBuffer 68 typedef interface ID3DXBuffer {
69 const struct ID3DXBufferVtbl
FAR* lpVtbl;
71 typedef const struct ID3DXBufferVtbl ID3DXBufferVtbl;
72 const struct ID3DXBufferVtbl
75 STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
76 STDMETHOD_(ULONG, AddRef)(THIS) PURE;
77 STDMETHOD_(ULONG, Release)(THIS) PURE;
80 STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE;
81 STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE;
88 CONST LPVOID* pDefines,
91 LPD3DXBUFFER* ppShader,
92 LPD3DXBUFFER* ppErrorMsgs);
94 static void PrintShaderData(LPDWORD shader_data, DWORD shader_size)
96 OutputDebugStringA(
"const DWORD shader_data[] = {\n\t");
100 for (i = 0; i < shader_size /
sizeof(DWORD); ++
i) {
107 OutputDebugStringA(
",\n ");
110 OutputDebugStringA(
", ");
113 SDL_snprintf(dword,
sizeof(dword),
"0x%8.8x", shader_data[i]);
114 OutputDebugStringA(dword);
116 OutputDebugStringA(
"\n};\n");
135 const Uint8 *Yplane,
int Ypitch,
136 const Uint8 *Uplane,
int Upitch,
137 const Uint8 *Vplane,
int Vpitch);
182 D3DPRESENT_PARAMETERS pparams;
186 D3DTEXTUREFILTERTYPE scaleMode[8];
187 IDirect3DSurface9 *defaultRenderTarget;
188 IDirect3DSurface9 *currentRenderTarget;
190 LPDIRECT3DPIXELSHADER9 ps_yuv;
200 IDirect3DTexture9 *staging;
206 D3DTEXTUREFILTERTYPE scaleMode;
210 D3D_TextureRep utexture;
211 D3D_TextureRep vtexture;
225 D3D_SetError(
const char *prefix, HRESULT
result)
230 case D3DERR_WRONGTEXTUREFORMAT:
231 error =
"WRONGTEXTUREFORMAT";
233 case D3DERR_UNSUPPORTEDCOLOROPERATION:
234 error =
"UNSUPPORTEDCOLOROPERATION";
236 case D3DERR_UNSUPPORTEDCOLORARG:
237 error =
"UNSUPPORTEDCOLORARG";
239 case D3DERR_UNSUPPORTEDALPHAOPERATION:
240 error =
"UNSUPPORTEDALPHAOPERATION";
242 case D3DERR_UNSUPPORTEDALPHAARG:
243 error =
"UNSUPPORTEDALPHAARG";
245 case D3DERR_TOOMANYOPERATIONS:
246 error =
"TOOMANYOPERATIONS";
248 case D3DERR_CONFLICTINGTEXTUREFILTER:
249 error =
"CONFLICTINGTEXTUREFILTER";
251 case D3DERR_UNSUPPORTEDFACTORVALUE:
252 error =
"UNSUPPORTEDFACTORVALUE";
254 case D3DERR_CONFLICTINGRENDERSTATE:
255 error =
"CONFLICTINGRENDERSTATE";
257 case D3DERR_UNSUPPORTEDTEXTUREFILTER:
258 error =
"UNSUPPORTEDTEXTUREFILTER";
260 case D3DERR_CONFLICTINGTEXTUREPALETTE:
261 error =
"CONFLICTINGTEXTUREPALETTE";
263 case D3DERR_DRIVERINTERNALERROR:
264 error =
"DRIVERINTERNALERROR";
266 case D3DERR_NOTFOUND:
269 case D3DERR_MOREDATA:
272 case D3DERR_DEVICELOST:
273 error =
"DEVICELOST";
275 case D3DERR_DEVICENOTRESET:
276 error =
"DEVICENOTRESET";
278 case D3DERR_NOTAVAILABLE:
279 error =
"NOTAVAILABLE";
281 case D3DERR_OUTOFVIDEOMEMORY:
282 error =
"OUTOFVIDEOMEMORY";
284 case D3DERR_INVALIDDEVICE:
285 error =
"INVALIDDEVICE";
287 case D3DERR_INVALIDCALL:
288 error =
"INVALIDCALL";
290 case D3DERR_DRIVERINVALIDCALL:
291 error =
"DRIVERINVALIDCALL";
293 case D3DERR_WASSTILLDRAWING:
294 error =
"WASSTILLDRAWING";
308 return D3DFMT_R5G6B5;
310 return D3DFMT_X8R8G8B8;
312 return D3DFMT_A8R8G8B8;
317 return D3DFMT_UNKNOWN;
322 D3DFMTToPixelFormat(D3DFORMAT format)
327 case D3DFMT_X8R8G8B8:
329 case D3DFMT_A8R8G8B8:
337 D3D_InitRenderState(D3D_RenderData *
data)
343 IDirect3DDevice9_SetVertexShader(device,
NULL);
344 IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
345 IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_FALSE);
346 IDirect3DDevice9_SetRenderState(device, D3DRS_CULLMODE, D3DCULL_NONE);
347 IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING,
FALSE);
350 IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLOROP,
352 IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG1,
354 IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_COLORARG2,
358 IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAOP,
360 IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAARG1,
362 IDirect3DDevice9_SetTextureStageState(device, 0, D3DTSS_ALPHAARG2,
366 if (data->enableSeparateAlphaBlend) {
367 IDirect3DDevice9_SetRenderState(device, D3DRS_SEPARATEALPHABLENDENABLE,
TRUE);
371 IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_COLOROP,
373 IDirect3DDevice9_SetTextureStageState(device, 1, D3DTSS_ALPHAOP,
377 matrix.m[0][0] = 1.0f;
378 matrix.m[0][1] = 0.0f;
379 matrix.m[0][2] = 0.0f;
380 matrix.m[0][3] = 0.0f;
381 matrix.m[1][0] = 0.0f;
382 matrix.m[1][1] = 1.0f;
383 matrix.m[1][2] = 0.0f;
384 matrix.m[1][3] = 0.0f;
385 matrix.m[2][0] = 0.0f;
386 matrix.m[2][1] = 0.0f;
387 matrix.m[2][2] = 1.0f;
388 matrix.m[2][3] = 0.0f;
389 matrix.m[3][0] = 0.0f;
390 matrix.m[3][1] = 0.0f;
391 matrix.m[3][2] = 0.0f;
392 matrix.m[3][3] = 1.0f;
393 IDirect3DDevice9_SetTransform(device, D3DTS_WORLD, &matrix);
394 IDirect3DDevice9_SetTransform(device, D3DTS_VIEW, &matrix);
397 SDL_memset(data->scaleMode, 0xFF,
sizeof(data->scaleMode));
406 D3D_RenderData *data = (D3D_RenderData *) renderer->
driverdata;
411 if (data->defaultRenderTarget) {
412 IDirect3DSurface9_Release(data->defaultRenderTarget);
413 data->defaultRenderTarget =
NULL;
415 if (data->currentRenderTarget !=
NULL) {
416 IDirect3DSurface9_Release(data->currentRenderTarget);
417 data->currentRenderTarget =
NULL;
423 D3D_DestroyTexture(renderer,
texture);
425 D3D_RecreateTexture(renderer,
texture);
429 result = IDirect3DDevice9_Reset(data->device, &data->pparams);
431 if (result == D3DERR_DEVICELOST) {
435 return D3D_SetError(
"Reset()", result);
442 D3D_CreateTexture(renderer,
texture);
446 IDirect3DDevice9_GetRenderTarget(data->device, 0, &data->defaultRenderTarget);
447 D3D_InitRenderState(data);
448 D3D_SetRenderTargetInternal(renderer, renderer->
target);
449 D3D_UpdateViewport(renderer);
464 D3D_RenderData *data = (D3D_RenderData *) renderer->
driverdata;
467 if (data->updateSize) {
473 data->pparams.BackBufferWidth =
w;
474 data->pparams.BackBufferHeight =
h;
478 data->pparams.Windowed =
FALSE;
479 data->pparams.BackBufferFormat = PixelFormatToD3DFMT(fullscreen_mode.
format);
480 data->pparams.FullScreen_RefreshRateInHz = fullscreen_mode.
refresh_rate;
482 data->pparams.Windowed =
TRUE;
483 data->pparams.BackBufferFormat = D3DFMT_UNKNOWN;
484 data->pparams.FullScreen_RefreshRateInHz = 0;
486 if (D3D_Reset(renderer) < 0) {
492 if (data->beginScene) {
493 result = IDirect3DDevice9_BeginScene(data->device);
494 if (result == D3DERR_DEVICELOST) {
495 if (D3D_Reset(renderer) < 0) {
498 result = IDirect3DDevice9_BeginScene(data->device);
501 return D3D_SetError(
"BeginScene()", result);
512 D3D_RenderData *
data;
516 D3DPRESENT_PARAMETERS pparams;
517 IDirect3DSwapChain9 *chain;
531 data = (D3D_RenderData *)
SDL_calloc(1,
sizeof(*data));
564 renderer->
info = D3D_RenderDriver.
info;
576 pparams.hDeviceWindow = windowinfo.
info.win.
window;
577 pparams.BackBufferWidth =
w;
578 pparams.BackBufferHeight =
h;
579 pparams.BackBufferCount = 1;
580 pparams.SwapEffect = D3DSWAPEFFECT_DISCARD;
582 if (window_flags &
SDL_WINDOW_FULLSCREEN && (window_flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP) {
583 pparams.Windowed =
FALSE;
584 pparams.BackBufferFormat = PixelFormatToD3DFMT(fullscreen_mode.
format);
585 pparams.FullScreen_RefreshRateInHz = fullscreen_mode.
refresh_rate;
587 pparams.Windowed =
TRUE;
588 pparams.BackBufferFormat = D3DFMT_UNKNOWN;
589 pparams.FullScreen_RefreshRateInHz = 0;
592 pparams.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
594 pparams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
601 IDirect3D9_GetDeviceCaps(data->d3d, data->adapter, D3DDEVTYPE_HAL, &caps);
603 device_flags = D3DCREATE_FPU_PRESERVE;
604 if (caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) {
605 device_flags |= D3DCREATE_HARDWARE_VERTEXPROCESSING;
607 device_flags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;
612 device_flags |= D3DCREATE_MULTITHREADED;
615 result = IDirect3D9_CreateDevice(data->d3d, data->adapter,
617 pparams.hDeviceWindow,
619 &pparams, &data->device);
621 D3D_DestroyRenderer(renderer);
622 D3D_SetError(
"CreateDevice()", result);
627 result = IDirect3DDevice9_GetSwapChain(data->device, 0, &chain);
629 D3D_DestroyRenderer(renderer);
630 D3D_SetError(
"GetSwapChain()", result);
633 result = IDirect3DSwapChain9_GetPresentParameters(chain, &pparams);
635 IDirect3DSwapChain9_Release(chain);
636 D3D_DestroyRenderer(renderer);
637 D3D_SetError(
"GetPresentParameters()", result);
640 IDirect3DSwapChain9_Release(chain);
641 if (pparams.PresentationInterval == D3DPRESENT_INTERVAL_ONE) {
644 data->pparams = pparams;
646 IDirect3DDevice9_GetDeviceCaps(data->device, &caps);
649 if (caps.NumSimultaneousRTs >= 2) {
653 if (caps.PrimitiveMiscCaps & D3DPMISCCAPS_SEPARATEALPHABLEND) {
654 data->enableSeparateAlphaBlend =
SDL_TRUE;
658 IDirect3DDevice9_GetRenderTarget(data->device, 0, &data->defaultRenderTarget);
659 data->currentRenderTarget =
NULL;
662 D3D_InitRenderState(data);
664 if (caps.MaxSimultaneousTextures >= 3)
666 #ifdef ASSEMBLE_SHADER 727 const char *shader_text =
729 "def c0, -0.0627451017, -0.501960814, -0.501960814, 1\n" 730 "def c1, 1.16400003, 0, 1.59599996, 0\n" 731 "def c2, 1.16400003, -0.391000003, -0.813000023, 0\n" 732 "def c3, 1.16400003, 2.01799989, 0, 0\n" 743 "add r0.xyz, r0, c0\n" 746 "dp2add r1.z, r0, c3, c3.z\n" 752 LPD3DXBUFFER pErrorMsgs;
753 LPDWORD shader_data =
NULL;
754 DWORD shader_size = 0;
755 result = D3DXAssembleShader(shader_text,
SDL_strlen(shader_text),
NULL,
NULL, 0, &pCode, &pErrorMsgs);
757 shader_data = (DWORD*)pCode->lpVtbl->GetBufferPointer(pCode);
758 shader_size = pCode->lpVtbl->GetBufferSize(pCode);
759 PrintShaderData(shader_data, shader_size);
761 const char *error = (
const char *)pErrorMsgs->lpVtbl->GetBufferPointer(pErrorMsgs);
765 const DWORD shader_data[] = {
766 0xffff0200, 0x05000051, 0xa00f0000, 0xbd808081, 0xbf008081, 0xbf008081,
767 0x3f800000, 0x05000051, 0xa00f0001, 0x3f94fdf4, 0x00000000, 0x3fcc49ba,
768 0x00000000, 0x05000051, 0xa00f0002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5,
769 0x00000000, 0x05000051, 0xa00f0003, 0x3f94fdf4, 0x400126e9, 0x00000000,
770 0x00000000, 0x0200001f, 0x80000000, 0xb0030000, 0x0200001f, 0x80000000,
771 0x900f0000, 0x0200001f, 0x90000000, 0xa00f0800, 0x0200001f, 0x90000000,
772 0xa00f0801, 0x0200001f, 0x90000000, 0xa00f0802, 0x03000042, 0x800f0000,
773 0xb0e40000, 0xa0e40800, 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40801,
774 0x03000042, 0x800f0002, 0xb0e40000, 0xa0e40802, 0x02000001, 0x80020000,
775 0x80000001, 0x02000001, 0x80040000, 0x80000002, 0x03000002, 0x80070000,
776 0x80e40000, 0xa0e40000, 0x03000008, 0x80010001, 0x80e40000, 0xa0e40001,
777 0x03000008, 0x80020001, 0x80e40000, 0xa0e40002, 0x0400005a, 0x80040001,
778 0x80e40000, 0xa0e40003, 0xa0aa0003, 0x02000001, 0x80080001, 0xa0ff0000,
779 0x03000005, 0x800f0000, 0x80e40001, 0x90e40000, 0x02000001, 0x800f0800,
780 0x80e40000, 0x0000ffff
783 if (shader_data !=
NULL) {
784 result = IDirect3DDevice9_CreatePixelShader(data->device, shader_data, &data->ps_yuv);
789 D3D_SetError(
"CreatePixelShader()", result);
800 D3D_RenderData *data = (D3D_RenderData *) renderer->
driverdata;
807 static D3DTEXTUREFILTERTYPE
812 if (!hint || *hint ==
'0' ||
SDL_strcasecmp(hint,
"nearest") == 0) {
813 return D3DTEXF_POINT;
815 return D3DTEXF_LINEAR;
827 texture->usage =
usage;
830 result = IDirect3DDevice9_CreateTexture(device, w, h, 1, usage,
831 PixelFormatToD3DFMT(format),
832 D3DPOOL_DEFAULT, &texture->texture,
NULL);
834 return D3D_SetError(
"CreateTexture(D3DPOOL_DEFAULT)", result);
845 if (texture->staging ==
NULL) {
846 result = IDirect3DDevice9_CreateTexture(device, texture->w, texture->h, 1, 0,
847 PixelFormatToD3DFMT(texture->format),
848 D3DPOOL_SYSTEMMEM, &texture->staging,
NULL);
850 return D3D_SetError(
"CreateTexture(D3DPOOL_SYSTEMMEM)", result);
861 if (texture->dirty && texture->staging) {
862 if (!texture->texture) {
863 result = IDirect3DDevice9_CreateTexture(device, texture->w, texture->h, 1, texture->usage,
864 PixelFormatToD3DFMT(texture->format), D3DPOOL_DEFAULT, &texture->texture,
NULL);
866 return D3D_SetError(
"CreateTexture(D3DPOOL_DEFAULT)", result);
870 result = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)texture->staging, (IDirect3DBaseTexture9 *)texture->texture);
872 return D3D_SetError(
"UpdateTexture()", result);
876 result = IDirect3DDevice9_SetTexture(device, sampler, (IDirect3DBaseTexture9 *)texture->texture);
878 return D3D_SetError(
"SetTexture()", result);
886 if (texture->texture) {
887 IDirect3DTexture9_Release(texture->texture);
888 texture->texture =
NULL;
890 if (texture->staging) {
891 IDirect3DTexture9_AddDirtyRect(texture->staging,
NULL);
901 D3DLOCKED_RECT locked;
907 if (D3D_CreateStagingTexture(device, texture) < 0) {
912 d3drect.right = x +
w;
914 d3drect.bottom = y +
h;
916 result = IDirect3DTexture9_LockRect(texture->staging, 0, &locked, &d3drect, 0);
918 return D3D_SetError(
"LockRect()", result);
921 src = (
const Uint8 *)pixels;
924 if (length == pitch && length == locked.Pitch) {
927 if (length > pitch) {
930 if (length > locked.Pitch) {
931 length = locked.Pitch;
933 for (row = 0; row <
h; ++
row) {
939 result = IDirect3DTexture9_UnlockRect(texture->staging, 0);
941 return D3D_SetError(
"UnlockRect()", result);
949 D3D_DestroyTextureRep(D3D_TextureRep *texture)
951 if (texture->texture) {
952 IDirect3DTexture9_Release(texture->texture);
953 texture->texture =
NULL;
955 if (texture->staging) {
956 IDirect3DTexture9_Release(texture->staging);
957 texture->staging =
NULL;
964 D3D_RenderData *data = (D3D_RenderData *) renderer->
driverdata;
965 D3D_TextureData *texturedata;
968 texturedata = (D3D_TextureData *)
SDL_calloc(1,
sizeof(*texturedata));
977 usage = D3DUSAGE_RENDERTARGET;
982 if (D3D_CreateTextureRep(data->device, &texturedata->texture, usage, texture->
format, texture->
w, texture->
h) < 0) {
990 if (D3D_CreateTextureRep(data->device, &texturedata->utexture, usage, texture->
format, texture->
w / 2, texture->
h / 2) < 0) {
994 if (D3D_CreateTextureRep(data->device, &texturedata->vtexture, usage, texture->
format, texture->
w / 2, texture->
h / 2) < 0) {
1004 D3D_RenderData *data = (D3D_RenderData *)renderer->
driverdata;
1005 D3D_TextureData *texturedata = (D3D_TextureData *)texture->
driverdata;
1007 if (D3D_RecreateTextureRep(data->device, &texturedata->texture, texture->
format, texture->
w, texture->
h) < 0) {
1011 if (texturedata->yuv) {
1012 if (D3D_RecreateTextureRep(data->device, &texturedata->utexture, texture->
format, texture->
w / 2, texture->
h / 2) < 0) {
1016 if (D3D_RecreateTextureRep(data->device, &texturedata->vtexture, texture->
format, texture->
w / 2, texture->
h / 2) < 0) {
1027 D3D_RenderData *data = (D3D_RenderData *)renderer->
driverdata;
1028 D3D_TextureData *texturedata = (D3D_TextureData *) texture->
driverdata;
1035 if (D3D_UpdateTextureRep(data->device, &texturedata->texture, texture->
format, rect->
x, rect->
y, rect->
w, rect->
h, pixels, pitch) < 0) {
1039 if (texturedata->yuv) {
1041 pixels = (
const void*)((
const Uint8*)pixels + rect->
h * pitch);
1043 if (D3D_UpdateTextureRep(data->device, texture->
format ==
SDL_PIXELFORMAT_YV12 ? &texturedata->vtexture : &texturedata->utexture, texture->
format, rect->
x / 2, rect->
y / 2, rect->
w / 2, rect->
h / 2, pixels, pitch / 2) < 0) {
1048 pixels = (
const void*)((
const Uint8*)pixels + (rect->
h * pitch)/4);
1049 if (D3D_UpdateTextureRep(data->device, texture->
format ==
SDL_PIXELFORMAT_YV12 ? &texturedata->utexture : &texturedata->vtexture, texture->
format, rect->
x / 2, rect->
y / 2, rect->
w / 2, rect->
h / 2, pixels, pitch / 2) < 0) {
1059 const Uint8 *Yplane,
int Ypitch,
1060 const Uint8 *Uplane,
int Upitch,
1061 const Uint8 *Vplane,
int Vpitch)
1063 D3D_RenderData *data = (D3D_RenderData *)renderer->
driverdata;
1064 D3D_TextureData *texturedata = (D3D_TextureData *) texture->
driverdata;
1071 if (D3D_UpdateTextureRep(data->device, &texturedata->texture, texture->
format, rect->
x, rect->
y, rect->
w, rect->
h, Yplane, Ypitch) < 0) {
1074 if (D3D_UpdateTextureRep(data->device, &texturedata->utexture, texture->
format, rect->
x / 2, rect->
y / 2, rect->
w / 2, rect->
h / 2, Uplane, Upitch) < 0) {
1077 if (D3D_UpdateTextureRep(data->device, &texturedata->vtexture, texture->
format, rect->
x / 2, rect->
y / 2, rect->
w / 2, rect->
h / 2, Vplane, Vpitch) < 0) {
1085 const SDL_Rect * rect,
void **pixels,
int *pitch)
1087 D3D_RenderData *data = (D3D_RenderData *)renderer->
driverdata;
1088 D3D_TextureData *texturedata = (D3D_TextureData *)texture->
driverdata;
1096 texturedata->locked_rect = *
rect;
1098 if (texturedata->yuv) {
1100 if (!texturedata->pixels) {
1101 texturedata->pitch = texture->
w;
1102 texturedata->pixels = (
Uint8 *)
SDL_malloc((texture->
h * texturedata->pitch * 3) / 2);
1103 if (!texturedata->pixels) {
1108 (
void *) ((
Uint8 *) texturedata->pixels + rect->
y * texturedata->pitch +
1110 *pitch = texturedata->pitch;
1113 D3DLOCKED_RECT locked;
1116 if (D3D_CreateStagingTexture(device, &texturedata->texture) < 0) {
1120 d3drect.left = rect->
x;
1121 d3drect.right = rect->
x + rect->
w;
1122 d3drect.top = rect->
y;
1123 d3drect.bottom = rect->
y + rect->
h;
1125 result = IDirect3DTexture9_LockRect(texturedata->texture.staging, 0, &locked, &d3drect, 0);
1127 return D3D_SetError(
"LockRect()", result);
1129 *pixels = locked.pBits;
1130 *pitch = locked.Pitch;
1139 D3D_TextureData *texturedata = (D3D_TextureData *)texture->
driverdata;
1145 if (texturedata->yuv) {
1146 const SDL_Rect *rect = &texturedata->locked_rect;
1148 (
void *) ((
Uint8 *) texturedata->pixels + rect->
y * texturedata->pitch +
1150 D3D_UpdateTexture(renderer, texture, rect, pixels, texturedata->pitch);
1152 IDirect3DTexture9_UnlockRect(texturedata->texture.staging, 0);
1153 texturedata->texture.dirty =
SDL_TRUE;
1160 D3D_RenderData *data = (D3D_RenderData *) renderer->
driverdata;
1161 D3D_TextureData *texturedata;
1162 D3D_TextureRep *texturerep;
1167 if (data->currentRenderTarget !=
NULL) {
1168 IDirect3DSurface9_Release(data->currentRenderTarget);
1169 data->currentRenderTarget =
NULL;
1172 if (texture ==
NULL) {
1173 IDirect3DDevice9_SetRenderTarget(data->device, 0, data->defaultRenderTarget);
1177 texturedata = (D3D_TextureData *)texture->
driverdata;
1184 texturerep = &texturedata->texture;
1185 if (texturerep->dirty && texturerep->staging) {
1186 if (!texturerep->texture) {
1187 result = IDirect3DDevice9_CreateTexture(device, texturerep->w, texturerep->h, 1, texturerep->usage,
1188 PixelFormatToD3DFMT(texturerep->format), D3DPOOL_DEFAULT, &texturerep->texture,
NULL);
1190 return D3D_SetError(
"CreateTexture(D3DPOOL_DEFAULT)", result);
1194 result = IDirect3DDevice9_UpdateTexture(device, (IDirect3DBaseTexture9 *)texturerep->staging, (IDirect3DBaseTexture9 *)texturerep->texture);
1196 return D3D_SetError(
"UpdateTexture()", result);
1201 result = IDirect3DTexture9_GetSurfaceLevel(texturedata->texture.texture, 0, &data->currentRenderTarget);
1203 return D3D_SetError(
"GetSurfaceLevel()", result);
1205 result = IDirect3DDevice9_SetRenderTarget(data->device, 0, data->currentRenderTarget);
1207 return D3D_SetError(
"SetRenderTarget()", result);
1216 D3D_ActivateRenderer(renderer);
1218 return D3D_SetRenderTargetInternal(renderer, texture);
1224 D3D_RenderData *data = (D3D_RenderData *) renderer->
driverdata;
1235 IDirect3DDevice9_SetViewport(data->device, &
viewport);
1239 matrix.m[0][0] = 2.0f / renderer->
viewport.
w;
1240 matrix.m[0][1] = 0.0f;
1241 matrix.m[0][2] = 0.0f;
1242 matrix.m[0][3] = 0.0f;
1243 matrix.m[1][0] = 0.0f;
1244 matrix.m[1][1] = -2.0f / renderer->
viewport.
h;
1245 matrix.m[1][2] = 0.0f;
1246 matrix.m[1][3] = 0.0f;
1247 matrix.m[2][0] = 0.0f;
1248 matrix.m[2][1] = 0.0f;
1249 matrix.m[2][2] = 1.0f;
1250 matrix.m[2][3] = 0.0f;
1251 matrix.m[3][0] = -1.0f;
1252 matrix.m[3][1] = 1.0f;
1253 matrix.m[3][2] = 0.0f;
1254 matrix.m[3][3] = 1.0f;
1255 IDirect3DDevice9_SetTransform(data->device, D3DTS_PROJECTION, &matrix);
1264 D3D_RenderData *data = (D3D_RenderData *) renderer->
driverdata;
1271 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SCISSORTESTENABLE,
TRUE);
1274 r.right = renderer->
viewport.
x + rect->
x + rect->
w;
1275 r.bottom = renderer->
viewport.
y + rect->
y + rect->
h;
1277 result = IDirect3DDevice9_SetScissorRect(data->device, &r);
1278 if (result != D3D_OK) {
1279 D3D_SetError(
"SetScissor()", result);
1283 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SCISSORTESTENABLE,
FALSE);
1291 D3D_RenderData *data = (D3D_RenderData *) renderer->
driverdata;
1294 int BackBufferWidth, BackBufferHeight;
1296 if (D3D_ActivateRenderer(renderer) < 0) {
1300 color = D3DCOLOR_ARGB(renderer->
a, renderer->
r, renderer->
g, renderer->
b);
1303 BackBufferWidth = renderer->
target->
w;
1304 BackBufferHeight = renderer->
target->
h;
1306 BackBufferWidth = data->pparams.BackBufferWidth;
1307 BackBufferHeight = data->pparams.BackBufferHeight;
1312 renderer->
viewport.
w == BackBufferWidth &&
1313 renderer->
viewport.
h == BackBufferHeight) {
1314 result = IDirect3DDevice9_Clear(data->device, 0,
NULL, D3DCLEAR_TARGET,
color, 0.0f, 0);
1321 viewport.Width = BackBufferWidth;
1322 viewport.Height = BackBufferHeight;
1323 viewport.MinZ = 0.0f;
1324 viewport.MaxZ = 1.0f;
1325 IDirect3DDevice9_SetViewport(data->device, &viewport);
1327 result = IDirect3DDevice9_Clear(data->device, 0,
NULL, D3DCLEAR_TARGET,
color, 0.0f, 0);
1334 viewport.MinZ = 0.0f;
1335 viewport.MaxZ = 1.0f;
1336 IDirect3DDevice9_SetViewport(data->device, &viewport);
1340 return D3D_SetError(
"Clear()", result);
1346 D3D_SetBlendMode(D3D_RenderData * data,
int blendMode)
1348 switch (blendMode) {
1350 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
1354 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
1356 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
1358 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
1359 D3DBLEND_INVSRCALPHA);
1360 if (data->enableSeparateAlphaBlend) {
1361 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLENDALPHA,
1363 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLENDALPHA,
1364 D3DBLEND_INVSRCALPHA);
1368 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
1370 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
1372 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
1374 if (data->enableSeparateAlphaBlend) {
1375 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLENDALPHA,
1377 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLENDALPHA,
1382 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
1384 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
1386 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
1388 if (data->enableSeparateAlphaBlend) {
1389 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLENDALPHA,
1391 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLENDALPHA,
1402 D3D_RenderData *data = (D3D_RenderData *) renderer->
driverdata;
1408 if (D3D_ActivateRenderer(renderer) < 0) {
1412 D3D_SetBlendMode(data, renderer->
blendMode);
1415 IDirect3DDevice9_SetTexture(data->device, 0,
1416 (IDirect3DBaseTexture9 *) 0);
1418 return D3D_SetError(
"SetTexture()", result);
1421 color = D3DCOLOR_ARGB(renderer->
a, renderer->
r, renderer->
g, renderer->
b);
1424 for (i = 0; i <
count; ++
i) {
1425 vertices[
i].x = points[
i].
x;
1426 vertices[
i].y = points[
i].
y;
1427 vertices[
i].z = 0.0f;
1428 vertices[
i].color =
color;
1429 vertices[
i].u = 0.0f;
1430 vertices[
i].v = 0.0f;
1433 IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, count,
1434 vertices,
sizeof(*vertices));
1437 return D3D_SetError(
"DrawPrimitiveUP()", result);
1446 D3D_RenderData *data = (D3D_RenderData *) renderer->
driverdata;
1452 if (D3D_ActivateRenderer(renderer) < 0) {
1456 D3D_SetBlendMode(data, renderer->
blendMode);
1459 IDirect3DDevice9_SetTexture(data->device, 0,
1460 (IDirect3DBaseTexture9 *) 0);
1462 return D3D_SetError(
"SetTexture()", result);
1465 color = D3DCOLOR_ARGB(renderer->
a, renderer->
r, renderer->
g, renderer->
b);
1468 for (i = 0; i <
count; ++
i) {
1469 vertices[
i].x = points[
i].
x;
1470 vertices[
i].y = points[
i].
y;
1471 vertices[
i].z = 0.0f;
1472 vertices[
i].color =
color;
1473 vertices[
i].u = 0.0f;
1474 vertices[
i].v = 0.0f;
1477 IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_LINESTRIP, count-1,
1478 vertices,
sizeof(*vertices));
1483 points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
1484 vertices[0].x = points[count-1].
x;
1485 vertices[0].y = points[count-1].
y;
1486 result = IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, 1, vertices,
sizeof(*vertices));
1491 return D3D_SetError(
"DrawPrimitiveUP()", result);
1500 D3D_RenderData *data = (D3D_RenderData *) renderer->
driverdata;
1503 float minx, miny, maxx, maxy;
1507 if (D3D_ActivateRenderer(renderer) < 0) {
1511 D3D_SetBlendMode(data, renderer->
blendMode);
1514 IDirect3DDevice9_SetTexture(data->device, 0,
1515 (IDirect3DBaseTexture9 *) 0);
1517 return D3D_SetError(
"SetTexture()", result);
1520 color = D3DCOLOR_ARGB(renderer->
a, renderer->
r, renderer->
g, renderer->
b);
1522 for (i = 0; i <
count; ++
i) {
1527 maxx = rect->
x + rect->
w;
1528 maxy = rect->
y + rect->
h;
1530 vertices[0].x = minx;
1531 vertices[0].y = miny;
1532 vertices[0].z = 0.0f;
1533 vertices[0].color =
color;
1534 vertices[0].u = 0.0f;
1535 vertices[0].v = 0.0f;
1537 vertices[1].x = maxx;
1538 vertices[1].y = miny;
1539 vertices[1].z = 0.0f;
1540 vertices[1].color =
color;
1541 vertices[1].u = 0.0f;
1542 vertices[1].v = 0.0f;
1544 vertices[2].x = maxx;
1545 vertices[2].y = maxy;
1546 vertices[2].z = 0.0f;
1547 vertices[2].color =
color;
1548 vertices[2].u = 0.0f;
1549 vertices[2].v = 0.0f;
1551 vertices[3].x = minx;
1552 vertices[3].y = maxy;
1553 vertices[3].z = 0.0f;
1554 vertices[3].color =
color;
1555 vertices[3].u = 0.0f;
1556 vertices[3].v = 0.0f;
1559 IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN,
1560 2, vertices,
sizeof(*vertices));
1562 return D3D_SetError(
"DrawPrimitiveUP()", result);
1569 D3D_UpdateTextureScaleMode(D3D_RenderData *data, D3D_TextureData *texturedata,
unsigned index)
1571 if (texturedata->scaleMode != data->scaleMode[index]) {
1572 IDirect3DDevice9_SetSamplerState(data->device, index, D3DSAMP_MINFILTER,
1573 texturedata->scaleMode);
1574 IDirect3DDevice9_SetSamplerState(data->device, index, D3DSAMP_MAGFILTER,
1575 texturedata->scaleMode);
1576 data->scaleMode[
index] = texturedata->scaleMode;
1584 D3D_RenderData *data = (D3D_RenderData *) renderer->
driverdata;
1585 D3D_TextureData *texturedata;
1587 float minx, miny, maxx, maxy;
1588 float minu, maxu, minv, maxv;
1593 if (D3D_ActivateRenderer(renderer) < 0) {
1597 texturedata = (D3D_TextureData *)texture->
driverdata;
1603 minx = dstrect->
x - 0.5f;
1604 miny = dstrect->
y - 0.5f;
1605 maxx = dstrect->
x + dstrect->
w - 0.5f;
1606 maxy = dstrect->
y + dstrect->
h - 0.5f;
1608 minu = (float) srcrect->
x / texture->
w;
1609 maxu = (
float) (srcrect->
x + srcrect->
w) / texture->
w;
1610 minv = (
float) srcrect->
y / texture->
h;
1611 maxv = (float) (srcrect->
y + srcrect->
h) / texture->
h;
1613 color = D3DCOLOR_ARGB(texture->
a, texture->
r, texture->
g, texture->
b);
1615 vertices[0].x = minx;
1616 vertices[0].y = miny;
1617 vertices[0].z = 0.0f;
1618 vertices[0].color =
color;
1619 vertices[0].u = minu;
1620 vertices[0].v = minv;
1622 vertices[1].x = maxx;
1623 vertices[1].y = miny;
1624 vertices[1].z = 0.0f;
1625 vertices[1].color =
color;
1626 vertices[1].u = maxu;
1627 vertices[1].v = minv;
1629 vertices[2].x = maxx;
1630 vertices[2].y = maxy;
1631 vertices[2].z = 0.0f;
1632 vertices[2].color =
color;
1633 vertices[2].u = maxu;
1634 vertices[2].v = maxv;
1636 vertices[3].x = minx;
1637 vertices[3].y = maxy;
1638 vertices[3].z = 0.0f;
1639 vertices[3].color =
color;
1640 vertices[3].u = minu;
1641 vertices[3].v = maxv;
1643 D3D_SetBlendMode(data, texture->
blendMode);
1645 D3D_UpdateTextureScaleMode(data, texturedata, 0);
1647 if (D3D_BindTextureRep(data->device, &texturedata->texture, 0) < 0) {
1651 if (texturedata->yuv) {
1654 D3D_UpdateTextureScaleMode(data, texturedata, 1);
1655 D3D_UpdateTextureScaleMode(data, texturedata, 2);
1657 if (D3D_BindTextureRep(data->device, &texturedata->utexture, 1) < 0) {
1660 if (D3D_BindTextureRep(data->device, &texturedata->vtexture, 2) < 0) {
1666 result = IDirect3DDevice9_SetPixelShader(data->device,
shader);
1668 return D3D_SetError(
"SetShader()", result);
1672 IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN, 2,
1673 vertices,
sizeof(*vertices));
1675 return D3D_SetError(
"DrawPrimitiveUP()", result);
1678 result = IDirect3DDevice9_SetPixelShader(data->device,
NULL);
1680 return D3D_SetError(
"SetShader()", result);
1692 D3D_RenderData *data = (D3D_RenderData *) renderer->
driverdata;
1693 D3D_TextureData *texturedata;
1695 float minx, miny, maxx, maxy;
1696 float minu, maxu, minv, maxv;
1697 float centerx, centery;
1700 Float4X4 modelMatrix;
1703 if (D3D_ActivateRenderer(renderer) < 0) {
1707 texturedata = (D3D_TextureData *)texture->
driverdata;
1713 centerx = center->
x;
1714 centery = center->
y;
1717 minx = dstrect->
w - centerx - 0.5f;
1718 maxx = -centerx - 0.5f;
1721 minx = -centerx - 0.5f;
1722 maxx = dstrect->
w - centerx - 0.5f;
1726 miny = dstrect->
h - centery - 0.5f;
1727 maxy = -centery - 0.5f;
1730 miny = -centery - 0.5f;
1731 maxy = dstrect->
h - centery - 0.5f;
1734 minu = (float) srcrect->
x / texture->
w;
1735 maxu = (
float) (srcrect->
x + srcrect->
w) / texture->
w;
1736 minv = (
float) srcrect->
y / texture->
h;
1737 maxv = (float) (srcrect->
y + srcrect->
h) / texture->
h;
1739 color = D3DCOLOR_ARGB(texture->
a, texture->
r, texture->
g, texture->
b);
1741 vertices[0].x = minx;
1742 vertices[0].y = miny;
1743 vertices[0].z = 0.0f;
1744 vertices[0].color =
color;
1745 vertices[0].u = minu;
1746 vertices[0].v = minv;
1748 vertices[1].x = maxx;
1749 vertices[1].y = miny;
1750 vertices[1].z = 0.0f;
1751 vertices[1].color =
color;
1752 vertices[1].u = maxu;
1753 vertices[1].v = minv;
1755 vertices[2].x = maxx;
1756 vertices[2].y = maxy;
1757 vertices[2].z = 0.0f;
1758 vertices[2].color =
color;
1759 vertices[2].u = maxu;
1760 vertices[2].v = maxv;
1762 vertices[3].x = minx;
1763 vertices[3].y = maxy;
1764 vertices[3].z = 0.0f;
1765 vertices[3].color =
color;
1766 vertices[3].u = minu;
1767 vertices[3].v = maxv;
1769 D3D_SetBlendMode(data, texture->
blendMode);
1772 modelMatrix = MatrixMultiply(
1773 MatrixRotationZ((
float)(
M_PI * (
float) angle / 180.0
f)),
1774 MatrixTranslation(dstrect->
x + center->
x, dstrect->
y + center->
y, 0)
1776 IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX*)&modelMatrix);
1778 D3D_UpdateTextureScaleMode(data, texturedata, 0);
1780 if (D3D_BindTextureRep(data->device, &texturedata->texture, 0) < 0) {
1784 if (texturedata->yuv) {
1787 D3D_UpdateTextureScaleMode(data, texturedata, 1);
1788 D3D_UpdateTextureScaleMode(data, texturedata, 2);
1790 if (D3D_BindTextureRep(data->device, &texturedata->utexture, 1) < 0) {
1793 if (D3D_BindTextureRep(data->device, &texturedata->vtexture, 2) < 0) {
1799 result = IDirect3DDevice9_SetPixelShader(data->device,
shader);
1801 return D3D_SetError(
"SetShader()", result);
1805 IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN, 2,
1806 vertices,
sizeof(*vertices));
1808 return D3D_SetError(
"DrawPrimitiveUP()", result);
1811 result = IDirect3DDevice9_SetPixelShader(data->device,
NULL);
1813 return D3D_SetError(
"SetShader()", result);
1817 modelMatrix = MatrixIdentity();
1818 IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX*)&modelMatrix);
1824 Uint32 format,
void * pixels,
int pitch)
1826 D3D_RenderData *data = (D3D_RenderData *) renderer->
driverdata;
1827 D3DSURFACE_DESC desc;
1828 LPDIRECT3DSURFACE9 backBuffer;
1829 LPDIRECT3DSURFACE9 surface;
1831 D3DLOCKED_RECT locked;
1834 if (data->currentRenderTarget) {
1835 backBuffer = data->currentRenderTarget;
1837 backBuffer = data->defaultRenderTarget;
1840 result = IDirect3DSurface9_GetDesc(backBuffer, &desc);
1842 IDirect3DSurface9_Release(backBuffer);
1843 return D3D_SetError(
"GetDesc()", result);
1846 result = IDirect3DDevice9_CreateOffscreenPlainSurface(data->device, desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &surface,
NULL);
1848 IDirect3DSurface9_Release(backBuffer);
1849 return D3D_SetError(
"CreateOffscreenPlainSurface()", result);
1852 result = IDirect3DDevice9_GetRenderTargetData(data->device, backBuffer, surface);
1854 IDirect3DSurface9_Release(surface);
1855 IDirect3DSurface9_Release(backBuffer);
1856 return D3D_SetError(
"GetRenderTargetData()", result);
1859 d3drect.left = rect->
x;
1860 d3drect.right = rect->
x + rect->
w;
1861 d3drect.top = rect->
y;
1862 d3drect.bottom = rect->
y + rect->
h;
1864 result = IDirect3DSurface9_LockRect(surface, &locked, &d3drect, D3DLOCK_READONLY);
1866 IDirect3DSurface9_Release(surface);
1867 IDirect3DSurface9_Release(backBuffer);
1868 return D3D_SetError(
"LockRect()", result);
1872 D3DFMTToPixelFormat(desc.Format), locked.pBits, locked.Pitch,
1873 format, pixels, pitch);
1875 IDirect3DSurface9_UnlockRect(surface);
1877 IDirect3DSurface9_Release(surface);
1885 D3D_RenderData *data = (D3D_RenderData *) renderer->
driverdata;
1888 if (!data->beginScene) {
1889 IDirect3DDevice9_EndScene(data->device);
1893 result = IDirect3DDevice9_TestCooperativeLevel(data->device);
1894 if (result == D3DERR_DEVICELOST) {
1898 if (result == D3DERR_DEVICENOTRESET) {
1899 D3D_Reset(renderer);
1903 D3D_SetError(
"Present()", result);
1910 D3D_TextureData *data = (D3D_TextureData *) texture->
driverdata;
1915 D3D_DestroyTextureRep(&data->texture);
1916 D3D_DestroyTextureRep(&data->utexture);
1917 D3D_DestroyTextureRep(&data->vtexture);
1926 D3D_RenderData *data = (D3D_RenderData *) renderer->
driverdata;
1930 if (data->defaultRenderTarget) {
1931 IDirect3DSurface9_Release(data->defaultRenderTarget);
1932 data->defaultRenderTarget =
NULL;
1934 if (data->currentRenderTarget !=
NULL) {
1935 IDirect3DSurface9_Release(data->currentRenderTarget);
1936 data->currentRenderTarget =
NULL;
1939 IDirect3DPixelShader9_Release(data->ps_yuv);
1942 IDirect3DDevice9_Release(data->device);
1945 IDirect3D9_Release(data->d3d);
1961 #if SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED 1962 D3D_RenderData *data = (D3D_RenderData *) renderer->
driverdata;
1970 device = data->device;
1972 IDirect3DDevice9_AddRef(device);
int(* RenderDrawLines)(SDL_Renderer *renderer, const SDL_FPoint *points, int count)
struct IDirect3D9 IDirect3D9
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
int(* RenderDrawPoints)(SDL_Renderer *renderer, const SDL_FPoint *points, int count)
int(* LockTexture)(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch)
#define SDL_GetWindowDisplayIndex
GLuint GLfloat GLfloat GLfloat x1
GLdouble GLdouble GLdouble r
uint32_t Uint32
An unsigned 32-bit integer type.
int(* RenderReadPixels)(SDL_Renderer *renderer, const SDL_Rect *rect, Uint32 format, void *pixels, int pitch)
GLint GLint GLint GLint GLint x
GLuint GLuint GLsizei count
#define SDL_HINT_RENDER_SCALE_QUALITY
A variable controlling the scaling quality.
GLenum GLenum GLuint texture
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Uint32 texture_formats[16]
The structure that defines a display mode.
#define SDL_GetWindowFlags
#define SDL_BYTESPERPIXEL(X)
int(* RenderFillRects)(SDL_Renderer *renderer, const SDL_FRect *rects, int count)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
int(* RenderClear)(SDL_Renderer *renderer)
void(* DestroyRenderer)(SDL_Renderer *renderer)
GLfixed GLfixed GLint GLint GLfixed points
#define SDL_VERSION(x)
Macro to determine SDL version program was compiled against.
int SDL_Direct3D9GetAdapterIndex(int displayIndex)
Returns the D3D9 adapter index that matches the specified display index.
static SDL_BlendMode blendMode
int(* UpdateTexture)(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch)
int(* UpdateTextureYUV)(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, const Uint8 *Yplane, int Ypitch, const Uint8 *Uplane, int Upitch, const Uint8 *Vplane, int Vpitch)
#define SDL_GetWindowSize
GLsizeiptr const void GLenum usage
void * SDL_calloc(size_t nmemb, size_t size)
#define SDL_GetWindowDisplayMode
GLint GLint GLint GLint GLint GLint y
static int GetScaleQuality(void)
uint8_t Uint8
An unsigned 8-bit integer type.
#define SDL_stack_alloc(type, count)
void(* UnlockTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
int(* SetRenderTarget)(SDL_Renderer *renderer, SDL_Texture *texture)
int(* UpdateViewport)(SDL_Renderer *renderer)
SDL_bool D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface)
SDL_RendererFlip
Flip constants for SDL_RenderCopyEx.
#define SDL_HINT_RENDER_DIRECT3D_THREADSAFE
A variable controlling whether the Direct3D device is initialized for thread-safe operations...
int(* RenderCopy)(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect)
Window state change event data (event.window.*)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
#define SDL_GetWindowWMInfo
#define SDL_OutOfMemory()
int(* RenderCopyEx)(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcquad, const SDL_FRect *dstrect, const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip)
The type used to identify a window.
SDL_Rect rects[MAX_RECTS]
void(* WindowEvent)(SDL_Renderer *renderer, const SDL_WindowEvent *event)
Uint32 num_texture_formats
union SDL_SysWMinfo::@18 info
GLubyte GLubyte GLubyte GLubyte w
#define SDL_ConvertPixels
void(* DestroyTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
int(* CreateTexture)(SDL_Renderer *renderer, SDL_Texture *texture)
void(* RenderPresent)(SDL_Renderer *renderer)
#define SDL_stack_free(data)
GLuint GLsizei GLsizei * length
int(* UpdateClipRect)(SDL_Renderer *renderer)
GLfloat GLfloat GLfloat GLfloat h
IDirect3DDevice9 * SDL_RenderGetD3D9Device(SDL_Renderer *renderer)
Returns the D3D device associated with a renderer, or NULL if it's not a D3D renderer.
SDL_bool clipping_enabled
A rectangle, with the origin at the upper left.
struct IDirect3DDevice9 IDirect3DDevice9