Implemented Windows OpenGL support
authorSam Lantinga <slouken@libsdl.org>
Mon, 17 Jul 2006 06:47:33 +0000
changeset 191383420da906a5
parent 1912 8d384b647307
child 1914 051df511279c
Implemented Windows OpenGL support
Fixed slowdown enumerating display modes, which was hosing OpenGL as well...
Removed SDL_ from the render driver prefixes
src/SDL_compat.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/dummy/SDL_nullvideo.c
src/video/win32/SDL_d3drender.c
src/video/win32/SDL_gdirender.c
src/video/win32/SDL_win32events.c
src/video/win32/SDL_win32modes.c
src/video/win32/SDL_win32opengl.c
src/video/win32/SDL_win32opengl.h
src/video/win32/SDL_win32video.c
src/video/win32/SDL_win32video.h
src/video/win32/SDL_win32window.c
src/video/win32/SDL_win32window.h
     1.1 --- a/src/SDL_compat.c	Sun Jul 16 09:34:01 2006 +0000
     1.2 +++ b/src/SDL_compat.c	Mon Jul 17 06:47:33 2006 +0000
     1.3 @@ -337,7 +337,7 @@
     1.4          SDL_VideoSurface = NULL;
     1.5      }
     1.6      if (SDL_VideoContext) {
     1.7 -        SDL_GL_MakeCurrent(0, SDL_VideoContext);
     1.8 +        SDL_GL_MakeCurrent(0, NULL);
     1.9          SDL_GL_DeleteContext(SDL_VideoContext);
    1.10          SDL_VideoContext = NULL;
    1.11      }
     2.1 --- a/src/video/SDL_sysvideo.h	Sun Jul 16 09:34:01 2006 +0000
     2.2 +++ b/src/video/SDL_sysvideo.h	Mon Jul 17 06:47:33 2006 +0000
     2.3 @@ -172,6 +172,11 @@
     2.4       */
     2.5      int (*VideoInit) (_THIS);
     2.6  
     2.7 +    /* Reverse the effects VideoInit() -- called if VideoInit() fails
     2.8 +       or if the application is shutting down the video subsystem.
     2.9 +     */
    2.10 +    void (*VideoQuit) (_THIS);
    2.11 +
    2.12      /* * * */
    2.13      /* Display functions
    2.14       */
    2.15 @@ -221,17 +226,13 @@
    2.16        SDL_bool(*GetWindowWMInfo) (_THIS, SDL_Window * window,
    2.17                                    struct SDL_SysWMinfo * info);
    2.18  
    2.19 -    /* Reverse the effects VideoInit() -- called if VideoInit() fails
    2.20 -       or if the application is shutting down the video subsystem.
    2.21 -     */
    2.22 -    void (*VideoQuit) (_THIS);
    2.23 -
    2.24      /* * * */
    2.25      /* OpenGL support
    2.26       */
    2.27      int (*GL_LoadLibrary) (_THIS, const char *path);
    2.28      void *(*GL_GetProcAddress) (_THIS, const char *proc);
    2.29 -    int (*GL_GetAttribute) (_THIS, SDL_GLattr attrib, int *value);
    2.30 +    int (*GL_GetWindowAttribute) (_THIS, SDL_Window * window,
    2.31 +                                  SDL_GLattr attrib, int *value);
    2.32        SDL_GLContext(*GL_CreateContext) (_THIS, SDL_Window * window);
    2.33      int (*GL_MakeCurrent) (_THIS, SDL_Window * window, SDL_GLContext context);
    2.34      int (*GL_SetSwapInterval) (_THIS, int interval);
    2.35 @@ -279,7 +280,7 @@
    2.36      /* * * */
    2.37      /* Data private to this driver */
    2.38      void *driverdata;
    2.39 -    struct SDL_PrivateGLData *gl_data;
    2.40 +    struct SDL_GLDriverData *gl_data;
    2.41  
    2.42      /* * * */
    2.43      /* The function used to dispose of this structure */
     3.1 --- a/src/video/SDL_video.c	Sun Jul 16 09:34:01 2006 +0000
     3.2 +++ b/src/video/SDL_video.c	Mon Jul 17 06:47:33 2006 +0000
     3.3 @@ -2117,11 +2117,11 @@
     3.4          return -1;
     3.5      }
     3.6  
     3.7 -    if (_this->GL_GetAttribute) {
     3.8 -        retval = _this->GL_GetAttribute(_this, attr, value);
     3.9 +    if (_this->GL_GetWindowAttribute) {
    3.10 +        retval = _this->GL_GetWindowAttribute(_this, window, attr, value);
    3.11      } else {
    3.12          *value = 0;
    3.13 -        SDL_SetError("GL_GetAttribute not supported");
    3.14 +        SDL_SetError("GL_GetWindowAttribute not supported");
    3.15          retval = -1;
    3.16      }
    3.17      return retval;
    3.18 @@ -2147,10 +2147,7 @@
    3.19  {
    3.20      SDL_Window *window = SDL_GetWindowFromID(windowID);
    3.21  
    3.22 -    if (!window || !context) {
    3.23 -        return -1;
    3.24 -    }
    3.25 -    if (!(window->flags & SDL_WINDOW_OPENGL)) {
    3.26 +    if (window && !(window->flags & SDL_WINDOW_OPENGL)) {
    3.27          SDL_SetError("The specified window isn't an OpenGL window");
    3.28          return -1;
    3.29      }
     4.1 --- a/src/video/dummy/SDL_nullvideo.c	Sun Jul 16 09:34:01 2006 +0000
     4.2 +++ b/src/video/dummy/SDL_nullvideo.c	Mon Jul 17 06:47:33 2006 +0000
     4.3 @@ -89,8 +89,8 @@
     4.4  
     4.5      /* Set the function pointers */
     4.6      device->VideoInit = DUMMY_VideoInit;
     4.7 +    device->VideoQuit = DUMMY_VideoQuit;
     4.8      device->SetDisplayMode = DUMMY_SetDisplayMode;
     4.9 -    device->VideoQuit = DUMMY_VideoQuit;
    4.10      device->PumpEvents = DUMMY_PumpEvents;
    4.11  
    4.12      device->free = DUMMY_DeleteDevice;
     5.1 --- a/src/video/win32/SDL_d3drender.c	Sun Jul 16 09:34:01 2006 +0000
     5.2 +++ b/src/video/win32/SDL_d3drender.c	Mon Jul 17 06:47:33 2006 +0000
     5.3 @@ -27,43 +27,37 @@
     5.4  
     5.5  /* Direct3D renderer implementation */
     5.6  
     5.7 -static SDL_Renderer *SDL_D3D_CreateRenderer(SDL_Window * window,
     5.8 -                                            Uint32 flags);
     5.9 -static int SDL_D3D_CreateTexture(SDL_Renderer * renderer,
    5.10 -                                 SDL_Texture * texture);
    5.11 -static int SDL_D3D_SetTexturePalette(SDL_Renderer * renderer,
    5.12 -                                     SDL_Texture * texture,
    5.13 -                                     const SDL_Color * colors, int firstcolor,
    5.14 -                                     int ncolors);
    5.15 -static int SDL_D3D_GetTexturePalette(SDL_Renderer * renderer,
    5.16 -                                     SDL_Texture * texture,
    5.17 -                                     SDL_Color * colors, int firstcolor,
    5.18 -                                     int ncolors);
    5.19 -static int SDL_D3D_UpdateTexture(SDL_Renderer * renderer,
    5.20 -                                 SDL_Texture * texture, const SDL_Rect * rect,
    5.21 -                                 const void *pixels, int pitch);
    5.22 -static int SDL_D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    5.23 -                               const SDL_Rect * rect, int markDirty,
    5.24 -                               void **pixels, int *pitch);
    5.25 -static void SDL_D3D_UnlockTexture(SDL_Renderer * renderer,
    5.26 -                                  SDL_Texture * texture);
    5.27 -static void SDL_D3D_DirtyTexture(SDL_Renderer * renderer,
    5.28 -                                 SDL_Texture * texture, int numrects,
    5.29 -                                 const SDL_Rect * rects);
    5.30 -static int SDL_D3D_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
    5.31 -                              Uint32 color);
    5.32 -static int SDL_D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
    5.33 -                              const SDL_Rect * srcrect,
    5.34 -                              const SDL_Rect * dstrect, int blendMode,
    5.35 -                              int scaleMode);
    5.36 -static void SDL_D3D_RenderPresent(SDL_Renderer * renderer);
    5.37 -static void SDL_D3D_DestroyTexture(SDL_Renderer * renderer,
    5.38 -                                   SDL_Texture * texture);
    5.39 -static void SDL_D3D_DestroyRenderer(SDL_Renderer * renderer);
    5.40 +static SDL_Renderer *D3D_CreateRenderer(SDL_Window * window, Uint32 flags);
    5.41 +static int D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
    5.42 +static int D3D_SetTexturePalette(SDL_Renderer * renderer,
    5.43 +                                 SDL_Texture * texture,
    5.44 +                                 const SDL_Color * colors, int firstcolor,
    5.45 +                                 int ncolors);
    5.46 +static int D3D_GetTexturePalette(SDL_Renderer * renderer,
    5.47 +                                 SDL_Texture * texture, SDL_Color * colors,
    5.48 +                                 int firstcolor, int ncolors);
    5.49 +static int D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    5.50 +                             const SDL_Rect * rect, const void *pixels,
    5.51 +                             int pitch);
    5.52 +static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    5.53 +                           const SDL_Rect * rect, int markDirty,
    5.54 +                           void **pixels, int *pitch);
    5.55 +static void D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
    5.56 +static void D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    5.57 +                             int numrects, const SDL_Rect * rects);
    5.58 +static int D3D_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
    5.59 +                          Uint32 color);
    5.60 +static int D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
    5.61 +                          const SDL_Rect * srcrect, const SDL_Rect * dstrect,
    5.62 +                          int blendMode, int scaleMode);
    5.63 +static void D3D_RenderPresent(SDL_Renderer * renderer);
    5.64 +static void D3D_DestroyTexture(SDL_Renderer * renderer,
    5.65 +                               SDL_Texture * texture);
    5.66 +static void D3D_DestroyRenderer(SDL_Renderer * renderer);
    5.67  
    5.68  
    5.69 -SDL_RenderDriver SDL_D3D_RenderDriver = {
    5.70 -    SDL_D3D_CreateRenderer,
    5.71 +SDL_RenderDriver D3D_RenderDriver = {
    5.72 +    D3D_CreateRenderer,
    5.73      {
    5.74       "d3d",
    5.75       (SDL_Renderer_SingleBuffer | SDL_Renderer_PresentCopy |
    5.76 @@ -93,12 +87,12 @@
    5.77  {
    5.78      IDirect3DDevice9 *device;
    5.79      SDL_bool beginScene;
    5.80 -} SDL_D3D_RenderData;
    5.81 +} D3D_RenderData;
    5.82  
    5.83  typedef struct
    5.84  {
    5.85      IDirect3DTexture9 *texture;
    5.86 -} SDL_D3D_TextureData;
    5.87 +} D3D_TextureData;
    5.88  
    5.89  typedef struct
    5.90  {
    5.91 @@ -225,18 +219,18 @@
    5.92      SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    5.93  
    5.94      if (data->d3d) {
    5.95 -        SDL_AddRenderDriver(0, &SDL_D3D_RenderDriver);
    5.96 +        SDL_AddRenderDriver(0, &D3D_RenderDriver);
    5.97      }
    5.98  }
    5.99  
   5.100  SDL_Renderer *
   5.101 -SDL_D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
   5.102 +D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
   5.103  {
   5.104      SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
   5.105      SDL_VideoData *videodata = (SDL_VideoData *) display->device->driverdata;
   5.106      SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
   5.107      SDL_Renderer *renderer;
   5.108 -    SDL_D3D_RenderData *data;
   5.109 +    D3D_RenderData *data;
   5.110      HRESULT result;
   5.111      D3DPRESENT_PARAMETERS pparams;
   5.112      IDirect3DSwapChain9 *chain;
   5.113 @@ -248,27 +242,27 @@
   5.114      }
   5.115      SDL_zerop(renderer);
   5.116  
   5.117 -    data = (SDL_D3D_RenderData *) SDL_malloc(sizeof(*data));
   5.118 +    data = (D3D_RenderData *) SDL_malloc(sizeof(*data));
   5.119      if (!data) {
   5.120 -        SDL_D3D_DestroyRenderer(renderer);
   5.121 +        D3D_DestroyRenderer(renderer);
   5.122          SDL_OutOfMemory();
   5.123          return NULL;
   5.124      }
   5.125      SDL_zerop(data);
   5.126  
   5.127 -    renderer->CreateTexture = SDL_D3D_CreateTexture;
   5.128 -    renderer->SetTexturePalette = SDL_D3D_SetTexturePalette;
   5.129 -    renderer->GetTexturePalette = SDL_D3D_GetTexturePalette;
   5.130 -    renderer->UpdateTexture = SDL_D3D_UpdateTexture;
   5.131 -    renderer->LockTexture = SDL_D3D_LockTexture;
   5.132 -    renderer->UnlockTexture = SDL_D3D_UnlockTexture;
   5.133 -    renderer->DirtyTexture = SDL_D3D_DirtyTexture;
   5.134 -    renderer->RenderFill = SDL_D3D_RenderFill;
   5.135 -    renderer->RenderCopy = SDL_D3D_RenderCopy;
   5.136 -    renderer->RenderPresent = SDL_D3D_RenderPresent;
   5.137 -    renderer->DestroyTexture = SDL_D3D_DestroyTexture;
   5.138 -    renderer->DestroyRenderer = SDL_D3D_DestroyRenderer;
   5.139 -    renderer->info = SDL_D3D_RenderDriver.info;
   5.140 +    renderer->CreateTexture = D3D_CreateTexture;
   5.141 +    renderer->SetTexturePalette = D3D_SetTexturePalette;
   5.142 +    renderer->GetTexturePalette = D3D_GetTexturePalette;
   5.143 +    renderer->UpdateTexture = D3D_UpdateTexture;
   5.144 +    renderer->LockTexture = D3D_LockTexture;
   5.145 +    renderer->UnlockTexture = D3D_UnlockTexture;
   5.146 +    renderer->DirtyTexture = D3D_DirtyTexture;
   5.147 +    renderer->RenderFill = D3D_RenderFill;
   5.148 +    renderer->RenderCopy = D3D_RenderCopy;
   5.149 +    renderer->RenderPresent = D3D_RenderPresent;
   5.150 +    renderer->DestroyTexture = D3D_DestroyTexture;
   5.151 +    renderer->DestroyRenderer = D3D_DestroyRenderer;
   5.152 +    renderer->info = D3D_RenderDriver.info;
   5.153      renderer->window = window->id;
   5.154      renderer->driverdata = data;
   5.155  
   5.156 @@ -316,7 +310,7 @@
   5.157                                       D3DCREATE_SOFTWARE_VERTEXPROCESSING,
   5.158                                       &pparams, &data->device);
   5.159      if (FAILED(result)) {
   5.160 -        SDL_D3D_DestroyRenderer(renderer);
   5.161 +        D3D_DestroyRenderer(renderer);
   5.162          D3D_SetError("CreateDevice()", result);
   5.163          return NULL;
   5.164      }
   5.165 @@ -325,14 +319,14 @@
   5.166      /* Get presentation parameters to fill info */
   5.167      result = IDirect3DDevice9_GetSwapChain(data->device, 0, &chain);
   5.168      if (FAILED(result)) {
   5.169 -        SDL_D3D_DestroyRenderer(renderer);
   5.170 +        D3D_DestroyRenderer(renderer);
   5.171          D3D_SetError("GetSwapChain()", result);
   5.172          return NULL;
   5.173      }
   5.174      result = IDirect3DSwapChain9_GetPresentParameters(chain, &pparams);
   5.175      if (FAILED(result)) {
   5.176          IDirect3DSwapChain9_Release(chain);
   5.177 -        SDL_D3D_DestroyRenderer(renderer);
   5.178 +        D3D_DestroyRenderer(renderer);
   5.179          D3D_SetError("GetPresentParameters()", result);
   5.180          return NULL;
   5.181      }
   5.182 @@ -376,17 +370,16 @@
   5.183  }
   5.184  
   5.185  static int
   5.186 -SDL_D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   5.187 +D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   5.188  {
   5.189 -    SDL_D3D_RenderData *renderdata =
   5.190 -        (SDL_D3D_RenderData *) renderer->driverdata;
   5.191 +    D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata;
   5.192      SDL_Window *window = SDL_GetWindowFromID(renderer->window);
   5.193      SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
   5.194 -    SDL_D3D_TextureData *data;
   5.195 +    D3D_TextureData *data;
   5.196      D3DPOOL pool;
   5.197      HRESULT result;
   5.198  
   5.199 -    data = (SDL_D3D_TextureData *) SDL_malloc(sizeof(*data));
   5.200 +    data = (D3D_TextureData *) SDL_malloc(sizeof(*data));
   5.201      if (!data) {
   5.202          SDL_OutOfMemory();
   5.203          return -1;
   5.204 @@ -415,33 +408,30 @@
   5.205  }
   5.206  
   5.207  static int
   5.208 -SDL_D3D_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
   5.209 -                          const SDL_Color * colors, int firstcolor,
   5.210 -                          int ncolors)
   5.211 +D3D_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
   5.212 +                      const SDL_Color * colors, int firstcolor, int ncolors)
   5.213  {
   5.214 -    SDL_D3D_RenderData *renderdata =
   5.215 -        (SDL_D3D_RenderData *) renderer->driverdata;
   5.216 -    SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->driverdata;
   5.217 +    D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata;
   5.218 +    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
   5.219  
   5.220      return 0;
   5.221  }
   5.222  
   5.223  static int
   5.224 -SDL_D3D_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
   5.225 -                          SDL_Color * colors, int firstcolor, int ncolors)
   5.226 +D3D_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
   5.227 +                      SDL_Color * colors, int firstcolor, int ncolors)
   5.228  {
   5.229 -    SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->driverdata;
   5.230 +    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
   5.231  
   5.232      return 0;
   5.233  }
   5.234  
   5.235  static int
   5.236 -SDL_D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   5.237 -                      const SDL_Rect * rect, const void *pixels, int pitch)
   5.238 +D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   5.239 +                  const SDL_Rect * rect, const void *pixels, int pitch)
   5.240  {
   5.241 -    SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->driverdata;
   5.242 -    SDL_D3D_RenderData *renderdata =
   5.243 -        (SDL_D3D_RenderData *) renderer->driverdata;
   5.244 +    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
   5.245 +    D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata;
   5.246      IDirect3DTexture9 *temp;
   5.247      RECT d3drect;
   5.248      D3DLOCKED_RECT locked;
   5.249 @@ -496,11 +486,11 @@
   5.250  }
   5.251  
   5.252  static int
   5.253 -SDL_D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   5.254 -                    const SDL_Rect * rect, int markDirty, void **pixels,
   5.255 -                    int *pitch)
   5.256 +D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   5.257 +                const SDL_Rect * rect, int markDirty, void **pixels,
   5.258 +                int *pitch)
   5.259  {
   5.260 -    SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->driverdata;
   5.261 +    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
   5.262      RECT d3drect;
   5.263      D3DLOCKED_RECT locked;
   5.264      HRESULT result;
   5.265 @@ -528,18 +518,18 @@
   5.266  }
   5.267  
   5.268  static void
   5.269 -SDL_D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   5.270 +D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   5.271  {
   5.272 -    SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->driverdata;
   5.273 +    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
   5.274  
   5.275      IDirect3DTexture9_UnlockRect(data->texture, 0);
   5.276  }
   5.277  
   5.278  static void
   5.279 -SDL_D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   5.280 -                     int numrects, const SDL_Rect * rects)
   5.281 +D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, int numrects,
   5.282 +                 const SDL_Rect * rects)
   5.283  {
   5.284 -    SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->driverdata;
   5.285 +    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
   5.286      RECT d3drect;
   5.287      int i;
   5.288  
   5.289 @@ -556,10 +546,9 @@
   5.290  }
   5.291  
   5.292  static int
   5.293 -SDL_D3D_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
   5.294 -                   Uint32 color)
   5.295 +D3D_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect, Uint32 color)
   5.296  {
   5.297 -    SDL_D3D_RenderData *data = (SDL_D3D_RenderData *) renderer->driverdata;
   5.298 +    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
   5.299      D3DRECT d3drect;
   5.300      HRESULT result;
   5.301  
   5.302 @@ -584,13 +573,12 @@
   5.303  }
   5.304  
   5.305  static int
   5.306 -SDL_D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
   5.307 -                   const SDL_Rect * srcrect, const SDL_Rect * dstrect,
   5.308 -                   int blendMode, int scaleMode)
   5.309 +D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
   5.310 +               const SDL_Rect * srcrect, const SDL_Rect * dstrect,
   5.311 +               int blendMode, int scaleMode)
   5.312  {
   5.313 -    SDL_D3D_RenderData *data = (SDL_D3D_RenderData *) renderer->driverdata;
   5.314 -    SDL_D3D_TextureData *texturedata =
   5.315 -        (SDL_D3D_TextureData *) texture->driverdata;
   5.316 +    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
   5.317 +    D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata;
   5.318      float minx, miny, maxx, maxy;
   5.319      float minu, maxu, minv, maxv;
   5.320      Vertex vertices[4];
   5.321 @@ -658,9 +646,9 @@
   5.322  }
   5.323  
   5.324  static void
   5.325 -SDL_D3D_RenderPresent(SDL_Renderer * renderer)
   5.326 +D3D_RenderPresent(SDL_Renderer * renderer)
   5.327  {
   5.328 -    SDL_D3D_RenderData *data = (SDL_D3D_RenderData *) renderer->driverdata;
   5.329 +    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
   5.330      HRESULT result;
   5.331  
   5.332      if (!data->beginScene) {
   5.333 @@ -675,9 +663,9 @@
   5.334  }
   5.335  
   5.336  static void
   5.337 -SDL_D3D_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   5.338 +D3D_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   5.339  {
   5.340 -    SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->driverdata;
   5.341 +    D3D_TextureData *data = (D3D_TextureData *) texture->driverdata;
   5.342  
   5.343      if (!data) {
   5.344          return;
   5.345 @@ -690,9 +678,9 @@
   5.346  }
   5.347  
   5.348  void
   5.349 -SDL_D3D_DestroyRenderer(SDL_Renderer * renderer)
   5.350 +D3D_DestroyRenderer(SDL_Renderer * renderer)
   5.351  {
   5.352 -    SDL_D3D_RenderData *data = (SDL_D3D_RenderData *) renderer->driverdata;
   5.353 +    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
   5.354  
   5.355      if (data) {
   5.356          if (data->device) {
     6.1 --- a/src/video/win32/SDL_gdirender.c	Sun Jul 16 09:34:01 2006 +0000
     6.2 +++ b/src/video/win32/SDL_gdirender.c	Mon Jul 17 06:47:33 2006 +0000
     6.3 @@ -29,46 +29,40 @@
     6.4  
     6.5  /* GDI renderer implementation */
     6.6  
     6.7 -static SDL_Renderer *SDL_GDI_CreateRenderer(SDL_Window * window,
     6.8 -                                            Uint32 flags);
     6.9 -static int SDL_GDI_CreateTexture(SDL_Renderer * renderer,
    6.10 -                                 SDL_Texture * texture);
    6.11 -static int SDL_GDI_QueryTexturePixels(SDL_Renderer * renderer,
    6.12 -                                      SDL_Texture * texture, void **pixels,
    6.13 -                                      int *pitch);
    6.14 -static int SDL_GDI_SetTexturePalette(SDL_Renderer * renderer,
    6.15 -                                     SDL_Texture * texture,
    6.16 -                                     const SDL_Color * colors, int firstcolor,
    6.17 -                                     int ncolors);
    6.18 -static int SDL_GDI_GetTexturePalette(SDL_Renderer * renderer,
    6.19 -                                     SDL_Texture * texture,
    6.20 -                                     SDL_Color * colors, int firstcolor,
    6.21 -                                     int ncolors);
    6.22 -static int SDL_GDI_UpdateTexture(SDL_Renderer * renderer,
    6.23 -                                 SDL_Texture * texture, const SDL_Rect * rect,
    6.24 -                                 const void *pixels, int pitch);
    6.25 -static int SDL_GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    6.26 -                               const SDL_Rect * rect, int markDirty,
    6.27 -                               void **pixels, int *pitch);
    6.28 -static void SDL_GDI_UnlockTexture(SDL_Renderer * renderer,
    6.29 -                                  SDL_Texture * texture);
    6.30 -static void SDL_GDI_DirtyTexture(SDL_Renderer * renderer,
    6.31 -                                 SDL_Texture * texture, int numrects,
    6.32 -                                 const SDL_Rect * rects);
    6.33 -static int SDL_GDI_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
    6.34 -                              Uint32 color);
    6.35 -static int SDL_GDI_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
    6.36 -                              const SDL_Rect * srcrect,
    6.37 -                              const SDL_Rect * dstrect, int blendMode,
    6.38 -                              int scaleMode);
    6.39 -static void SDL_GDI_RenderPresent(SDL_Renderer * renderer);
    6.40 -static void SDL_GDI_DestroyTexture(SDL_Renderer * renderer,
    6.41 -                                   SDL_Texture * texture);
    6.42 -static void SDL_GDI_DestroyRenderer(SDL_Renderer * renderer);
    6.43 +static SDL_Renderer *GDI_CreateRenderer(SDL_Window * window, Uint32 flags);
    6.44 +static int GDI_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
    6.45 +static int GDI_QueryTexturePixels(SDL_Renderer * renderer,
    6.46 +                                  SDL_Texture * texture, void **pixels,
    6.47 +                                  int *pitch);
    6.48 +static int GDI_SetTexturePalette(SDL_Renderer * renderer,
    6.49 +                                 SDL_Texture * texture,
    6.50 +                                 const SDL_Color * colors, int firstcolor,
    6.51 +                                 int ncolors);
    6.52 +static int GDI_GetTexturePalette(SDL_Renderer * renderer,
    6.53 +                                 SDL_Texture * texture, SDL_Color * colors,
    6.54 +                                 int firstcolor, int ncolors);
    6.55 +static int GDI_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    6.56 +                             const SDL_Rect * rect, const void *pixels,
    6.57 +                             int pitch);
    6.58 +static int GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    6.59 +                           const SDL_Rect * rect, int markDirty,
    6.60 +                           void **pixels, int *pitch);
    6.61 +static void GDI_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
    6.62 +static void GDI_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    6.63 +                             int numrects, const SDL_Rect * rects);
    6.64 +static int GDI_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
    6.65 +                          Uint32 color);
    6.66 +static int GDI_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
    6.67 +                          const SDL_Rect * srcrect, const SDL_Rect * dstrect,
    6.68 +                          int blendMode, int scaleMode);
    6.69 +static void GDI_RenderPresent(SDL_Renderer * renderer);
    6.70 +static void GDI_DestroyTexture(SDL_Renderer * renderer,
    6.71 +                               SDL_Texture * texture);
    6.72 +static void GDI_DestroyRenderer(SDL_Renderer * renderer);
    6.73  
    6.74  
    6.75 -SDL_RenderDriver SDL_GDI_RenderDriver = {
    6.76 -    SDL_GDI_CreateRenderer,
    6.77 +SDL_RenderDriver GDI_RenderDriver = {
    6.78 +    GDI_CreateRenderer,
    6.79      {
    6.80       "gdi",
    6.81       (SDL_Renderer_SingleBuffer | SDL_Renderer_PresentCopy |
    6.82 @@ -106,7 +100,7 @@
    6.83      int current_hbm;
    6.84      SDL_DirtyRectList dirty;
    6.85      SDL_bool makedirty;
    6.86 -} SDL_GDI_RenderData;
    6.87 +} GDI_RenderData;
    6.88  
    6.89  typedef struct
    6.90  {
    6.91 @@ -116,12 +110,12 @@
    6.92      HBITMAP hbm;
    6.93      void *pixels;
    6.94      int pitch;
    6.95 -} SDL_GDI_TextureData;
    6.96 +} GDI_TextureData;
    6.97  
    6.98  static void
    6.99  UpdateYUVTextureData(SDL_Texture * texture)
   6.100  {
   6.101 -    SDL_GDI_TextureData *data = (SDL_GDI_TextureData *) texture->driverdata;
   6.102 +    GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
   6.103      SDL_Rect rect;
   6.104  
   6.105      rect.x = 0;
   6.106 @@ -135,15 +129,15 @@
   6.107  void
   6.108  GDI_AddRenderDriver(_THIS)
   6.109  {
   6.110 -    SDL_AddRenderDriver(0, &SDL_GDI_RenderDriver);
   6.111 +    SDL_AddRenderDriver(0, &GDI_RenderDriver);
   6.112  }
   6.113  
   6.114  SDL_Renderer *
   6.115 -SDL_GDI_CreateRenderer(SDL_Window * window, Uint32 flags)
   6.116 +GDI_CreateRenderer(SDL_Window * window, Uint32 flags)
   6.117  {
   6.118      SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
   6.119      SDL_Renderer *renderer;
   6.120 -    SDL_GDI_RenderData *data;
   6.121 +    GDI_RenderData *data;
   6.122      int bmi_size;
   6.123      HBITMAP hbm;
   6.124      int i, n;
   6.125 @@ -155,35 +149,35 @@
   6.126      }
   6.127      SDL_zerop(renderer);
   6.128  
   6.129 -    data = (SDL_GDI_RenderData *) SDL_malloc(sizeof(*data));
   6.130 +    data = (GDI_RenderData *) SDL_malloc(sizeof(*data));
   6.131      if (!data) {
   6.132 -        SDL_GDI_DestroyRenderer(renderer);
   6.133 +        GDI_DestroyRenderer(renderer);
   6.134          SDL_OutOfMemory();
   6.135          return NULL;
   6.136      }
   6.137      SDL_zerop(data);
   6.138  
   6.139 -    renderer->CreateTexture = SDL_GDI_CreateTexture;
   6.140 -    renderer->QueryTexturePixels = SDL_GDI_QueryTexturePixels;
   6.141 -    renderer->SetTexturePalette = SDL_GDI_SetTexturePalette;
   6.142 -    renderer->GetTexturePalette = SDL_GDI_GetTexturePalette;
   6.143 -    renderer->UpdateTexture = SDL_GDI_UpdateTexture;
   6.144 -    renderer->LockTexture = SDL_GDI_LockTexture;
   6.145 -    renderer->UnlockTexture = SDL_GDI_UnlockTexture;
   6.146 -    renderer->DirtyTexture = SDL_GDI_DirtyTexture;
   6.147 -    renderer->RenderFill = SDL_GDI_RenderFill;
   6.148 -    renderer->RenderCopy = SDL_GDI_RenderCopy;
   6.149 -    renderer->RenderPresent = SDL_GDI_RenderPresent;
   6.150 -    renderer->DestroyTexture = SDL_GDI_DestroyTexture;
   6.151 -    renderer->DestroyRenderer = SDL_GDI_DestroyRenderer;
   6.152 -    renderer->info = SDL_GDI_RenderDriver.info;
   6.153 +    renderer->CreateTexture = GDI_CreateTexture;
   6.154 +    renderer->QueryTexturePixels = GDI_QueryTexturePixels;
   6.155 +    renderer->SetTexturePalette = GDI_SetTexturePalette;
   6.156 +    renderer->GetTexturePalette = GDI_GetTexturePalette;
   6.157 +    renderer->UpdateTexture = GDI_UpdateTexture;
   6.158 +    renderer->LockTexture = GDI_LockTexture;
   6.159 +    renderer->UnlockTexture = GDI_UnlockTexture;
   6.160 +    renderer->DirtyTexture = GDI_DirtyTexture;
   6.161 +    renderer->RenderFill = GDI_RenderFill;
   6.162 +    renderer->RenderCopy = GDI_RenderCopy;
   6.163 +    renderer->RenderPresent = GDI_RenderPresent;
   6.164 +    renderer->DestroyTexture = GDI_DestroyTexture;
   6.165 +    renderer->DestroyRenderer = GDI_DestroyRenderer;
   6.166 +    renderer->info = GDI_RenderDriver.info;
   6.167      renderer->window = window->id;
   6.168      renderer->driverdata = data;
   6.169  
   6.170      renderer->info.flags = SDL_Renderer_Accelerated;
   6.171  
   6.172      data->hwnd = windowdata->hwnd;
   6.173 -    data->window_hdc = GetDC(data->hwnd);
   6.174 +    data->window_hdc = windowdata->hdc;
   6.175      data->render_hdc = CreateCompatibleDC(data->window_hdc);
   6.176      data->memory_hdc = CreateCompatibleDC(data->window_hdc);
   6.177  
   6.178 @@ -191,7 +185,7 @@
   6.179      bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD);
   6.180      data->bmi = (LPBITMAPINFO) SDL_malloc(bmi_size);
   6.181      if (!data->bmi) {
   6.182 -        SDL_GDI_DestroyRenderer(renderer);
   6.183 +        GDI_DestroyRenderer(renderer);
   6.184          SDL_OutOfMemory();
   6.185          return NULL;
   6.186      }
   6.187 @@ -221,7 +215,7 @@
   6.188          data->hbm[i] =
   6.189              CreateCompatibleBitmap(data->window_hdc, window->w, window->h);
   6.190          if (!data->hbm[i]) {
   6.191 -            SDL_GDI_DestroyRenderer(renderer);
   6.192 +            GDI_DestroyRenderer(renderer);
   6.193              WIN_SetError("CreateCompatibleBitmap()");
   6.194              return NULL;
   6.195          }
   6.196 @@ -240,15 +234,14 @@
   6.197  }
   6.198  
   6.199  static int
   6.200 -SDL_GDI_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   6.201 +GDI_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   6.202  {
   6.203 -    SDL_GDI_RenderData *renderdata =
   6.204 -        (SDL_GDI_RenderData *) renderer->driverdata;
   6.205 +    GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata;
   6.206      SDL_Window *window = SDL_GetWindowFromID(renderer->window);
   6.207      SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
   6.208 -    SDL_GDI_TextureData *data;
   6.209 +    GDI_TextureData *data;
   6.210  
   6.211 -    data = (SDL_GDI_TextureData *) SDL_malloc(sizeof(*data));
   6.212 +    data = (GDI_TextureData *) SDL_malloc(sizeof(*data));
   6.213      if (!data) {
   6.214          SDL_OutOfMemory();
   6.215          return -1;
   6.216 @@ -260,7 +253,7 @@
   6.217      if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
   6.218          data->yuv = SDL_SW_CreateYUVTexture(texture);
   6.219          if (!data->yuv) {
   6.220 -            SDL_GDI_DestroyTexture(renderer, texture);
   6.221 +            GDI_DestroyTexture(renderer, texture);
   6.222              return -1;
   6.223          }
   6.224          data->format = display->current_mode.format;
   6.225 @@ -277,7 +270,7 @@
   6.226          bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD);
   6.227          bmi = (LPBITMAPINFO) SDL_malloc(bmi_size);
   6.228          if (!bmi) {
   6.229 -            SDL_GDI_DestroyTexture(renderer, texture);
   6.230 +            GDI_DestroyTexture(renderer, texture);
   6.231              SDL_OutOfMemory();
   6.232              return -1;
   6.233          }
   6.234 @@ -303,7 +296,7 @@
   6.235                                            ncolors * sizeof(PALETTEENTRY));
   6.236              if (!palette) {
   6.237                  SDL_free(bmi);
   6.238 -                SDL_GDI_DestroyTexture(renderer, texture);
   6.239 +                GDI_DestroyTexture(renderer, texture);
   6.240                  SDL_OutOfMemory();
   6.241                  return -1;
   6.242              }
   6.243 @@ -339,7 +332,7 @@
   6.244          data->pixels = NULL;
   6.245      }
   6.246      if (!data->hbm) {
   6.247 -        SDL_GDI_DestroyTexture(renderer, texture);
   6.248 +        GDI_DestroyTexture(renderer, texture);
   6.249          WIN_SetError("Couldn't create bitmap");
   6.250          return -1;
   6.251      }
   6.252 @@ -347,10 +340,10 @@
   6.253  }
   6.254  
   6.255  static int
   6.256 -SDL_GDI_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
   6.257 -                           void **pixels, int *pitch)
   6.258 +GDI_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
   6.259 +                       void **pixels, int *pitch)
   6.260  {
   6.261 -    SDL_GDI_TextureData *data = (SDL_GDI_TextureData *) texture->driverdata;
   6.262 +    GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
   6.263  
   6.264      if (data->yuv) {
   6.265          return SDL_SW_QueryYUVTexturePixels(data->yuv, pixels, pitch);
   6.266 @@ -362,13 +355,11 @@
   6.267  }
   6.268  
   6.269  static int
   6.270 -SDL_GDI_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
   6.271 -                          const SDL_Color * colors, int firstcolor,
   6.272 -                          int ncolors)
   6.273 +GDI_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
   6.274 +                      const SDL_Color * colors, int firstcolor, int ncolors)
   6.275  {
   6.276 -    SDL_GDI_RenderData *renderdata =
   6.277 -        (SDL_GDI_RenderData *) renderer->driverdata;
   6.278 -    SDL_GDI_TextureData *data = (SDL_GDI_TextureData *) texture->driverdata;
   6.279 +    GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata;
   6.280 +    GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
   6.281  
   6.282      if (data->yuv) {
   6.283          SDL_SetError("YUV textures don't have a palette");
   6.284 @@ -392,10 +383,10 @@
   6.285  }
   6.286  
   6.287  static int
   6.288 -SDL_GDI_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
   6.289 -                          SDL_Color * colors, int firstcolor, int ncolors)
   6.290 +GDI_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
   6.291 +                      SDL_Color * colors, int firstcolor, int ncolors)
   6.292  {
   6.293 -    SDL_GDI_TextureData *data = (SDL_GDI_TextureData *) texture->driverdata;
   6.294 +    GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
   6.295  
   6.296      if (data->yuv) {
   6.297          SDL_SetError("YUV textures don't have a palette");
   6.298 @@ -418,10 +409,10 @@
   6.299  }
   6.300  
   6.301  static int
   6.302 -SDL_GDI_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   6.303 -                      const SDL_Rect * rect, const void *pixels, int pitch)
   6.304 +GDI_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   6.305 +                  const SDL_Rect * rect, const void *pixels, int pitch)
   6.306  {
   6.307 -    SDL_GDI_TextureData *data = (SDL_GDI_TextureData *) texture->driverdata;
   6.308 +    GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
   6.309  
   6.310      if (data->yuv) {
   6.311          if (SDL_SW_UpdateYUVTexture(data->yuv, rect, pixels, pitch) < 0) {
   6.312 @@ -430,8 +421,7 @@
   6.313          UpdateYUVTextureData(texture);
   6.314          return 0;
   6.315      } else {
   6.316 -        SDL_GDI_RenderData *renderdata =
   6.317 -            (SDL_GDI_RenderData *) renderer->driverdata;
   6.318 +        GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata;
   6.319  
   6.320          if (data->pixels) {
   6.321              Uint8 *src, *dst;
   6.322 @@ -465,11 +455,11 @@
   6.323  }
   6.324  
   6.325  static int
   6.326 -SDL_GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   6.327 -                    const SDL_Rect * rect, int markDirty, void **pixels,
   6.328 -                    int *pitch)
   6.329 +GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   6.330 +                const SDL_Rect * rect, int markDirty, void **pixels,
   6.331 +                int *pitch)
   6.332  {
   6.333 -    SDL_GDI_TextureData *data = (SDL_GDI_TextureData *) texture->driverdata;
   6.334 +    GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
   6.335  
   6.336      if (data->yuv) {
   6.337          return SDL_SW_LockYUVTexture(data->yuv, rect, markDirty, pixels,
   6.338 @@ -488,9 +478,9 @@
   6.339  }
   6.340  
   6.341  static void
   6.342 -SDL_GDI_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   6.343 +GDI_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   6.344  {
   6.345 -    SDL_GDI_TextureData *data = (SDL_GDI_TextureData *) texture->driverdata;
   6.346 +    GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
   6.347  
   6.348      if (data->yuv) {
   6.349          SDL_SW_UnlockYUVTexture(data->yuv);
   6.350 @@ -499,16 +489,15 @@
   6.351  }
   6.352  
   6.353  static void
   6.354 -SDL_GDI_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   6.355 -                     int numrects, const SDL_Rect * rects)
   6.356 +GDI_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, int numrects,
   6.357 +                 const SDL_Rect * rects)
   6.358  {
   6.359  }
   6.360  
   6.361  static int
   6.362 -SDL_GDI_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
   6.363 -                   Uint32 color)
   6.364 +GDI_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect, Uint32 color)
   6.365  {
   6.366 -    SDL_GDI_RenderData *data = (SDL_GDI_RenderData *) renderer->driverdata;
   6.367 +    GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
   6.368      Uint8 r, g, b;
   6.369      RECT rc;
   6.370      HBRUSH brush;
   6.371 @@ -541,13 +530,12 @@
   6.372  }
   6.373  
   6.374  static int
   6.375 -SDL_GDI_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
   6.376 -                   const SDL_Rect * srcrect, const SDL_Rect * dstrect,
   6.377 -                   int blendMode, int scaleMode)
   6.378 +GDI_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
   6.379 +               const SDL_Rect * srcrect, const SDL_Rect * dstrect,
   6.380 +               int blendMode, int scaleMode)
   6.381  {
   6.382 -    SDL_GDI_RenderData *data = (SDL_GDI_RenderData *) renderer->driverdata;
   6.383 -    SDL_GDI_TextureData *texturedata =
   6.384 -        (SDL_GDI_TextureData *) texture->driverdata;
   6.385 +    GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
   6.386 +    GDI_TextureData *texturedata = (GDI_TextureData *) texture->driverdata;
   6.387  
   6.388      if (data->makedirty) {
   6.389          SDL_AddDirtyRect(&data->dirty, dstrect);
   6.390 @@ -596,9 +584,9 @@
   6.391  }
   6.392  
   6.393  static void
   6.394 -SDL_GDI_RenderPresent(SDL_Renderer * renderer)
   6.395 +GDI_RenderPresent(SDL_Renderer * renderer)
   6.396  {
   6.397 -    SDL_GDI_RenderData *data = (SDL_GDI_RenderData *) renderer->driverdata;
   6.398 +    GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
   6.399      SDL_DirtyRect *dirty;
   6.400  
   6.401      /* Send the data to the display */
   6.402 @@ -622,9 +610,9 @@
   6.403  }
   6.404  
   6.405  static void
   6.406 -SDL_GDI_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   6.407 +GDI_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   6.408  {
   6.409 -    SDL_GDI_TextureData *data = (SDL_GDI_TextureData *) texture->driverdata;
   6.410 +    GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
   6.411  
   6.412      if (!data) {
   6.413          return;
   6.414 @@ -643,13 +631,12 @@
   6.415  }
   6.416  
   6.417  void
   6.418 -SDL_GDI_DestroyRenderer(SDL_Renderer * renderer)
   6.419 +GDI_DestroyRenderer(SDL_Renderer * renderer)
   6.420  {
   6.421 -    SDL_GDI_RenderData *data = (SDL_GDI_RenderData *) renderer->driverdata;
   6.422 +    GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
   6.423      int i;
   6.424  
   6.425      if (data) {
   6.426 -        ReleaseDC(data->hwnd, data->window_hdc);
   6.427          DeleteDC(data->render_hdc);
   6.428          DeleteDC(data->memory_hdc);
   6.429          if (data->bmi) {
     7.1 --- a/src/video/win32/SDL_win32events.c	Sun Jul 16 09:34:01 2006 +0000
     7.2 +++ b/src/video/win32/SDL_win32events.c	Mon Jul 17 06:47:33 2006 +0000
     7.3 @@ -29,6 +29,7 @@
     7.4  
     7.5  /*#define WMMSG_DEBUG*/
     7.6  #ifdef WMMSG_DEBUG
     7.7 +#include <stdio.h>
     7.8  #include "wmmsg.h"
     7.9  #endif
    7.10  
    7.11 @@ -398,13 +399,17 @@
    7.12          return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam);
    7.13      }
    7.14  #ifdef WMMSG_DEBUG
    7.15 -    fprintf(stderr, "Received windows message:  ");
    7.16 -    if (msg > MAX_WMMSG) {
    7.17 -        fprintf(stderr, "%d", msg);
    7.18 -    } else {
    7.19 -        fprintf(stderr, "%s", wmtab[msg]);
    7.20 +    {
    7.21 +        FILE *log = fopen("wmmsg.txt", "a");
    7.22 +        fprintf(log, "Received windows message: %p ", hwnd);
    7.23 +        if (msg > MAX_WMMSG) {
    7.24 +            fprintf(log, "%d", msg);
    7.25 +        } else {
    7.26 +            fprintf(log, "%s", wmtab[msg]);
    7.27 +        }
    7.28 +        fprintf(log, " -- 0x%X, 0x%X\n", wParam, lParam);
    7.29 +        fclose(log);
    7.30      }
    7.31 -    fprintf(stderr, " -- 0x%X, 0x%X\n", wParam, lParam);
    7.32  #endif
    7.33  
    7.34      /* Send a SDL_SYSWMEVENT if the application wants them */
     8.1 --- a/src/video/win32/SDL_win32modes.c	Sun Jul 16 09:34:01 2006 +0000
     8.2 +++ b/src/video/win32/SDL_win32modes.c	Mon Jul 17 06:47:33 2006 +0000
     8.3 @@ -24,10 +24,6 @@
     8.4  #include "SDL_win32video.h"
     8.5  
     8.6  
     8.7 -/* FIXME: Each call to EnumDisplaySettings() takes about 6 ms on my laptop.
     8.8 -          With 500 or so modes, this takes almost 3 seconds to run!
     8.9 -*/
    8.10 -
    8.11  static SDL_bool
    8.12  WIN_GetDisplayMode(LPCTSTR deviceName, DWORD index, SDL_DisplayMode * mode)
    8.13  {
    8.14 @@ -58,8 +54,8 @@
    8.15      mode->refresh_rate = devmode.dmDisplayFrequency;
    8.16      mode->driverdata = data;
    8.17  
    8.18 -    hdc = CreateDC(deviceName, NULL, NULL, &devmode);
    8.19 -    if (hdc) {
    8.20 +    if (index == ENUM_CURRENT_SETTINGS
    8.21 +        && (hdc = CreateDC(deviceName, NULL, NULL, NULL)) != NULL) {
    8.22          char bmi_data[sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)];
    8.23          LPBITMAPINFO bmi;
    8.24          HBITMAP hbm;
    8.25 @@ -92,6 +88,7 @@
    8.26              mode->format = SDL_PixelFormat_Index8;
    8.27          }
    8.28      } else {
    8.29 +        /* FIXME: Can we tell what this will be? */
    8.30          switch (devmode.dmBitsPerPel) {
    8.31          case 32:
    8.32              mode->format = SDL_PixelFormat_RGB888;
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/src/video/win32/SDL_win32opengl.c	Mon Jul 17 06:47:33 2006 +0000
     9.3 @@ -0,0 +1,643 @@
     9.4 +/*
     9.5 +    SDL - Simple DirectMedia Layer
     9.6 +    Copyright (C) 1997-2006 Sam Lantinga
     9.7 +
     9.8 +    This library is free software; you can redistribute it and/or
     9.9 +    modify it under the terms of the GNU Lesser General Public
    9.10 +    License as published by the Free Software Foundation; either
    9.11 +    version 2.1 of the License, or (at your option) any later version.
    9.12 +
    9.13 +    This library is distributed in the hope that it will be useful,
    9.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    9.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    9.16 +    Lesser General Public License for more details.
    9.17 +
    9.18 +    You should have received a copy of the GNU Lesser General Public
    9.19 +    License along with this library; if not, write to the Free Software
    9.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    9.21 +
    9.22 +    Sam Lantinga
    9.23 +    slouken@libsdl.org
    9.24 +*/
    9.25 +#include "SDL_config.h"
    9.26 +
    9.27 +#include "SDL_win32video.h"
    9.28 +
    9.29 +/* WGL implementation of SDL OpenGL support */
    9.30 +
    9.31 +#if SDL_VIDEO_OPENGL
    9.32 +#include "SDL_opengl.h"
    9.33 +
    9.34 +#define DEFAULT_GL_DRIVER_PATH "OPENGL32.DLL"
    9.35 +
    9.36 +
    9.37 +int
    9.38 +WIN_GL_LoadLibrary(_THIS, const char *path)
    9.39 +{
    9.40 +    LPTSTR wpath;
    9.41 +    HANDLE handle;
    9.42 +
    9.43 +    if (_this->gl_config.driver_loaded) {
    9.44 +        if (path) {
    9.45 +            SDL_SetError("OpenGL library already loaded");
    9.46 +            return -1;
    9.47 +        } else {
    9.48 +            ++_this->gl_config.driver_loaded;
    9.49 +            return 0;
    9.50 +        }
    9.51 +    }
    9.52 +    if (path == NULL) {
    9.53 +        path = DEFAULT_GL_DRIVER_PATH;
    9.54 +    }
    9.55 +    wpath = WIN_UTF8ToString(path);
    9.56 +    handle = LoadLibrary(wpath);
    9.57 +    SDL_free(wpath);
    9.58 +    if (!handle) {
    9.59 +        char message[1024];
    9.60 +        SDL_snprintf(message, SDL_arraysize(message), "LoadLibrary(\"%s\")",
    9.61 +                     path);
    9.62 +        WIN_SetError(message);
    9.63 +        return -1;
    9.64 +    }
    9.65 +
    9.66 +    /* Load function pointers */
    9.67 +    _this->gl_data->wglGetProcAddress = (void *(WINAPI *) (const char *))
    9.68 +        GetProcAddress(handle, "wglGetProcAddress");
    9.69 +    _this->gl_data->wglCreateContext = (HGLRC(WINAPI *) (HDC))
    9.70 +        GetProcAddress(handle, "wglCreateContext");
    9.71 +    _this->gl_data->wglDeleteContext = (BOOL(WINAPI *) (HGLRC))
    9.72 +        GetProcAddress(handle, "wglDeleteContext");
    9.73 +    _this->gl_data->wglMakeCurrent = (BOOL(WINAPI *) (HDC, HGLRC))
    9.74 +        GetProcAddress(handle, "wglMakeCurrent");
    9.75 +    _this->gl_data->wglSwapIntervalEXT = (void (WINAPI *) (int))
    9.76 +        GetProcAddress(handle, "wglSwapIntervalEXT");
    9.77 +    _this->gl_data->wglGetSwapIntervalEXT = (int (WINAPI *) (void))
    9.78 +        GetProcAddress(handle, "wglGetSwapIntervalEXT");
    9.79 +
    9.80 +    if (!_this->gl_data->wglGetProcAddress ||
    9.81 +        !_this->gl_data->wglCreateContext ||
    9.82 +        !_this->gl_data->wglDeleteContext ||
    9.83 +        !_this->gl_data->wglMakeCurrent) {
    9.84 +        SDL_SetError("Could not retrieve OpenGL functions");
    9.85 +        FreeLibrary(handle);
    9.86 +        return -1;
    9.87 +    }
    9.88 +
    9.89 +    _this->gl_config.dll_handle = handle;
    9.90 +    SDL_strlcpy(_this->gl_config.driver_path, path,
    9.91 +                SDL_arraysize(_this->gl_config.driver_path));
    9.92 +    _this->gl_config.driver_loaded = 1;
    9.93 +    return 0;
    9.94 +}
    9.95 +
    9.96 +void *
    9.97 +WIN_GL_GetProcAddress(_THIS, const char *proc)
    9.98 +{
    9.99 +    void *func;
   9.100 +
   9.101 +    /* This is to pick up extensions */
   9.102 +    func = _this->gl_data->wglGetProcAddress(proc);
   9.103 +    if (!func) {
   9.104 +        /* This is probably a normal GL function */
   9.105 +        func = GetProcAddress(_this->gl_config.dll_handle, proc);
   9.106 +    }
   9.107 +    return func;
   9.108 +}
   9.109 +
   9.110 +static void
   9.111 +WIN_GL_UnloadLibrary(_THIS)
   9.112 +{
   9.113 +    if (_this->gl_config.driver_loaded > 0) {
   9.114 +        if (--_this->gl_config.driver_loaded > 0) {
   9.115 +            return;
   9.116 +        }
   9.117 +        FreeLibrary((HMODULE) _this->gl_config.dll_handle);
   9.118 +        _this->gl_config.dll_handle = NULL;
   9.119 +    }
   9.120 +}
   9.121 +
   9.122 +static void
   9.123 +WIN_GL_SetupPixelFormat(_THIS, PIXELFORMATDESCRIPTOR * pfd)
   9.124 +{
   9.125 +    SDL_zerop(pfd);
   9.126 +    pfd->nSize = sizeof(*pfd);
   9.127 +    pfd->nVersion = 1;
   9.128 +    pfd->dwFlags = (PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL);
   9.129 +    if (_this->gl_config.double_buffer) {
   9.130 +        pfd->dwFlags |= PFD_DOUBLEBUFFER;
   9.131 +    }
   9.132 +    if (_this->gl_config.stereo) {
   9.133 +        pfd->dwFlags |= PFD_STEREO;
   9.134 +    }
   9.135 +    pfd->iLayerType = PFD_MAIN_PLANE;
   9.136 +    pfd->iPixelType = PFD_TYPE_RGBA;
   9.137 +    pfd->cRedBits = _this->gl_config.red_size;
   9.138 +    pfd->cGreenBits = _this->gl_config.green_size;
   9.139 +    pfd->cBlueBits = _this->gl_config.blue_size;
   9.140 +    pfd->cAlphaBits = _this->gl_config.alpha_size;
   9.141 +    if (_this->gl_config.buffer_size) {
   9.142 +        pfd->cColorBits =
   9.143 +            _this->gl_config.buffer_size - _this->gl_config.alpha_size;
   9.144 +    } else {
   9.145 +        pfd->cColorBits = (pfd->cRedBits + pfd->cGreenBits + pfd->cBlueBits);
   9.146 +    }
   9.147 +    pfd->cAccumRedBits = _this->gl_config.accum_red_size;
   9.148 +    pfd->cAccumGreenBits = _this->gl_config.accum_green_size;
   9.149 +    pfd->cAccumBlueBits = _this->gl_config.accum_blue_size;
   9.150 +    pfd->cAccumAlphaBits = _this->gl_config.accum_alpha_size;
   9.151 +    pfd->cAccumBits =
   9.152 +        (pfd->cAccumRedBits + pfd->cAccumGreenBits + pfd->cAccumBlueBits +
   9.153 +         pfd->cAccumAlphaBits);
   9.154 +    pfd->cDepthBits = _this->gl_config.depth_size;
   9.155 +    pfd->cStencilBits = _this->gl_config.stencil_size;
   9.156 +}
   9.157 +
   9.158 +static SDL_bool
   9.159 +HasExtension(const char *extension, const char *extensions)
   9.160 +{
   9.161 +    const char *start;
   9.162 +    const char *where, *terminator;
   9.163 +
   9.164 +    /* Extension names should not have spaces. */
   9.165 +    where = SDL_strchr(extension, ' ');
   9.166 +    if (where || *extension == '\0')
   9.167 +        return SDL_FALSE;
   9.168 +
   9.169 +    if (!extensions)
   9.170 +        return SDL_FALSE;
   9.171 +
   9.172 +    /* It takes a bit of care to be fool-proof about parsing the
   9.173 +     * OpenGL extensions string. Don't be fooled by sub-strings,
   9.174 +     * etc. */
   9.175 +
   9.176 +    start = extensions;
   9.177 +
   9.178 +    for (;;) {
   9.179 +        where = SDL_strstr(start, extension);
   9.180 +        if (!where)
   9.181 +            break;
   9.182 +
   9.183 +        terminator = where + SDL_strlen(extension);
   9.184 +        if (where == start || *(where - 1) == ' ')
   9.185 +            if (*terminator == ' ' || *terminator == '\0')
   9.186 +                return SDL_TRUE;
   9.187 +
   9.188 +        start = terminator;
   9.189 +    }
   9.190 +    return SDL_FALSE;
   9.191 +}
   9.192 +
   9.193 +static void
   9.194 +WIN_GL_InitExtensions(_THIS)
   9.195 +{
   9.196 +    HWND hwnd;
   9.197 +    HDC hdc;
   9.198 +    PIXELFORMATDESCRIPTOR pfd;
   9.199 +    int pixel_format;
   9.200 +    HGLRC hglrc;
   9.201 +    const char *(WINAPI * wglGetExtensionsStringARB) (HDC) = 0;
   9.202 +    const GLubyte *(WINAPI * glGetStringFunc) (GLenum);
   9.203 +    const char *extensions;
   9.204 +
   9.205 +    hwnd =
   9.206 +        CreateWindow(SDL_Appname, SDL_Appname, (WS_POPUP | WS_DISABLED), 0, 0,
   9.207 +                     10, 10, NULL, NULL, SDL_Instance, NULL);
   9.208 +    WIN_PumpEvents(_this);
   9.209 +
   9.210 +    hdc = GetDC(hwnd);
   9.211 +
   9.212 +    WIN_GL_SetupPixelFormat(_this, &pfd);
   9.213 +    pixel_format = ChoosePixelFormat(hdc, &pfd);
   9.214 +    SetPixelFormat(hdc, pixel_format, &pfd);
   9.215 +
   9.216 +    hglrc = _this->gl_data->wglCreateContext(hdc);
   9.217 +    if (hglrc) {
   9.218 +        _this->gl_data->wglMakeCurrent(hdc, hglrc);
   9.219 +    }
   9.220 +
   9.221 +    wglGetExtensionsStringARB = (const char *(WINAPI *) (HDC))
   9.222 +        _this->gl_data->wglGetProcAddress("wglGetExtensionsStringARB");
   9.223 +    if (wglGetExtensionsStringARB) {
   9.224 +        extensions = wglGetExtensionsStringARB(hdc);
   9.225 +    } else {
   9.226 +        extensions = NULL;
   9.227 +    }
   9.228 +
   9.229 +    /* Check for WGL_ARB_pixel_format */
   9.230 +    _this->gl_data->WGL_ARB_pixel_format = 0;
   9.231 +    if (HasExtension("WGL_ARB_pixel_format", extensions)) {
   9.232 +        _this->gl_data->wglChoosePixelFormatARB = (BOOL(WINAPI *)
   9.233 +                                                   (HDC, const int *,
   9.234 +                                                    const FLOAT *, UINT,
   9.235 +                                                    int *, UINT *))
   9.236 +            WIN_GL_GetProcAddress(_this, "wglChoosePixelFormatARB");
   9.237 +        _this->gl_data->wglGetPixelFormatAttribivARB =
   9.238 +            (BOOL(WINAPI *) (HDC, int, int, UINT, const int *, int *))
   9.239 +            WIN_GL_GetProcAddress(_this, "wglGetPixelFormatAttribivARB");
   9.240 +
   9.241 +        if ((_this->gl_data->wglChoosePixelFormatARB != NULL) &&
   9.242 +            (_this->gl_data->wglGetPixelFormatAttribivARB != NULL)) {
   9.243 +            _this->gl_data->WGL_ARB_pixel_format = 1;
   9.244 +        }
   9.245 +    }
   9.246 +
   9.247 +    glGetStringFunc = WIN_GL_GetProcAddress(_this, "glGetString");
   9.248 +    if (glGetStringFunc) {
   9.249 +        extensions = (const char *) glGetStringFunc(GL_EXTENSIONS);
   9.250 +    } else {
   9.251 +        /* Uh oh, something is seriously wrong here... */
   9.252 +        extensions = NULL;
   9.253 +    }
   9.254 +
   9.255 +    /* Check for WGL_EXT_swap_control */
   9.256 +    if (HasExtension("WGL_EXT_swap_control", extensions)) {
   9.257 +        _this->gl_data->wglSwapIntervalEXT =
   9.258 +            WIN_GL_GetProcAddress(_this, "wglSwapIntervalEXT");
   9.259 +        _this->gl_data->wglGetSwapIntervalEXT =
   9.260 +            WIN_GL_GetProcAddress(_this, "wglGetSwapIntervalEXT");
   9.261 +    }
   9.262 +
   9.263 +    if (hglrc) {
   9.264 +        _this->gl_data->wglMakeCurrent(NULL, NULL);
   9.265 +        _this->gl_data->wglDeleteContext(hglrc);
   9.266 +    }
   9.267 +    ReleaseDC(hwnd, hdc);
   9.268 +    DestroyWindow(hwnd);
   9.269 +    WIN_PumpEvents(_this);
   9.270 +}
   9.271 +
   9.272 +static void
   9.273 +WIN_GL_Shutdown(_THIS)
   9.274 +{
   9.275 +    if (!_this->gl_data || (--_this->gl_data->initialized > 0)) {
   9.276 +        return;
   9.277 +    }
   9.278 +
   9.279 +    WIN_GL_UnloadLibrary(_this);
   9.280 +
   9.281 +    SDL_free(_this->gl_data);
   9.282 +    _this->gl_data = NULL;
   9.283 +}
   9.284 +
   9.285 +static int
   9.286 +WIN_GL_Initialize(_THIS)
   9.287 +{
   9.288 +    if (_this->gl_data) {
   9.289 +        ++_this->gl_data->initialized;
   9.290 +        return 0;
   9.291 +    }
   9.292 +
   9.293 +    _this->gl_data =
   9.294 +        (struct SDL_GLDriverData *) SDL_calloc(1,
   9.295 +                                               sizeof(struct
   9.296 +                                                      SDL_GLDriverData));
   9.297 +    if (!_this->gl_data) {
   9.298 +        SDL_OutOfMemory();
   9.299 +        return -1;
   9.300 +    }
   9.301 +    _this->gl_data->initialized = 1;
   9.302 +
   9.303 +    if (WIN_GL_LoadLibrary(_this, NULL) < 0) {
   9.304 +        return -1;
   9.305 +    }
   9.306 +
   9.307 +    /* Initialize extensions */
   9.308 +    WIN_GL_InitExtensions(_this);
   9.309 +
   9.310 +    return 0;
   9.311 +}
   9.312 +
   9.313 +int
   9.314 +WIN_GL_SetupWindow(_THIS, SDL_Window * window)
   9.315 +{
   9.316 +    HDC hdc = ((SDL_WindowData *) window->driverdata)->hdc;
   9.317 +    PIXELFORMATDESCRIPTOR pfd;
   9.318 +    int pixel_format;
   9.319 +    unsigned int matching;
   9.320 +    int iAttribs[64];
   9.321 +    int *iAttr;
   9.322 +    float fAttribs[1] = { 0 };
   9.323 +
   9.324 +    if (WIN_GL_Initialize(_this) < 0) {
   9.325 +        return -1;
   9.326 +    }
   9.327 +
   9.328 +    WIN_GL_SetupPixelFormat(_this, &pfd);
   9.329 +
   9.330 +    /* setup WGL_ARB_pixel_format attribs */
   9.331 +    iAttr = &iAttribs[0];
   9.332 +
   9.333 +    *iAttr++ = WGL_DRAW_TO_WINDOW_ARB;
   9.334 +    *iAttr++ = GL_TRUE;
   9.335 +    *iAttr++ = WGL_ACCELERATION_ARB;
   9.336 +    *iAttr++ = WGL_FULL_ACCELERATION_ARB;
   9.337 +    *iAttr++ = WGL_RED_BITS_ARB;
   9.338 +    *iAttr++ = _this->gl_config.red_size;
   9.339 +    *iAttr++ = WGL_GREEN_BITS_ARB;
   9.340 +    *iAttr++ = _this->gl_config.green_size;
   9.341 +    *iAttr++ = WGL_BLUE_BITS_ARB;
   9.342 +    *iAttr++ = _this->gl_config.blue_size;
   9.343 +
   9.344 +    if (_this->gl_config.alpha_size) {
   9.345 +        *iAttr++ = WGL_ALPHA_BITS_ARB;
   9.346 +        *iAttr++ = _this->gl_config.alpha_size;
   9.347 +    }
   9.348 +
   9.349 +    *iAttr++ = WGL_DOUBLE_BUFFER_ARB;
   9.350 +    *iAttr++ = _this->gl_config.double_buffer;
   9.351 +
   9.352 +    *iAttr++ = WGL_DEPTH_BITS_ARB;
   9.353 +    *iAttr++ = _this->gl_config.depth_size;
   9.354 +
   9.355 +    if (_this->gl_config.stencil_size) {
   9.356 +        *iAttr++ = WGL_STENCIL_BITS_ARB;
   9.357 +        *iAttr++ = _this->gl_config.stencil_size;
   9.358 +    }
   9.359 +
   9.360 +    if (_this->gl_config.accum_red_size) {
   9.361 +        *iAttr++ = WGL_ACCUM_RED_BITS_ARB;
   9.362 +        *iAttr++ = _this->gl_config.accum_red_size;
   9.363 +    }
   9.364 +
   9.365 +    if (_this->gl_config.accum_green_size) {
   9.366 +        *iAttr++ = WGL_ACCUM_GREEN_BITS_ARB;
   9.367 +        *iAttr++ = _this->gl_config.accum_green_size;
   9.368 +    }
   9.369 +
   9.370 +    if (_this->gl_config.accum_blue_size) {
   9.371 +        *iAttr++ = WGL_ACCUM_BLUE_BITS_ARB;
   9.372 +        *iAttr++ = _this->gl_config.accum_blue_size;
   9.373 +    }
   9.374 +
   9.375 +    if (_this->gl_config.accum_alpha_size) {
   9.376 +        *iAttr++ = WGL_ACCUM_ALPHA_BITS_ARB;
   9.377 +        *iAttr++ = _this->gl_config.accum_alpha_size;
   9.378 +    }
   9.379 +
   9.380 +    if (_this->gl_config.stereo) {
   9.381 +        *iAttr++ = WGL_STEREO_ARB;
   9.382 +        *iAttr++ = GL_TRUE;
   9.383 +    }
   9.384 +
   9.385 +    if (_this->gl_config.multisamplebuffers) {
   9.386 +        *iAttr++ = WGL_SAMPLE_BUFFERS_ARB;
   9.387 +        *iAttr++ = _this->gl_config.multisamplebuffers;
   9.388 +    }
   9.389 +
   9.390 +    if (_this->gl_config.multisamplesamples) {
   9.391 +        *iAttr++ = WGL_SAMPLES_ARB;
   9.392 +        *iAttr++ = _this->gl_config.multisamplesamples;
   9.393 +    }
   9.394 +
   9.395 +    if (_this->gl_config.accelerated >= 0) {
   9.396 +        *iAttr++ = WGL_ACCELERATION_ARB;
   9.397 +        *iAttr++ =
   9.398 +            (_this->gl_config.
   9.399 +             accelerated ? WGL_GENERIC_ACCELERATION_ARB :
   9.400 +             WGL_NO_ACCELERATION_ARB);
   9.401 +    }
   9.402 +
   9.403 +    *iAttr = 0;
   9.404 +
   9.405 +    /* Choose and set the closest available pixel format */
   9.406 +    if (!_this->gl_data->WGL_ARB_pixel_format
   9.407 +        || !_this->gl_data->wglChoosePixelFormatARB(hdc, iAttribs, fAttribs,
   9.408 +                                                    1, &pixel_format,
   9.409 +                                                    &matching) || !matching) {
   9.410 +        pixel_format = ChoosePixelFormat(hdc, &pfd);
   9.411 +    }
   9.412 +    if (!pixel_format) {
   9.413 +        SDL_SetError("No matching GL pixel format available");
   9.414 +        return -1;
   9.415 +    }
   9.416 +    if (!SetPixelFormat(hdc, pixel_format, &pfd)) {
   9.417 +        WIN_SetError("SetPixelFormat()");
   9.418 +        return (-1);
   9.419 +    }
   9.420 +    return 0;
   9.421 +}
   9.422 +
   9.423 +void
   9.424 +WIN_GL_CleanupWindow(_THIS, SDL_Window * window)
   9.425 +{
   9.426 +    WIN_GL_Shutdown(_this);
   9.427 +}
   9.428 +
   9.429 +int
   9.430 +WIN_GL_GetWindowAttribute(_THIS, SDL_Window * window, SDL_GLattr attrib,
   9.431 +                          int *value)
   9.432 +{
   9.433 +    HDC hdc = ((SDL_WindowData *) window->driverdata)->hdc;
   9.434 +    int pixel_format;
   9.435 +
   9.436 +    pixel_format = GetPixelFormat(hdc);
   9.437 +
   9.438 +    if (_this->gl_data->WGL_ARB_pixel_format) {
   9.439 +        int wgl_attrib;
   9.440 +
   9.441 +        switch (attrib) {
   9.442 +        case SDL_GL_RED_SIZE:
   9.443 +            wgl_attrib = WGL_RED_BITS_ARB;
   9.444 +            break;
   9.445 +        case SDL_GL_GREEN_SIZE:
   9.446 +            wgl_attrib = WGL_GREEN_BITS_ARB;
   9.447 +            break;
   9.448 +        case SDL_GL_BLUE_SIZE:
   9.449 +            wgl_attrib = WGL_BLUE_BITS_ARB;
   9.450 +            break;
   9.451 +        case SDL_GL_ALPHA_SIZE:
   9.452 +            wgl_attrib = WGL_ALPHA_BITS_ARB;
   9.453 +            break;
   9.454 +        case SDL_GL_DOUBLEBUFFER:
   9.455 +            wgl_attrib = WGL_DOUBLE_BUFFER_ARB;
   9.456 +            break;
   9.457 +        case SDL_GL_BUFFER_SIZE:
   9.458 +            wgl_attrib = WGL_COLOR_BITS_ARB;
   9.459 +            break;
   9.460 +        case SDL_GL_DEPTH_SIZE:
   9.461 +            wgl_attrib = WGL_DEPTH_BITS_ARB;
   9.462 +            break;
   9.463 +        case SDL_GL_STENCIL_SIZE:
   9.464 +            wgl_attrib = WGL_STENCIL_BITS_ARB;
   9.465 +            break;
   9.466 +        case SDL_GL_ACCUM_RED_SIZE:
   9.467 +            wgl_attrib = WGL_ACCUM_RED_BITS_ARB;
   9.468 +            break;
   9.469 +        case SDL_GL_ACCUM_GREEN_SIZE:
   9.470 +            wgl_attrib = WGL_ACCUM_GREEN_BITS_ARB;
   9.471 +            break;
   9.472 +        case SDL_GL_ACCUM_BLUE_SIZE:
   9.473 +            wgl_attrib = WGL_ACCUM_BLUE_BITS_ARB;
   9.474 +            break;
   9.475 +        case SDL_GL_ACCUM_ALPHA_SIZE:
   9.476 +            wgl_attrib = WGL_ACCUM_ALPHA_BITS_ARB;
   9.477 +            break;
   9.478 +        case SDL_GL_STEREO:
   9.479 +            wgl_attrib = WGL_STEREO_ARB;
   9.480 +            break;
   9.481 +        case SDL_GL_MULTISAMPLEBUFFERS:
   9.482 +            wgl_attrib = WGL_SAMPLE_BUFFERS_ARB;
   9.483 +            break;
   9.484 +        case SDL_GL_MULTISAMPLESAMPLES:
   9.485 +            wgl_attrib = WGL_SAMPLES_ARB;
   9.486 +            break;
   9.487 +        case SDL_GL_ACCELERATED_VISUAL:
   9.488 +            wgl_attrib = WGL_ACCELERATION_ARB;
   9.489 +            _this->gl_data->wglGetPixelFormatAttribivARB(hdc, pixel_format, 0,
   9.490 +                                                         1, &wgl_attrib,
   9.491 +                                                         value);
   9.492 +            if (*value == WGL_NO_ACCELERATION_ARB) {
   9.493 +                *value = SDL_FALSE;
   9.494 +            } else {
   9.495 +                *value = SDL_TRUE;
   9.496 +            }
   9.497 +            return 0;
   9.498 +            break;
   9.499 +        default:
   9.500 +            return (-1);
   9.501 +        }
   9.502 +        _this->gl_data->wglGetPixelFormatAttribivARB(hdc, pixel_format, 0, 1,
   9.503 +                                                     &wgl_attrib, value);
   9.504 +        return 0;
   9.505 +    } else {
   9.506 +        PIXELFORMATDESCRIPTOR pfd;
   9.507 +        int retval;
   9.508 +
   9.509 +        if (!DescribePixelFormat(hdc, pixel_format, sizeof(pfd), &pfd)) {
   9.510 +            WIN_SetError("DescribePixelFormat()");
   9.511 +            return -1;
   9.512 +        }
   9.513 +        retval = 0;
   9.514 +        switch (attrib) {
   9.515 +        case SDL_GL_RED_SIZE:
   9.516 +            *value = pfd.cRedBits;
   9.517 +            break;
   9.518 +        case SDL_GL_GREEN_SIZE:
   9.519 +            *value = pfd.cGreenBits;
   9.520 +            break;
   9.521 +        case SDL_GL_BLUE_SIZE:
   9.522 +            *value = pfd.cBlueBits;
   9.523 +            break;
   9.524 +        case SDL_GL_ALPHA_SIZE:
   9.525 +            *value = pfd.cAlphaBits;
   9.526 +            break;
   9.527 +        case SDL_GL_DOUBLEBUFFER:
   9.528 +            if (pfd.dwFlags & PFD_DOUBLEBUFFER) {
   9.529 +                *value = 1;
   9.530 +            } else {
   9.531 +                *value = 0;
   9.532 +            }
   9.533 +            break;
   9.534 +        case SDL_GL_BUFFER_SIZE:
   9.535 +            *value = pfd.cColorBits;
   9.536 +            break;
   9.537 +        case SDL_GL_DEPTH_SIZE:
   9.538 +            *value = pfd.cDepthBits;
   9.539 +            break;
   9.540 +        case SDL_GL_STENCIL_SIZE:
   9.541 +            *value = pfd.cStencilBits;
   9.542 +            break;
   9.543 +        case SDL_GL_ACCUM_RED_SIZE:
   9.544 +            *value = pfd.cAccumRedBits;
   9.545 +            break;
   9.546 +        case SDL_GL_ACCUM_GREEN_SIZE:
   9.547 +            *value = pfd.cAccumGreenBits;
   9.548 +            break;
   9.549 +        case SDL_GL_ACCUM_BLUE_SIZE:
   9.550 +            *value = pfd.cAccumBlueBits;
   9.551 +            break;
   9.552 +        case SDL_GL_ACCUM_ALPHA_SIZE:
   9.553 +            *value = pfd.cAccumAlphaBits;
   9.554 +            break;
   9.555 +        case SDL_GL_STEREO:
   9.556 +            if (pfd.dwFlags & PFD_STEREO) {
   9.557 +                *value = 1;
   9.558 +            } else {
   9.559 +                *value = 0;
   9.560 +            }
   9.561 +            break;
   9.562 +        case SDL_GL_MULTISAMPLEBUFFERS:
   9.563 +            *value = 0;
   9.564 +            break;
   9.565 +        case SDL_GL_MULTISAMPLESAMPLES:
   9.566 +            *value = 1;
   9.567 +            break;
   9.568 +        default:
   9.569 +            retval = -1;
   9.570 +            break;
   9.571 +        }
   9.572 +        return retval;
   9.573 +    }
   9.574 +}
   9.575 +
   9.576 +SDL_GLContext
   9.577 +WIN_GL_CreateContext(_THIS, SDL_Window * window)
   9.578 +{
   9.579 +    HDC hdc = ((SDL_WindowData *) window->driverdata)->hdc;
   9.580 +
   9.581 +    return _this->gl_data->wglCreateContext(hdc);
   9.582 +}
   9.583 +
   9.584 +int
   9.585 +WIN_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
   9.586 +{
   9.587 +    HDC hdc;
   9.588 +    int status;
   9.589 +
   9.590 +    if (window) {
   9.591 +        hdc = ((SDL_WindowData *) window->driverdata)->hdc;
   9.592 +    } else {
   9.593 +        hdc = NULL;
   9.594 +    }
   9.595 +    if (!_this->gl_data->wglMakeCurrent(hdc, (HGLRC) context)) {
   9.596 +        WIN_SetError("wglMakeCurrent()");
   9.597 +        status = -1;
   9.598 +    } else {
   9.599 +        status = 0;
   9.600 +    }
   9.601 +    return status;
   9.602 +}
   9.603 +
   9.604 +int
   9.605 +WIN_GL_SetSwapInterval(_THIS, int interval)
   9.606 +{
   9.607 +    if (_this->gl_data->wglSwapIntervalEXT) {
   9.608 +        _this->gl_data->wglSwapIntervalEXT(interval);
   9.609 +        return 0;
   9.610 +    } else {
   9.611 +        SDL_Unsupported();
   9.612 +        return -1;
   9.613 +    }
   9.614 +}
   9.615 +
   9.616 +int
   9.617 +WIN_GL_GetSwapInterval(_THIS)
   9.618 +{
   9.619 +    if (_this->gl_data->wglGetSwapIntervalEXT) {
   9.620 +        return _this->gl_data->wglGetSwapIntervalEXT();
   9.621 +    } else {
   9.622 +        SDL_Unsupported();
   9.623 +        return -1;
   9.624 +    }
   9.625 +}
   9.626 +
   9.627 +void
   9.628 +WIN_GL_SwapWindow(_THIS, SDL_Window * window)
   9.629 +{
   9.630 +    HDC hdc = ((SDL_WindowData *) window->driverdata)->hdc;
   9.631 +
   9.632 +    SwapBuffers(hdc);
   9.633 +}
   9.634 +
   9.635 +void
   9.636 +WIN_GL_DeleteContext(_THIS, SDL_GLContext context)
   9.637 +{
   9.638 +    if (context) {
   9.639 +        _this->gl_data->wglDeleteContext((HGLRC) context);
   9.640 +    }
   9.641 +}
   9.642 +
   9.643 +#endif /* SDL_VIDEO_OPENGL */
   9.644 +
   9.645 +
   9.646 +/* vi: set ts=4 sw=4 expandtab: */
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/src/video/win32/SDL_win32opengl.h	Mon Jul 17 06:47:33 2006 +0000
    10.3 @@ -0,0 +1,129 @@
    10.4 +/*
    10.5 +    SDL - Simple DirectMedia Layer
    10.6 +    Copyright (C) 1997-2006 Sam Lantinga
    10.7 +
    10.8 +    This library is free software; you can redistribute it and/or
    10.9 +    modify it under the terms of the GNU Lesser General Public
   10.10 +    License as published by the Free Software Foundation; either
   10.11 +    version 2.1 of the License, or (at your option) any later version.
   10.12 +
   10.13 +    This library is distributed in the hope that it will be useful,
   10.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   10.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   10.16 +    Lesser General Public License for more details.
   10.17 +
   10.18 +    You should have received a copy of the GNU Lesser General Public
   10.19 +    License along with this library; if not, write to the Free Software
   10.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   10.21 +
   10.22 +    Sam Lantinga
   10.23 +    slouken@libsdl.org
   10.24 +*/
   10.25 +#include "SDL_config.h"
   10.26 +
   10.27 +#ifndef _SDL_win32opengl_h
   10.28 +#define _SDL_win32opengl_h
   10.29 +
   10.30 +#if SDL_VIDEO_OPENGL
   10.31 +
   10.32 +struct SDL_GLDriverData
   10.33 +{
   10.34 +    int initialized;
   10.35 +    int WGL_ARB_pixel_format;
   10.36 +
   10.37 +    void *(WINAPI * wglGetProcAddress) (const char *proc);
   10.38 +      HGLRC(WINAPI * wglCreateContext) (HDC hdc);
   10.39 +      BOOL(WINAPI * wglDeleteContext) (HGLRC hglrc);
   10.40 +      BOOL(WINAPI * wglMakeCurrent) (HDC hdc, HGLRC hglrc);
   10.41 +      BOOL(WINAPI * wglChoosePixelFormatARB) (HDC hdc,
   10.42 +                                              const int *piAttribIList,
   10.43 +                                              const FLOAT * pfAttribFList,
   10.44 +                                              UINT nMaxFormats,
   10.45 +                                              int *piFormats,
   10.46 +                                              UINT * nNumFormats);
   10.47 +      BOOL(WINAPI * wglGetPixelFormatAttribivARB) (HDC hdc, int iPixelFormat,
   10.48 +                                                   int iLayerPlane,
   10.49 +                                                   UINT nAttributes,
   10.50 +                                                   const int *piAttributes,
   10.51 +                                                   int *piValues);
   10.52 +    void (WINAPI * wglSwapIntervalEXT) (int interval);
   10.53 +    int (WINAPI * wglGetSwapIntervalEXT) (void);
   10.54 +};
   10.55 +
   10.56 +/* OpenGL functions */
   10.57 +extern int WIN_GL_LoadLibrary(_THIS, const char *path);
   10.58 +extern void *WIN_GL_GetProcAddress(_THIS, const char *proc);
   10.59 +extern int WIN_GL_SetupWindow(_THIS, SDL_Window * window);
   10.60 +extern void WIN_GL_CleanupWindow(_THIS, SDL_Window * window);
   10.61 +extern int WIN_GL_GetWindowAttribute(_THIS, SDL_Window * window,
   10.62 +                                     SDL_GLattr attrib, int *value);
   10.63 +extern SDL_GLContext WIN_GL_CreateContext(_THIS, SDL_Window * window);
   10.64 +extern int WIN_GL_MakeCurrent(_THIS, SDL_Window * window,
   10.65 +                              SDL_GLContext context);
   10.66 +extern int WIN_GL_SetSwapInterval(_THIS, int interval);
   10.67 +extern int WIN_GL_GetSwapInterval(_THIS);
   10.68 +extern void WIN_GL_SwapWindow(_THIS, SDL_Window * window);
   10.69 +extern void WIN_GL_DeleteContext(_THIS, SDL_GLContext context);
   10.70 +
   10.71 +#ifndef WGL_ARB_pixel_format
   10.72 +#define WGL_NUMBER_PIXEL_FORMATS_ARB   0x2000
   10.73 +#define WGL_DRAW_TO_WINDOW_ARB         0x2001
   10.74 +#define WGL_DRAW_TO_BITMAP_ARB         0x2002
   10.75 +#define WGL_ACCELERATION_ARB           0x2003
   10.76 +#define WGL_NEED_PALETTE_ARB           0x2004
   10.77 +#define WGL_NEED_SYSTEM_PALETTE_ARB    0x2005
   10.78 +#define WGL_SWAP_LAYER_BUFFERS_ARB     0x2006
   10.79 +#define WGL_SWAP_METHOD_ARB            0x2007
   10.80 +#define WGL_NUMBER_OVERLAYS_ARB        0x2008
   10.81 +#define WGL_NUMBER_UNDERLAYS_ARB       0x2009
   10.82 +#define WGL_TRANSPARENT_ARB            0x200A
   10.83 +#define WGL_TRANSPARENT_RED_VALUE_ARB  0x2037
   10.84 +#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
   10.85 +#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
   10.86 +#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
   10.87 +#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
   10.88 +#define WGL_SHARE_DEPTH_ARB            0x200C
   10.89 +#define WGL_SHARE_STENCIL_ARB          0x200D
   10.90 +#define WGL_SHARE_ACCUM_ARB            0x200E
   10.91 +#define WGL_SUPPORT_GDI_ARB            0x200F
   10.92 +#define WGL_SUPPORT_OPENGL_ARB         0x2010
   10.93 +#define WGL_DOUBLE_BUFFER_ARB          0x2011
   10.94 +#define WGL_STEREO_ARB                 0x2012
   10.95 +#define WGL_PIXEL_TYPE_ARB             0x2013
   10.96 +#define WGL_COLOR_BITS_ARB             0x2014
   10.97 +#define WGL_RED_BITS_ARB               0x2015
   10.98 +#define WGL_RED_SHIFT_ARB              0x2016
   10.99 +#define WGL_GREEN_BITS_ARB             0x2017
  10.100 +#define WGL_GREEN_SHIFT_ARB            0x2018
  10.101 +#define WGL_BLUE_BITS_ARB              0x2019
  10.102 +#define WGL_BLUE_SHIFT_ARB             0x201A
  10.103 +#define WGL_ALPHA_BITS_ARB             0x201B
  10.104 +#define WGL_ALPHA_SHIFT_ARB            0x201C
  10.105 +#define WGL_ACCUM_BITS_ARB             0x201D
  10.106 +#define WGL_ACCUM_RED_BITS_ARB         0x201E
  10.107 +#define WGL_ACCUM_GREEN_BITS_ARB       0x201F
  10.108 +#define WGL_ACCUM_BLUE_BITS_ARB        0x2020
  10.109 +#define WGL_ACCUM_ALPHA_BITS_ARB       0x2021
  10.110 +#define WGL_DEPTH_BITS_ARB             0x2022
  10.111 +#define WGL_STENCIL_BITS_ARB           0x2023
  10.112 +#define WGL_AUX_BUFFERS_ARB            0x2024
  10.113 +#define WGL_NO_ACCELERATION_ARB        0x2025
  10.114 +#define WGL_GENERIC_ACCELERATION_ARB   0x2026
  10.115 +#define WGL_FULL_ACCELERATION_ARB      0x2027
  10.116 +#define WGL_SWAP_EXCHANGE_ARB          0x2028
  10.117 +#define WGL_SWAP_COPY_ARB              0x2029
  10.118 +#define WGL_SWAP_UNDEFINED_ARB         0x202A
  10.119 +#define WGL_TYPE_RGBA_ARB              0x202B
  10.120 +#define WGL_TYPE_COLORINDEX_ARB        0x202C
  10.121 +#endif
  10.122 +
  10.123 +#ifndef WGL_ARB_multisample
  10.124 +#define WGL_SAMPLE_BUFFERS_ARB         0x2041
  10.125 +#define WGL_SAMPLES_ARB                0x2042
  10.126 +#endif
  10.127 +
  10.128 +#endif /* SDL_VIDEO_OPENGL */
  10.129 +
  10.130 +#endif /* _SDL_win32opengl_h */
  10.131 +
  10.132 +/* vi: set ts=4 sw=4 expandtab: */
    11.1 --- a/src/video/win32/SDL_win32video.c	Sun Jul 16 09:34:01 2006 +0000
    11.2 +++ b/src/video/win32/SDL_win32video.c	Mon Jul 17 06:47:33 2006 +0000
    11.3 @@ -101,11 +101,11 @@
    11.4  
    11.5      /* Set the function pointers */
    11.6      device->VideoInit = WIN_VideoInit;
    11.7 +    device->VideoQuit = WIN_VideoQuit;
    11.8      device->GetDisplayModes = WIN_GetDisplayModes;
    11.9      device->SetDisplayMode = WIN_SetDisplayMode;
   11.10      device->SetDisplayGammaRamp = WIN_SetDisplayGammaRamp;
   11.11      device->GetDisplayGammaRamp = WIN_GetDisplayGammaRamp;
   11.12 -    device->VideoQuit = WIN_VideoQuit;
   11.13      device->PumpEvents = WIN_PumpEvents;
   11.14  
   11.15  #undef CreateWindow
   11.16 @@ -123,6 +123,17 @@
   11.17      device->SetWindowGrab = WIN_SetWindowGrab;
   11.18      device->DestroyWindow = WIN_DestroyWindow;
   11.19      device->GetWindowWMInfo = WIN_GetWindowWMInfo;
   11.20 +#ifdef SDL_VIDEO_OPENGL
   11.21 +    device->GL_LoadLibrary = WIN_GL_LoadLibrary;
   11.22 +    device->GL_GetProcAddress = WIN_GL_GetProcAddress;
   11.23 +    device->GL_GetWindowAttribute = WIN_GL_GetWindowAttribute;
   11.24 +    device->GL_CreateContext = WIN_GL_CreateContext;
   11.25 +    device->GL_MakeCurrent = WIN_GL_MakeCurrent;
   11.26 +    device->GL_SetSwapInterval = WIN_GL_SetSwapInterval;
   11.27 +    device->GL_GetSwapInterval = WIN_GL_GetSwapInterval;
   11.28 +    device->GL_SwapWindow = WIN_GL_SwapWindow;
   11.29 +    device->GL_DeleteContext = WIN_GL_DeleteContext;
   11.30 +#endif
   11.31  
   11.32      device->free = WIN_DeleteDevice;
   11.33  
    12.1 --- a/src/video/win32/SDL_win32video.h	Sun Jul 16 09:34:01 2006 +0000
    12.2 +++ b/src/video/win32/SDL_win32video.h	Mon Jul 17 06:47:33 2006 +0000
    12.3 @@ -42,6 +42,7 @@
    12.4  #include "SDL_win32keyboard.h"
    12.5  #include "SDL_win32modes.h"
    12.6  #include "SDL_win32mouse.h"
    12.7 +#include "SDL_win32opengl.h"
    12.8  #include "SDL_win32window.h"
    12.9  
   12.10  #ifdef UNICODE
    13.1 --- a/src/video/win32/SDL_win32window.c	Sun Jul 16 09:34:01 2006 +0000
    13.2 +++ b/src/video/win32/SDL_win32window.c	Mon Jul 17 06:47:33 2006 +0000
    13.3 @@ -43,12 +43,14 @@
    13.4      }
    13.5      data->windowID = window->id;
    13.6      data->hwnd = hwnd;
    13.7 +    data->hdc = GetDC(hwnd);
    13.8      data->created = created;
    13.9      data->mouse_pressed = SDL_FALSE;
   13.10      data->videodata = (SDL_VideoData *) SDL_GetVideoDevice()->driverdata;
   13.11  
   13.12      /* Associate the data with the window */
   13.13      if (!SetProp(hwnd, TEXT("SDL_WindowData"), data)) {
   13.14 +        ReleaseDC(hwnd, data->hdc);
   13.15          SDL_free(data);
   13.16          WIN_SetError("SetProp() failed");
   13.17          return -1;
   13.18 @@ -133,7 +135,7 @@
   13.19      LPTSTR title = NULL;
   13.20      HWND top;
   13.21      RECT rect;
   13.22 -    DWORD style = 0;
   13.23 +    DWORD style = (WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
   13.24      int x, y;
   13.25      int w, h;
   13.26  
   13.27 @@ -210,6 +212,14 @@
   13.28          DestroyWindow(hwnd);
   13.29          return -1;
   13.30      }
   13.31 +#ifdef SDL_VIDEO_OPENGL
   13.32 +    if (window->flags & SDL_WINDOW_OPENGL) {
   13.33 +        if (WIN_GL_SetupWindow(_this, window) < 0) {
   13.34 +            WIN_DestroyWindow(_this, window);
   13.35 +            return -1;
   13.36 +        }
   13.37 +    }
   13.38 +#endif
   13.39      return 0;
   13.40  }
   13.41  
   13.42 @@ -408,6 +418,12 @@
   13.43      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
   13.44  
   13.45      if (data) {
   13.46 +#ifdef SDL_VIDEO_OPENGL
   13.47 +        if (window->flags & SDL_WINDOW_OPENGL) {
   13.48 +            WIN_GL_CleanupWindow(_this, window);
   13.49 +        }
   13.50 +#endif
   13.51 +        ReleaseDC(data->hwnd, data->hdc);
   13.52          if (data->created) {
   13.53              DestroyWindow(data->hwnd);
   13.54          }
    14.1 --- a/src/video/win32/SDL_win32window.h	Sun Jul 16 09:34:01 2006 +0000
    14.2 +++ b/src/video/win32/SDL_win32window.h	Mon Jul 17 06:47:33 2006 +0000
    14.3 @@ -31,6 +31,7 @@
    14.4  {
    14.5      SDL_WindowID windowID;
    14.6      HWND hwnd;
    14.7 +    HDC hdc;
    14.8      WNDPROC wndproc;
    14.9      BOOL created;
   14.10      int mouse_pressed;