comparison src/video/win32/SDL_d3drender.c @ 1965:a788656ca29a

SDL constants are all uppercase.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 05 Aug 2006 17:09:42 +0000
parents 411bfb37082b
children ccef0d0c40c6
comparison
equal deleted inserted replaced
1964:071b6598d48f 1965:a788656ca29a
58 58
59 SDL_RenderDriver D3D_RenderDriver = { 59 SDL_RenderDriver D3D_RenderDriver = {
60 D3D_CreateRenderer, 60 D3D_CreateRenderer,
61 { 61 {
62 "d3d", 62 "d3d",
63 (SDL_Renderer_SingleBuffer | SDL_Renderer_PresentCopy | 63 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
64 SDL_Renderer_PresentFlip2 | SDL_Renderer_PresentFlip3 | 64 SDL_RENDERER_PRESENTFLIP2 | sDL_RENDERER_PRESENTFLIP3 |
65 SDL_Renderer_PresentDiscard | SDL_Renderer_PresentVSync | 65 SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC |
66 SDL_Renderer_Accelerated), 66 SDL_RENDERER_ACCELERATED),
67 (SDL_TextureBlendMode_None | SDL_TextureBlendMode_Mask | 67 (SDL_TEXTUREBLENDMODE_NONE | SDL_TEXTUREBLENDMODE_MASK |
68 SDL_TextureBlendMode_Blend | SDL_TextureBlendMode_Add | 68 SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD |
69 SDL_TextureBlendMode_Mod), 69 SDL_TEXTUREBLENDMODE_MOD),
70 (SDL_TextureScaleMode_None | SDL_TextureScaleMode_Fast | 70 (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST |
71 SDL_TextureScaleMode_Slow | SDL_TextureScaleMode_Best), 71 SDL_TEXTURESCALEMODE_SLOW | SDL_TEXTURESCALEMODE_BEST),
72 12, 72 12,
73 { 73 {
74 SDL_PixelFormat_Index8, 74 SDL_PIXELFORMAT_INDEX8,
75 SDL_PixelFormat_RGB332, 75 SDL_PIXELFORMAT_RGB332,
76 SDL_PixelFormat_RGB444, 76 SDL_PIXELFORMAT_RGB444,
77 SDL_PixelFormat_RGB555, 77 SDL_PIXELFORMAT_RGB555,
78 SDL_PixelFormat_ARGB4444, 78 SDL_PIXELFORMAT_ARGB4444,
79 SDL_PixelFormat_ARGB1555, 79 SDL_PIXELFORMAT_ARGB1555,
80 SDL_PixelFormat_RGB565, 80 SDL_PIXELFORMAT_RGB565,
81 SDL_PixelFormat_RGB888, 81 SDL_PIXELFORMAT_RGB888,
82 SDL_PixelFormat_ARGB8888, 82 SDL_PIXELFORMAT_ARGB8888,
83 SDL_PixelFormat_ARGB2101010, 83 SDL_PIXELFORMAT_ARGB2101010,
84 SDL_PixelFormat_UYVY, 84 SDL_PIXELFORMAT_UYVY,
85 SDL_PixelFormat_YUY2}, 85 SDL_PIXELFORMAT_YUY2},
86 0, 86 0,
87 0} 87 0}
88 }; 88 };
89 89
90 typedef struct 90 typedef struct
186 186
187 static D3DFORMAT 187 static D3DFORMAT
188 PixelFormatToD3DFMT(Uint32 format) 188 PixelFormatToD3DFMT(Uint32 format)
189 { 189 {
190 switch (format) { 190 switch (format) {
191 case SDL_PixelFormat_Index8: 191 case SDL_PIXELFORMAT_INDEX8:
192 return D3DFMT_P8; 192 return D3DFMT_P8;
193 case SDL_PixelFormat_RGB332: 193 case SDL_PIXELFORMAT_RGB332:
194 return D3DFMT_R3G3B2; 194 return D3DFMT_R3G3B2;
195 case SDL_PixelFormat_RGB444: 195 case SDL_PIXELFORMAT_RGB444:
196 return D3DFMT_X4R4G4B4; 196 return D3DFMT_X4R4G4B4;
197 case SDL_PixelFormat_RGB555: 197 case SDL_PIXELFORMAT_RGB555:
198 return D3DFMT_X1R5G5B5; 198 return D3DFMT_X1R5G5B5;
199 case SDL_PixelFormat_ARGB4444: 199 case SDL_PIXELFORMAT_ARGB4444:
200 return D3DFMT_A4R4G4B4; 200 return D3DFMT_A4R4G4B4;
201 case SDL_PixelFormat_ARGB1555: 201 case SDL_PIXELFORMAT_ARGB1555:
202 return D3DFMT_A1R5G5B5; 202 return D3DFMT_A1R5G5B5;
203 case SDL_PixelFormat_RGB565: 203 case SDL_PIXELFORMAT_RGB565:
204 return D3DFMT_R5G6B5; 204 return D3DFMT_R5G6B5;
205 case SDL_PixelFormat_RGB888: 205 case SDL_PIXELFORMAT_RGB888:
206 return D3DFMT_X8R8G8B8; 206 return D3DFMT_X8R8G8B8;
207 case SDL_PixelFormat_ARGB8888: 207 case SDL_PIXELFORMAT_ARGB8888:
208 return D3DFMT_A8R8G8B8; 208 return D3DFMT_A8R8G8B8;
209 case SDL_PixelFormat_ARGB2101010: 209 case SDL_PIXELFORMAT_ARGB2101010:
210 return D3DFMT_A2R10G10B10; 210 return D3DFMT_A2R10G10B10;
211 case SDL_PixelFormat_UYVY: 211 case SDL_PIXELFORMAT_UYVY:
212 return D3DFMT_UYVY; 212 return D3DFMT_UYVY;
213 case SDL_PixelFormat_YUY2: 213 case SDL_PIXELFORMAT_YUY2:
214 return D3DFMT_YUY2; 214 return D3DFMT_YUY2;
215 default: 215 default:
216 return D3DFMT_UNKNOWN; 216 return D3DFMT_UNKNOWN;
217 } 217 }
218 } 218 }
267 renderer->DestroyRenderer = D3D_DestroyRenderer; 267 renderer->DestroyRenderer = D3D_DestroyRenderer;
268 renderer->info = D3D_RenderDriver.info; 268 renderer->info = D3D_RenderDriver.info;
269 renderer->window = window->id; 269 renderer->window = window->id;
270 renderer->driverdata = data; 270 renderer->driverdata = data;
271 271
272 renderer->info.flags = SDL_Renderer_Accelerated; 272 renderer->info.flags = SDL_RENDERER_ACCELERATED;
273 273
274 SDL_zero(pparams); 274 SDL_zero(pparams);
275 pparams.BackBufferWidth = window->w; 275 pparams.BackBufferWidth = window->w;
276 pparams.BackBufferHeight = window->h; 276 pparams.BackBufferHeight = window->h;
277 if (window->flags & SDL_WINDOW_FULLSCREEN) { 277 if (window->flags & SDL_WINDOW_FULLSCREEN) {
278 pparams.BackBufferFormat = 278 pparams.BackBufferFormat =
279 PixelFormatToD3DFMT(display->fullscreen_mode->format); 279 PixelFormatToD3DFMT(display->fullscreen_mode->format);
280 } else { 280 } else {
281 pparams.BackBufferFormat = D3DFMT_UNKNOWN; 281 pparams.BackBufferFormat = D3DFMT_UNKNOWN;
282 } 282 }
283 if (flags & SDL_Renderer_PresentFlip2) { 283 if (flags & SDL_RENDERER_PRESENTFLIP2) {
284 pparams.BackBufferCount = 2; 284 pparams.BackBufferCount = 2;
285 pparams.SwapEffect = D3DSWAPEFFECT_FLIP; 285 pparams.SwapEffect = D3DSWAPEFFECT_FLIP;
286 } else if (flags & SDL_Renderer_PresentFlip3) { 286 } else if (flags & SDL_RENDERER_PRESENTFLIP3) {
287 pparams.BackBufferCount = 3; 287 pparams.BackBufferCount = 3;
288 pparams.SwapEffect = D3DSWAPEFFECT_FLIP; 288 pparams.SwapEffect = D3DSWAPEFFECT_FLIP;
289 } else if (flags & SDL_Renderer_PresentCopy) { 289 } else if (flags & SDL_RENDERER_PRESENTCOPY) {
290 pparams.BackBufferCount = 1; 290 pparams.BackBufferCount = 1;
291 pparams.SwapEffect = D3DSWAPEFFECT_COPY; 291 pparams.SwapEffect = D3DSWAPEFFECT_COPY;
292 } else { 292 } else {
293 pparams.BackBufferCount = 1; 293 pparams.BackBufferCount = 1;
294 pparams.SwapEffect = D3DSWAPEFFECT_DISCARD; 294 pparams.SwapEffect = D3DSWAPEFFECT_DISCARD;
299 display->fullscreen_mode->refresh_rate; 299 display->fullscreen_mode->refresh_rate;
300 } else { 300 } else {
301 pparams.Windowed = TRUE; 301 pparams.Windowed = TRUE;
302 pparams.FullScreen_RefreshRateInHz = 0; 302 pparams.FullScreen_RefreshRateInHz = 0;
303 } 303 }
304 if (flags & SDL_Renderer_PresentVSync) { 304 if (flags & SDL_RENDERER_PRESENTVSYNC) {
305 pparams.PresentationInterval = D3DPRESENT_INTERVAL_ONE; 305 pparams.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
306 } else { 306 } else {
307 pparams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; 307 pparams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
308 } 308 }
309 309
334 return NULL; 334 return NULL;
335 } 335 }
336 IDirect3DSwapChain9_Release(chain); 336 IDirect3DSwapChain9_Release(chain);
337 switch (pparams.SwapEffect) { 337 switch (pparams.SwapEffect) {
338 case D3DSWAPEFFECT_COPY: 338 case D3DSWAPEFFECT_COPY:
339 renderer->info.flags |= SDL_Renderer_PresentCopy; 339 renderer->info.flags |= SDL_RENDERER_PRESENTCOPY;
340 break; 340 break;
341 case D3DSWAPEFFECT_FLIP: 341 case D3DSWAPEFFECT_FLIP:
342 switch (pparams.BackBufferCount) { 342 switch (pparams.BackBufferCount) {
343 case 2: 343 case 2:
344 renderer->info.flags |= SDL_Renderer_PresentFlip2; 344 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
345 break; 345 break;
346 case 3: 346 case 3:
347 renderer->info.flags |= SDL_Renderer_PresentFlip3; 347 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
348 break; 348 break;
349 } 349 }
350 break; 350 break;
351 case D3DSWAPEFFECT_DISCARD: 351 case D3DSWAPEFFECT_DISCARD:
352 renderer->info.flags |= SDL_Renderer_PresentDiscard; 352 renderer->info.flags |= SDL_RENDERER_PRESENTDISCARD;
353 break; 353 break;
354 } 354 }
355 if (pparams.PresentationInterval == D3DPRESENT_INTERVAL_ONE) { 355 if (pparams.PresentationInterval == D3DPRESENT_INTERVAL_ONE) {
356 renderer->info.flags |= SDL_Renderer_PresentVSync; 356 renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
357 } 357 }
358 358
359 IDirect3DDevice9_GetDeviceCaps(data->device, &caps); 359 IDirect3DDevice9_GetDeviceCaps(data->device, &caps);
360 renderer->info.max_texture_width = caps.MaxTextureWidth; 360 renderer->info.max_texture_width = caps.MaxTextureWidth;
361 renderer->info.max_texture_height = caps.MaxTextureHeight; 361 renderer->info.max_texture_height = caps.MaxTextureHeight;
386 return -1; 386 return -1;
387 } 387 }
388 388
389 texture->driverdata = data; 389 texture->driverdata = data;
390 390
391 if (texture->access == SDL_TextureAccess_Local) { 391 if (texture->access == SDL_TEXTUREACCESS_LOCAL) {
392 pool = D3DPOOL_MANAGED; 392 pool = D3DPOOL_MANAGED;
393 } else { 393 } else {
394 pool = D3DPOOL_DEFAULT; 394 pool = D3DPOOL_DEFAULT;
395 } 395 }
396 result = 396 result =
492 D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; 492 D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
493 RECT d3drect; 493 RECT d3drect;
494 D3DLOCKED_RECT locked; 494 D3DLOCKED_RECT locked;
495 HRESULT result; 495 HRESULT result;
496 496
497 if (texture->access != SDL_TextureAccess_Local) { 497 if (texture->access != SDL_TEXTUREACCESS_LOCAL) {
498 SDL_SetError("Can't lock remote video memory"); 498 SDL_SetError("Can't lock remote video memory");
499 return -1; 499 return -1;
500 } 500 }
501 501
502 d3drect.left = rect->x; 502 d3drect.left = rect->x;
625 vertices[3].rhw = 1.0f; 625 vertices[3].rhw = 1.0f;
626 vertices[3].u = minu; 626 vertices[3].u = minu;
627 vertices[3].v = maxv; 627 vertices[3].v = maxv;
628 628
629 switch (blendMode) { 629 switch (blendMode) {
630 case SDL_TextureBlendMode_None: 630 case SDL_TEXTUREBLENDMODE_NONE:
631 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, 631 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
632 FALSE); 632 FALSE);
633 break; 633 break;
634 case SDL_TextureBlendMode_Mask: 634 case SDL_TEXTUREBLENDMODE_MASK:
635 case SDL_TextureBlendMode_Blend: 635 case SDL_TEXTUREBLENDMODE_BLEND:
636 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, 636 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
637 TRUE); 637 TRUE);
638 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND, 638 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
639 D3DBLEND_SRCALPHA); 639 D3DBLEND_SRCALPHA);
640 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND, 640 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
641 D3DBLEND_INVSRCALPHA); 641 D3DBLEND_INVSRCALPHA);
642 break; 642 break;
643 case SDL_TextureBlendMode_Add: 643 case SDL_TEXTUREBLENDMODE_ADD:
644 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, 644 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
645 TRUE); 645 TRUE);
646 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND, 646 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
647 D3DBLEND_SRCALPHA); 647 D3DBLEND_SRCALPHA);
648 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND, 648 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
649 D3DBLEND_ONE); 649 D3DBLEND_ONE);
650 break; 650 break;
651 case SDL_TextureBlendMode_Mod: 651 case SDL_TEXTUREBLENDMODE_MOD:
652 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, 652 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
653 TRUE); 653 TRUE);
654 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND, 654 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
655 D3DBLEND_ZERO); 655 D3DBLEND_ZERO);
656 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND, 656 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
657 D3DBLEND_SRCCOLOR); 657 D3DBLEND_SRCCOLOR);
658 break; 658 break;
659 } 659 }
660 660
661 switch (scaleMode) { 661 switch (scaleMode) {
662 case SDL_TextureScaleMode_None: 662 case SDL_TEXTURESCALEMODE_NONE:
663 case SDL_TextureScaleMode_Fast: 663 case SDL_TEXTURESCALEMODE_FAST:
664 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER, 664 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER,
665 D3DTEXF_POINT); 665 D3DTEXF_POINT);
666 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER, 666 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER,
667 D3DTEXF_POINT); 667 D3DTEXF_POINT);
668 break; 668 break;
669 case SDL_TextureScaleMode_Slow: 669 case SDL_TEXTURESCALEMODE_SLOW:
670 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER, 670 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER,
671 D3DTEXF_LINEAR); 671 D3DTEXF_LINEAR);
672 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER, 672 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER,
673 D3DTEXF_LINEAR); 673 D3DTEXF_LINEAR);
674 break; 674 break;
675 case SDL_TextureScaleMode_Best: 675 case SDL_TEXTURESCALEMODE_BEST:
676 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER, 676 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER,
677 D3DTEXF_GAUSSIANQUAD); 677 D3DTEXF_GAUSSIANQUAD);
678 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER, 678 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER,
679 D3DTEXF_GAUSSIANQUAD); 679 D3DTEXF_GAUSSIANQUAD);
680 break; 680 break;