Mercurial > sdl-ios-xcode
comparison src/video/win32/SDL_d3drender.c @ 2990:502adab079a4
indent
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 04 Jan 2009 17:14:27 +0000 |
parents | ab0c00f1b070 |
children | 8f4ed5ec2b06 |
comparison
equal
deleted
inserted
replaced
2989:aba5a5cc2e63 | 2990:502adab079a4 |
---|---|
37 #endif | 37 #endif |
38 | 38 |
39 static SDL_Renderer *D3D_CreateRenderer(SDL_Window * window, Uint32 flags); | 39 static SDL_Renderer *D3D_CreateRenderer(SDL_Window * window, Uint32 flags); |
40 static int D3D_DisplayModeChanged(SDL_Renderer * renderer); | 40 static int D3D_DisplayModeChanged(SDL_Renderer * renderer); |
41 static int D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); | 41 static int D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); |
42 static int D3D_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture, void **pixels, int *pitch); | 42 static int D3D_QueryTexturePixels(SDL_Renderer * renderer, |
43 SDL_Texture * texture, void **pixels, | |
44 int *pitch); | |
43 static int D3D_SetTexturePalette(SDL_Renderer * renderer, | 45 static int D3D_SetTexturePalette(SDL_Renderer * renderer, |
44 SDL_Texture * texture, | 46 SDL_Texture * texture, |
45 const SDL_Color * colors, int firstcolor, | 47 const SDL_Color * colors, int firstcolor, |
46 int ncolors); | 48 int ncolors); |
47 static int D3D_GetTexturePalette(SDL_Renderer * renderer, | 49 static int D3D_GetTexturePalette(SDL_Renderer * renderer, |
230 return D3DFMT_UNKNOWN; | 232 return D3DFMT_UNKNOWN; |
231 } | 233 } |
232 } | 234 } |
233 | 235 |
234 static SDL_bool | 236 static SDL_bool |
235 D3D_IsTextureFormatAvailable(IDirect3D9 *d3d, Uint32 display_format, Uint32 texture_format) | 237 D3D_IsTextureFormatAvailable(IDirect3D9 * d3d, Uint32 display_format, |
238 Uint32 texture_format) | |
236 { | 239 { |
237 HRESULT result; | 240 HRESULT result; |
238 | 241 |
239 result = IDirect3D9_CheckDeviceFormat(d3d, | 242 result = IDirect3D9_CheckDeviceFormat(d3d, D3DADAPTER_DEFAULT, /* FIXME */ |
240 D3DADAPTER_DEFAULT, /* FIXME */ | |
241 D3DDEVTYPE_HAL, | 243 D3DDEVTYPE_HAL, |
242 PixelFormatToD3DFMT(display_format), | 244 PixelFormatToD3DFMT(display_format), |
243 0, | 245 0, |
244 D3DRTYPE_TEXTURE, | 246 D3DRTYPE_TEXTURE, |
245 PixelFormatToD3DFMT(texture_format)); | 247 PixelFormatToD3DFMT |
248 (texture_format)); | |
246 return FAILED(result) ? SDL_FALSE : SDL_TRUE; | 249 return FAILED(result) ? SDL_FALSE : SDL_TRUE; |
247 } | 250 } |
248 | 251 |
249 static void | 252 static void |
250 UpdateYUVTextureData(SDL_Texture * texture) | 253 UpdateYUVTextureData(SDL_Texture * texture) |
258 d3drect.left = 0; | 261 d3drect.left = 0; |
259 d3drect.right = texture->w; | 262 d3drect.right = texture->w; |
260 d3drect.top = 0; | 263 d3drect.top = 0; |
261 d3drect.bottom = texture->h; | 264 d3drect.bottom = texture->h; |
262 | 265 |
263 result = IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0); | 266 result = |
267 IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0); | |
264 if (FAILED(result)) { | 268 if (FAILED(result)) { |
265 return; | 269 return; |
266 } | 270 } |
267 | 271 |
268 rect.x = 0; | 272 rect.x = 0; |
283 SDL_DisplayMode *mode = &SDL_CurrentDisplay.desktop_mode; | 287 SDL_DisplayMode *mode = &SDL_CurrentDisplay.desktop_mode; |
284 | 288 |
285 if (data->d3d) { | 289 if (data->d3d) { |
286 int i; | 290 int i; |
287 int formats[] = { | 291 int formats[] = { |
288 SDL_PIXELFORMAT_INDEX8, | 292 SDL_PIXELFORMAT_INDEX8, |
289 SDL_PIXELFORMAT_RGB332, | 293 SDL_PIXELFORMAT_RGB332, |
290 SDL_PIXELFORMAT_RGB444, | 294 SDL_PIXELFORMAT_RGB444, |
291 SDL_PIXELFORMAT_RGB555, | 295 SDL_PIXELFORMAT_RGB555, |
292 SDL_PIXELFORMAT_ARGB4444, | 296 SDL_PIXELFORMAT_ARGB4444, |
293 SDL_PIXELFORMAT_ARGB1555, | 297 SDL_PIXELFORMAT_ARGB1555, |
294 SDL_PIXELFORMAT_RGB565, | 298 SDL_PIXELFORMAT_RGB565, |
295 SDL_PIXELFORMAT_RGB888, | 299 SDL_PIXELFORMAT_RGB888, |
296 SDL_PIXELFORMAT_ARGB8888, | 300 SDL_PIXELFORMAT_ARGB8888, |
297 SDL_PIXELFORMAT_ARGB2101010, | 301 SDL_PIXELFORMAT_ARGB2101010, |
298 }; | 302 }; |
299 | 303 |
300 for (i = 0; i < SDL_arraysize(formats); ++i) { | 304 for (i = 0; i < SDL_arraysize(formats); ++i) { |
301 if (D3D_IsTextureFormatAvailable(data->d3d, mode->format, formats[i])) { | 305 if (D3D_IsTextureFormatAvailable |
302 info->texture_formats[info->num_texture_formats++] = formats[i]; | 306 (data->d3d, mode->format, formats[i])) { |
307 info->texture_formats[info->num_texture_formats++] = | |
308 formats[i]; | |
303 } | 309 } |
304 } | 310 } |
305 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YV12; | 311 info->texture_formats[info->num_texture_formats++] = |
306 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_IYUV; | 312 SDL_PIXELFORMAT_YV12; |
307 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YUY2; | 313 info->texture_formats[info->num_texture_formats++] = |
308 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_UYVY; | 314 SDL_PIXELFORMAT_IYUV; |
309 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YVYU; | 315 info->texture_formats[info->num_texture_formats++] = |
316 SDL_PIXELFORMAT_YUY2; | |
317 info->texture_formats[info->num_texture_formats++] = | |
318 SDL_PIXELFORMAT_UYVY; | |
319 info->texture_formats[info->num_texture_formats++] = | |
320 SDL_PIXELFORMAT_YVYU; | |
310 | 321 |
311 SDL_AddRenderDriver(0, &D3D_RenderDriver); | 322 SDL_AddRenderDriver(0, &D3D_RenderDriver); |
312 } | 323 } |
313 } | 324 } |
314 | 325 |
547 | 558 |
548 texture->driverdata = data; | 559 texture->driverdata = data; |
549 | 560 |
550 if (SDL_ISPIXELFORMAT_FOURCC(texture->format) && | 561 if (SDL_ISPIXELFORMAT_FOURCC(texture->format) && |
551 (texture->format != SDL_PIXELFORMAT_YUY2 || | 562 (texture->format != SDL_PIXELFORMAT_YUY2 || |
552 !D3D_IsTextureFormatAvailable(renderdata->d3d, display_format, texture->format)) && | 563 !D3D_IsTextureFormatAvailable(renderdata->d3d, display_format, |
553 (texture->format != SDL_PIXELFORMAT_YVYU || | 564 texture->format)) |
554 !D3D_IsTextureFormatAvailable(renderdata->d3d, display_format, texture->format))) { | 565 && (texture->format != SDL_PIXELFORMAT_YVYU |
566 || !D3D_IsTextureFormatAvailable(renderdata->d3d, display_format, | |
567 texture->format))) { | |
555 data->yuv = | 568 data->yuv = |
556 SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h); | 569 SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h); |
557 if (!data->yuv) { | 570 if (!data->yuv) { |
558 return -1; | 571 return -1; |
559 } | 572 } |
678 HRESULT result; | 691 HRESULT result; |
679 | 692 |
680 result = | 693 result = |
681 IDirect3DDevice9_CreateTexture(renderdata->device, texture->w, | 694 IDirect3DDevice9_CreateTexture(renderdata->device, texture->w, |
682 texture->h, 1, 0, | 695 texture->h, 1, 0, |
683 PixelFormatToD3DFMT(texture->format), | 696 PixelFormatToD3DFMT(texture-> |
697 format), | |
684 D3DPOOL_SYSTEMMEM, &temp, NULL); | 698 D3DPOOL_SYSTEMMEM, &temp, NULL); |
685 if (FAILED(result)) { | 699 if (FAILED(result)) { |
686 D3D_SetError("CreateTexture()", result); | 700 D3D_SetError("CreateTexture()", result); |
687 return -1; | 701 return -1; |
688 } | 702 } |
731 d3drect.right = rect->x + rect->w; | 745 d3drect.right = rect->x + rect->w; |
732 d3drect.top = rect->y; | 746 d3drect.top = rect->y; |
733 d3drect.bottom = rect->y + rect->h; | 747 d3drect.bottom = rect->y + rect->h; |
734 | 748 |
735 result = | 749 result = |
736 IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0); | 750 IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, |
751 0); | |
737 if (FAILED(result)) { | 752 if (FAILED(result)) { |
738 D3D_SetError("LockRect()", result); | 753 D3D_SetError("LockRect()", result); |
739 return -1; | 754 return -1; |
740 } | 755 } |
741 | 756 |
774 d3drect.top = rect->y; | 789 d3drect.top = rect->y; |
775 d3drect.bottom = rect->y + rect->h; | 790 d3drect.bottom = rect->y + rect->h; |
776 | 791 |
777 result = | 792 result = |
778 IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, | 793 IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, |
779 markDirty ? 0 : D3DLOCK_NO_DIRTY_UPDATE); | 794 markDirty ? 0 : |
795 D3DLOCK_NO_DIRTY_UPDATE); | |
780 if (FAILED(result)) { | 796 if (FAILED(result)) { |
781 D3D_SetError("LockRect()", result); | 797 D3D_SetError("LockRect()", result); |
782 return -1; | 798 return -1; |
783 } | 799 } |
784 *pixels = locked.pBits; | 800 *pixels = locked.pBits; |