Query available formats before advertising them.
authorSam Lantinga <slouken@libsdl.org>
Sat, 03 Jan 2009 04:33:19 +0000
changeset 29720a4b70368372
parent 2971 a3012c6652ff
child 2973 ab0c00f1b070
Query available formats before advertising them.
src/video/win32/SDL_d3drender.c
     1.1 --- a/src/video/win32/SDL_d3drender.c	Sat Jan 03 01:20:55 2009 +0000
     1.2 +++ b/src/video/win32/SDL_d3drender.c	Sat Jan 03 04:33:19 2009 +0000
     1.3 @@ -88,20 +88,8 @@
     1.4        SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
     1.5       (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST |
     1.6        SDL_TEXTURESCALEMODE_SLOW | SDL_TEXTURESCALEMODE_BEST),
     1.7 -     12,
     1.8 -     {
     1.9 -      SDL_PIXELFORMAT_INDEX8,
    1.10 -      SDL_PIXELFORMAT_RGB332,
    1.11 -      SDL_PIXELFORMAT_RGB444,
    1.12 -      SDL_PIXELFORMAT_RGB555,
    1.13 -      SDL_PIXELFORMAT_ARGB4444,
    1.14 -      SDL_PIXELFORMAT_ARGB1555,
    1.15 -      SDL_PIXELFORMAT_RGB565,
    1.16 -      SDL_PIXELFORMAT_RGB888,
    1.17 -      SDL_PIXELFORMAT_ARGB8888,
    1.18 -      SDL_PIXELFORMAT_ARGB2101010,
    1.19 -      SDL_PIXELFORMAT_YUY2,
    1.20 -      SDL_PIXELFORMAT_UYVY},
    1.21 +     0,
    1.22 +     {0},
    1.23       0,
    1.24       0}
    1.25  };
    1.26 @@ -242,8 +230,40 @@
    1.27  D3D_AddRenderDriver(_THIS)
    1.28  {
    1.29      SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    1.30 +    SDL_RendererInfo *info = &D3D_RenderDriver.info;
    1.31 +    SDL_DisplayMode *mode = &SDL_CurrentDisplay.desktop_mode;
    1.32  
    1.33      if (data->d3d) {
    1.34 +        int i;
    1.35 +        int formats[] = {
    1.36 +          SDL_PIXELFORMAT_INDEX8,
    1.37 +          SDL_PIXELFORMAT_RGB332,
    1.38 +          SDL_PIXELFORMAT_RGB444,
    1.39 +          SDL_PIXELFORMAT_RGB555,
    1.40 +          SDL_PIXELFORMAT_ARGB4444,
    1.41 +          SDL_PIXELFORMAT_ARGB1555,
    1.42 +          SDL_PIXELFORMAT_RGB565,
    1.43 +          SDL_PIXELFORMAT_RGB888,
    1.44 +          SDL_PIXELFORMAT_ARGB8888,
    1.45 +          SDL_PIXELFORMAT_ARGB2101010,
    1.46 +          SDL_PIXELFORMAT_YUY2,
    1.47 +          SDL_PIXELFORMAT_UYVY,
    1.48 +        };
    1.49 +        HRESULT result;
    1.50 +
    1.51 +        for (i = 0; i < SDL_arraysize(formats); ++i) {
    1.52 +            result = IDirect3D9_CheckDeviceFormat(data->d3d,
    1.53 +                                                  D3DADAPTER_DEFAULT,        /* FIXME */
    1.54 +                                                  D3DDEVTYPE_HAL,
    1.55 +                                                  PixelFormatToD3DFMT(mode->format),
    1.56 +                                                  0,
    1.57 +                                                  D3DRTYPE_TEXTURE,
    1.58 +                                                  PixelFormatToD3DFMT(formats[i]));
    1.59 +            if (!FAILED(result)) {
    1.60 +                info->texture_formats[info->num_texture_formats++] = formats[i];
    1.61 +            }
    1.62 +        }
    1.63 +
    1.64          SDL_AddRenderDriver(0, &D3D_RenderDriver);
    1.65      }
    1.66  }