Setting up the OpenGL support
authorSam Lantinga <slouken@libsdl.org>
Sun, 16 Jul 2006 09:34:01 +0000
changeset 19128d384b647307
parent 1911 7577fd11cee4
child 1913 83420da906a5
Setting up the OpenGL support
include/SDL_compat.h
include/SDL_video.h
src/SDL_compat.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/dummy/SDL_nullrender.c
test/testgl.c
     1.1 --- a/include/SDL_compat.h	Sun Jul 16 03:35:44 2006 +0000
     1.2 +++ b/include/SDL_compat.h	Sun Jul 16 09:34:01 2006 +0000
     1.3 @@ -172,6 +172,7 @@
     1.4                                                    SDL_Rect * dstrect);
     1.5  extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay * overlay);
     1.6  extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int *value);
     1.7 +extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void);
     1.8  
     1.9  /* Ends C function definitions when using C++ */
    1.10  #ifdef __cplusplus
     2.1 --- a/include/SDL_video.h	Sun Jul 16 03:35:44 2006 +0000
     2.2 +++ b/include/SDL_video.h	Sun Jul 16 09:34:01 2006 +0000
     2.3 @@ -1499,6 +1499,10 @@
     2.4   *
     2.5   * \brief Set the swap interval for the current OpenGL context.
     2.6   *
     2.7 + * \param interval 0 for immediate updates, 1 for updates synchronized with the vertical retrace
     2.8 + *
     2.9 + * \return 0 on success, or -1 if setting the swap interval is not supported.
    2.10 + *
    2.11   * \sa SDL_GL_GetSwapInterval()
    2.12   */
    2.13  extern DECLSPEC int SDLCALL SDL_GL_SetSwapInterval(int interval);
    2.14 @@ -1508,16 +1512,18 @@
    2.15   *
    2.16   * \brief Get the swap interval for the current OpenGL context.
    2.17   *
    2.18 + * \return 0 if there is no vertical retrace synchronization, 1 if the buffer swap is synchronized with the vertical retrace, and -1 if getting the swap interval is not supported.
    2.19 + *
    2.20   * \sa SDL_GL_SetSwapInterval()
    2.21   */
    2.22  extern DECLSPEC int SDLCALL SDL_GL_GetSwapInterval(void);
    2.23  
    2.24  /**
    2.25 - * \fn void SDL_GL_SwapBuffers(void)
    2.26 + * \fn void SDL_GL_SwapWindow(SDL_WindowID windowID)
    2.27   *
    2.28 - * Swap the OpenGL buffers, if double-buffering is supported.
    2.29 + * \brief Swap the OpenGL buffers for the window, if double-buffering is supported.
    2.30   */
    2.31 -extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void);
    2.32 +extern DECLSPEC void SDLCALL SDL_GL_SwapWindow(SDL_WindowID windowID);
    2.33  
    2.34  /**
    2.35   * \fn void SDL_GL_DeleteContext(SDL_GLContext context)
     3.1 --- a/src/SDL_compat.c	Sun Jul 16 03:35:44 2006 +0000
     3.2 +++ b/src/SDL_compat.c	Sun Jul 16 09:34:01 2006 +0000
     3.3 @@ -36,6 +36,7 @@
     3.4  static SDL_Surface *SDL_VideoSurface;
     3.5  static SDL_Surface *SDL_ShadowSurface;
     3.6  static SDL_Surface *SDL_PublicSurface;
     3.7 +static SDL_GLContext *SDL_VideoContext;
     3.8  static char *wm_title;
     3.9  
    3.10  char *
    3.11 @@ -335,6 +336,11 @@
    3.12          SDL_FreeSurface(SDL_VideoSurface);
    3.13          SDL_VideoSurface = NULL;
    3.14      }
    3.15 +    if (SDL_VideoContext) {
    3.16 +        SDL_GL_MakeCurrent(0, SDL_VideoContext);
    3.17 +        SDL_GL_DeleteContext(SDL_VideoContext);
    3.18 +        SDL_VideoContext = NULL;
    3.19 +    }
    3.20      if (SDL_VideoWindow) {
    3.21          SDL_GetWindowPosition(SDL_VideoWindow, &window_x, &window_y);
    3.22      }
    3.23 @@ -432,6 +438,13 @@
    3.24  
    3.25      /* If we're in OpenGL mode, just create a stub surface and we're done! */
    3.26      if (flags & SDL_OPENGL) {
    3.27 +        SDL_VideoContext = SDL_GL_CreateContext(SDL_VideoWindow);
    3.28 +        if (!SDL_VideoContext) {
    3.29 +            return NULL;
    3.30 +        }
    3.31 +        if (SDL_GL_MakeCurrent(SDL_VideoWindow, SDL_VideoContext) < 0) {
    3.32 +            return NULL;
    3.33 +        }
    3.34          SDL_VideoSurface =
    3.35              SDL_CreateRGBSurfaceFrom(NULL, width, height, bpp, 0, 0, 0, 0, 0);
    3.36          if (!SDL_VideoSurface) {
    3.37 @@ -1418,4 +1431,16 @@
    3.38      }
    3.39  }
    3.40  
    3.41 +int
    3.42 +SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
    3.43 +{
    3.44 +    return SDL_GL_GetWindowAttribute(SDL_VideoWindow, attr, value);
    3.45 +}
    3.46 +
    3.47 +void
    3.48 +SDL_GL_SwapBuffers(void)
    3.49 +{
    3.50 +    SDL_GL_SwapWindow(SDL_VideoWindow);
    3.51 +}
    3.52 +
    3.53  /* vi: set ts=4 sw=4 expandtab: */
     4.1 --- a/src/video/SDL_sysvideo.h	Sun Jul 16 03:35:44 2006 +0000
     4.2 +++ b/src/video/SDL_sysvideo.h	Sun Jul 16 09:34:01 2006 +0000
     4.3 @@ -227,36 +227,21 @@
     4.4      void (*VideoQuit) (_THIS);
     4.5  
     4.6      /* * * */
     4.7 -    /* OpenGL support */
     4.8 -
     4.9 -    /* Sets the dll to use for OpenGL and loads it */
    4.10 +    /* OpenGL support
    4.11 +     */
    4.12      int (*GL_LoadLibrary) (_THIS, const char *path);
    4.13 -
    4.14 -    /* Retrieves the address of a function in the gl library */
    4.15      void *(*GL_GetProcAddress) (_THIS, const char *proc);
    4.16 -
    4.17 -    /* Get attribute information from the windowing system. */
    4.18      int (*GL_GetAttribute) (_THIS, SDL_GLattr attrib, int *value);
    4.19 -
    4.20 -    /* Make the context associated with this driver current */
    4.21 -    int (*GL_MakeCurrent) (_THIS);
    4.22 -
    4.23 -    /* Swap the current buffers in double buffer mode. */
    4.24 -    void (*GL_SwapBuffers) (_THIS);
    4.25 -
    4.26 -    /* Determine whether the mouse should be in relative mode or not.
    4.27 -       This function is called when the input grab state or cursor
    4.28 -       visibility state changes.
    4.29 -       If the cursor is not visible, and the input is grabbed, the
    4.30 -       driver can place the mouse in relative mode, which may result
    4.31 -       in higher accuracy sampling of the pointer motion.
    4.32 -     */
    4.33 -    void (*CheckMouseMode) (_THIS);
    4.34 +      SDL_GLContext(*GL_CreateContext) (_THIS, SDL_Window * window);
    4.35 +    int (*GL_MakeCurrent) (_THIS, SDL_Window * window, SDL_GLContext context);
    4.36 +    int (*GL_SetSwapInterval) (_THIS, int interval);
    4.37 +    int (*GL_GetSwapInterval) (_THIS);
    4.38 +    void (*GL_SwapWindow) (_THIS, SDL_Window * window);
    4.39 +    void (*GL_DeleteContext) (_THIS, SDL_GLContext context);
    4.40  
    4.41      /* * * */
    4.42 -    /* Event manager functions */
    4.43 -
    4.44 -    /* Handle any queued OS events */
    4.45 +    /* Event manager functions
    4.46 +     */
    4.47      void (*PumpEvents) (_THIS);
    4.48  
    4.49      /* * * */
    4.50 @@ -266,8 +251,6 @@
    4.51      int current_display;
    4.52      Uint32 next_object_id;
    4.53  
    4.54 -    /* Driver information flags */
    4.55 -
    4.56      /* * * */
    4.57      /* Data used by the GL drivers */
    4.58      struct
     5.1 --- a/src/video/SDL_video.c	Sun Jul 16 03:35:44 2006 +0000
     5.2 +++ b/src/video/SDL_video.c	Sun Jul 16 09:34:01 2006 +0000
     5.3 @@ -153,6 +153,12 @@
     5.4      return 0;
     5.5  }
     5.6  
     5.7 +static void
     5.8 +SDL_UninitializedVideo()
     5.9 +{
    5.10 +    SDL_SetError("Video subsystem has not been initialized");
    5.11 +}
    5.12 +
    5.13  int
    5.14  SDL_GetNumVideoDrivers(void)
    5.15  {
    5.16 @@ -285,6 +291,7 @@
    5.17  SDL_GetCurrentVideoDriver()
    5.18  {
    5.19      if (!_this) {
    5.20 +        SDL_UninitializedVideo();
    5.21          return NULL;
    5.22      }
    5.23      return _this->name;
    5.24 @@ -334,6 +341,7 @@
    5.25  SDL_GetNumVideoDisplays(void)
    5.26  {
    5.27      if (!_this) {
    5.28 +        SDL_UninitializedVideo();
    5.29          return 0;
    5.30      }
    5.31      return _this->num_displays;
    5.32 @@ -343,7 +351,7 @@
    5.33  SDL_SelectVideoDisplay(int index)
    5.34  {
    5.35      if (!_this) {
    5.36 -        SDL_SetError("Video subsystem has not been initialized");
    5.37 +        SDL_UninitializedVideo();
    5.38          return (-1);
    5.39      }
    5.40      if (index >= 0) {
    5.41 @@ -535,7 +543,7 @@
    5.42      int i, ncolors;
    5.43  
    5.44      if (!_this) {
    5.45 -        SDL_SetError("Video subsystem has not been initialized");
    5.46 +        SDL_UninitializedVideo();
    5.47          return -1;
    5.48      }
    5.49  
    5.50 @@ -621,7 +629,7 @@
    5.51      int i;
    5.52  
    5.53      if (!_this) {
    5.54 -        SDL_SetError("Video subsystem has not been initialized");
    5.55 +        SDL_UninitializedVideo();
    5.56          return -1;
    5.57      }
    5.58  
    5.59 @@ -659,7 +667,7 @@
    5.60      int status = 0;
    5.61  
    5.62      if (!_this) {
    5.63 -        SDL_SetError("Video subsystem has not been initialized");
    5.64 +        SDL_UninitializedVideo();
    5.65          return -1;
    5.66      }
    5.67      palette = SDL_CurrentDisplay.palette;
    5.68 @@ -684,7 +692,7 @@
    5.69      SDL_Palette *palette;
    5.70  
    5.71      if (!_this) {
    5.72 -        SDL_SetError("Video subsystem has not been initialized");
    5.73 +        SDL_UninitializedVideo();
    5.74          return -1;
    5.75      }
    5.76  
    5.77 @@ -721,7 +729,12 @@
    5.78      SDL_Window *windows;
    5.79  
    5.80      if (!_this) {
    5.81 -        SDL_SetError("Video subsystem has not been initialized");
    5.82 +        SDL_UninitializedVideo();
    5.83 +        return 0;
    5.84 +    }
    5.85 +
    5.86 +    if ((flags & SDL_WINDOW_OPENGL) && !_this->GL_CreateContext) {
    5.87 +        SDL_SetError("No OpenGL support in video driver");
    5.88          return 0;
    5.89      }
    5.90  
    5.91 @@ -783,7 +796,7 @@
    5.92      SDL_Window *windows;
    5.93  
    5.94      if (!_this) {
    5.95 -        SDL_SetError("Video subsystem has not been initialized");
    5.96 +        SDL_UninitializedVideo();
    5.97          return (0);
    5.98      }
    5.99  
   5.100 @@ -822,6 +835,7 @@
   5.101      int i, j;
   5.102  
   5.103      if (!_this) {
   5.104 +        SDL_UninitializedVideo();
   5.105          return NULL;
   5.106      }
   5.107  
   5.108 @@ -841,6 +855,7 @@
   5.109  SDL_GetDisplayFromWindow(SDL_Window * window)
   5.110  {
   5.111      if (!_this) {
   5.112 +        SDL_UninitializedVideo();
   5.113          return NULL;
   5.114      }
   5.115      return &_this->displays[window->display];
   5.116 @@ -1281,6 +1296,7 @@
   5.117  SDL_GetRendererInfo(int index, SDL_RendererInfo * info)
   5.118  {
   5.119      if (!_this) {
   5.120 +        SDL_UninitializedVideo();
   5.121          return -1;
   5.122      }
   5.123  
   5.124 @@ -1374,6 +1390,7 @@
   5.125      SDL_Texture *texture;
   5.126  
   5.127      if (!_this) {
   5.128 +        SDL_UninitializedVideo();
   5.129          return 0;
   5.130      }
   5.131  
   5.132 @@ -1752,6 +1769,7 @@
   5.133      SDL_Rect real_rect;
   5.134  
   5.135      if (!_this) {
   5.136 +        SDL_UninitializedVideo();
   5.137          return -1;
   5.138      }
   5.139  
   5.140 @@ -1821,6 +1839,7 @@
   5.141      SDL_Renderer *renderer;
   5.142  
   5.143      if (!_this) {
   5.144 +        SDL_UninitializedVideo();
   5.145          return;
   5.146      }
   5.147  
   5.148 @@ -1839,6 +1858,7 @@
   5.149      SDL_Renderer *renderer;
   5.150  
   5.151      if (!_this) {
   5.152 +        SDL_UninitializedVideo();
   5.153          return;
   5.154      }
   5.155  
   5.156 @@ -1977,21 +1997,21 @@
   5.157      _this = NULL;
   5.158  }
   5.159  
   5.160 -/* Load the GL driver library */
   5.161  int
   5.162  SDL_GL_LoadLibrary(const char *path)
   5.163  {
   5.164      int retval;
   5.165  
   5.166 -    retval = -1;
   5.167 -    if (_this == NULL) {
   5.168 -        SDL_SetError("Video subsystem has not been initialized");
   5.169 +    if (!_this) {
   5.170 +        SDL_UninitializedVideo();
   5.171 +        return -1;
   5.172 +    }
   5.173 +
   5.174 +    if (_this->GL_LoadLibrary) {
   5.175 +        retval = _this->GL_LoadLibrary(_this, path);
   5.176      } else {
   5.177 -        if (_this->GL_LoadLibrary) {
   5.178 -            retval = _this->GL_LoadLibrary(_this, path);
   5.179 -        } else {
   5.180 -            SDL_SetError("No dynamic GL support in video driver");
   5.181 -        }
   5.182 +        SDL_SetError("No dynamic GL support in video driver");
   5.183 +        retval = -1;
   5.184      }
   5.185      return (retval);
   5.186  }
   5.187 @@ -2001,6 +2021,11 @@
   5.188  {
   5.189      void *func;
   5.190  
   5.191 +    if (!_this) {
   5.192 +        SDL_UninitializedVideo();
   5.193 +        return NULL;
   5.194 +    }
   5.195 +
   5.196      func = NULL;
   5.197      if (_this->GL_GetProcAddress) {
   5.198          if (_this->gl_config.driver_loaded) {
   5.199 @@ -2014,12 +2039,16 @@
   5.200      return func;
   5.201  }
   5.202  
   5.203 -/* Set the specified GL attribute for setting up a GL video mode */
   5.204  int
   5.205  SDL_GL_SetAttribute(SDL_GLattr attr, int value)
   5.206  {
   5.207      int retval;
   5.208  
   5.209 +    if (!_this) {
   5.210 +        SDL_UninitializedVideo();
   5.211 +        return -1;
   5.212 +    }
   5.213 +
   5.214      retval = 0;
   5.215      switch (attr) {
   5.216      case SDL_GL_RED_SIZE:
   5.217 @@ -2075,30 +2104,113 @@
   5.218          retval = -1;
   5.219          break;
   5.220      }
   5.221 -    return (retval);
   5.222 +    return retval;
   5.223  }
   5.224  
   5.225 -/* Retrieve an attribute value from the windowing system. */
   5.226  int
   5.227 -SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
   5.228 +SDL_GL_GetWindowAttribute(SDL_WindowID windowID, SDL_GLattr attr, int *value)
   5.229  {
   5.230 -    int retval = -1;
   5.231 +    SDL_Window *window = SDL_GetWindowFromID(windowID);
   5.232 +    int retval;
   5.233 +
   5.234 +    if (!window) {
   5.235 +        return -1;
   5.236 +    }
   5.237  
   5.238      if (_this->GL_GetAttribute) {
   5.239          retval = _this->GL_GetAttribute(_this, attr, value);
   5.240      } else {
   5.241          *value = 0;
   5.242          SDL_SetError("GL_GetAttribute not supported");
   5.243 +        retval = -1;
   5.244      }
   5.245      return retval;
   5.246  }
   5.247  
   5.248 -/* Perform a GL buffer swap on the current GL context */
   5.249 +SDL_GLContext
   5.250 +SDL_GL_CreateContext(SDL_WindowID windowID)
   5.251 +{
   5.252 +    SDL_Window *window = SDL_GetWindowFromID(windowID);
   5.253 +
   5.254 +    if (!window) {
   5.255 +        return NULL;
   5.256 +    }
   5.257 +    if (!(window->flags & SDL_WINDOW_OPENGL)) {
   5.258 +        SDL_SetError("The specified window isn't an OpenGL window");
   5.259 +        return NULL;
   5.260 +    }
   5.261 +    return _this->GL_CreateContext(_this, window);
   5.262 +}
   5.263 +
   5.264 +int
   5.265 +SDL_GL_MakeCurrent(SDL_WindowID windowID, SDL_GLContext context)
   5.266 +{
   5.267 +    SDL_Window *window = SDL_GetWindowFromID(windowID);
   5.268 +
   5.269 +    if (!window || !context) {
   5.270 +        return -1;
   5.271 +    }
   5.272 +    if (!(window->flags & SDL_WINDOW_OPENGL)) {
   5.273 +        SDL_SetError("The specified window isn't an OpenGL window");
   5.274 +        return -1;
   5.275 +    }
   5.276 +    return _this->GL_MakeCurrent(_this, window, context);
   5.277 +}
   5.278 +
   5.279 +int
   5.280 +SDL_GL_SetSwapInterval(int interval)
   5.281 +{
   5.282 +    if (!_this) {
   5.283 +        SDL_UninitializedVideo();
   5.284 +        return -1;
   5.285 +    }
   5.286 +
   5.287 +    if (_this->GL_SetSwapInterval) {
   5.288 +        return _this->GL_SetSwapInterval(_this, interval);
   5.289 +    } else {
   5.290 +        SDL_SetError("Setting the swap interval is not supported");
   5.291 +        return -1;
   5.292 +    }
   5.293 +}
   5.294 +
   5.295 +int
   5.296 +SDL_GL_GetSwapInterval(void)
   5.297 +{
   5.298 +    if (!_this) {
   5.299 +        SDL_UninitializedVideo();
   5.300 +        return -1;
   5.301 +    }
   5.302 +
   5.303 +    if (_this->GL_GetSwapInterval) {
   5.304 +        return _this->GL_GetSwapInterval(_this);
   5.305 +    } else {
   5.306 +        SDL_SetError("Getting the swap interval is not supported");
   5.307 +        return -1;
   5.308 +    }
   5.309 +}
   5.310 +
   5.311  void
   5.312 -SDL_GL_SwapBuffers(void)
   5.313 +SDL_GL_SwapWindow(SDL_WindowID windowID)
   5.314  {
   5.315 -    // FIXME: Track the current window context - do we provide N contexts, and match them to M windows, or is there a one-to-one mapping?
   5.316 -    _this->GL_SwapBuffers(_this);
   5.317 +    SDL_Window *window = SDL_GetWindowFromID(windowID);
   5.318 +
   5.319 +    if (!window) {
   5.320 +        return;
   5.321 +    }
   5.322 +    if (!(window->flags & SDL_WINDOW_OPENGL)) {
   5.323 +        SDL_SetError("The specified window isn't an OpenGL window");
   5.324 +        return;
   5.325 +    }
   5.326 +    return _this->GL_SwapWindow(_this, window);
   5.327 +}
   5.328 +
   5.329 +void
   5.330 +SDL_GL_DeleteContext(SDL_GLContext context)
   5.331 +{
   5.332 +    if (!_this || !context) {
   5.333 +        return;
   5.334 +    }
   5.335 +    _this->GL_DeleteContext(_this, context);
   5.336  }
   5.337  
   5.338  #if 0                           // FIXME
     6.1 --- a/src/video/dummy/SDL_nullrender.c	Sun Jul 16 03:35:44 2006 +0000
     6.2 +++ b/src/video/dummy/SDL_nullrender.c	Sun Jul 16 09:34:01 2006 +0000
     6.3 @@ -28,47 +28,51 @@
     6.4  
     6.5  /* SDL surface based renderer implementation */
     6.6  
     6.7 -static SDL_Renderer *SDL_DUMMY_CreateRenderer(SDL_Window * window, Uint32 flags);
     6.8 +static SDL_Renderer *SDL_DUMMY_CreateRenderer(SDL_Window * window,
     6.9 +                                              Uint32 flags);
    6.10  static int SDL_DUMMY_CreateTexture(SDL_Renderer * renderer,
    6.11 -                                SDL_Texture * texture);
    6.12 +                                   SDL_Texture * texture);
    6.13  static int SDL_DUMMY_QueryTexturePixels(SDL_Renderer * renderer,
    6.14 -                                     SDL_Texture * texture, void **pixels,
    6.15 -                                     int *pitch);
    6.16 +                                        SDL_Texture * texture, void **pixels,
    6.17 +                                        int *pitch);
    6.18  static int SDL_DUMMY_SetTexturePalette(SDL_Renderer * renderer,
    6.19 -                                    SDL_Texture * texture,
    6.20 -                                    const SDL_Color * colors, int firstcolor,
    6.21 -                                    int ncolors);
    6.22 +                                       SDL_Texture * texture,
    6.23 +                                       const SDL_Color * colors,
    6.24 +                                       int firstcolor, int ncolors);
    6.25  static int SDL_DUMMY_GetTexturePalette(SDL_Renderer * renderer,
    6.26 -                                    SDL_Texture * texture, SDL_Color * colors,
    6.27 -                                    int firstcolor, int ncolors);
    6.28 +                                       SDL_Texture * texture,
    6.29 +                                       SDL_Color * colors, int firstcolor,
    6.30 +                                       int ncolors);
    6.31  static int SDL_DUMMY_UpdateTexture(SDL_Renderer * renderer,
    6.32 -                                SDL_Texture * texture, const SDL_Rect * rect,
    6.33 -                                const void *pixels, int pitch);
    6.34 -static int SDL_DUMMY_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    6.35 -                              const SDL_Rect * rect, int markDirty,
    6.36 -                              void **pixels, int *pitch);
    6.37 +                                   SDL_Texture * texture,
    6.38 +                                   const SDL_Rect * rect, const void *pixels,
    6.39 +                                   int pitch);
    6.40 +static int SDL_DUMMY_LockTexture(SDL_Renderer * renderer,
    6.41 +                                 SDL_Texture * texture, const SDL_Rect * rect,
    6.42 +                                 int markDirty, void **pixels, int *pitch);
    6.43  static void SDL_DUMMY_UnlockTexture(SDL_Renderer * renderer,
    6.44 -                                 SDL_Texture * texture);
    6.45 +                                    SDL_Texture * texture);
    6.46  static void SDL_DUMMY_DirtyTexture(SDL_Renderer * renderer,
    6.47 -                                SDL_Texture * texture, int numrects,
    6.48 -                                const SDL_Rect * rects);
    6.49 +                                   SDL_Texture * texture, int numrects,
    6.50 +                                   const SDL_Rect * rects);
    6.51  static void SDL_DUMMY_SelectRenderTexture(SDL_Renderer * renderer,
    6.52 -                                       SDL_Texture * texture);
    6.53 -static int SDL_DUMMY_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
    6.54 -                             Uint32 color);
    6.55 -static int SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
    6.56 -                             const SDL_Rect * srcrect,
    6.57 -                             const SDL_Rect * dstrect, int blendMode,
    6.58 -                             int scaleMode);
    6.59 +                                          SDL_Texture * texture);
    6.60 +static int SDL_DUMMY_RenderFill(SDL_Renderer * renderer,
    6.61 +                                const SDL_Rect * rect, Uint32 color);
    6.62 +static int SDL_DUMMY_RenderCopy(SDL_Renderer * renderer,
    6.63 +                                SDL_Texture * texture,
    6.64 +                                const SDL_Rect * srcrect,
    6.65 +                                const SDL_Rect * dstrect, int blendMode,
    6.66 +                                int scaleMode);
    6.67  static int SDL_DUMMY_RenderReadPixels(SDL_Renderer * renderer,
    6.68 -                                   const SDL_Rect * rect, void *pixels,
    6.69 -                                   int pitch);
    6.70 +                                      const SDL_Rect * rect, void *pixels,
    6.71 +                                      int pitch);
    6.72  static int SDL_DUMMY_RenderWritePixels(SDL_Renderer * renderer,
    6.73 -                                    const SDL_Rect * rect, const void *pixels,
    6.74 -                                    int pitch);
    6.75 +                                       const SDL_Rect * rect,
    6.76 +                                       const void *pixels, int pitch);
    6.77  static void SDL_DUMMY_RenderPresent(SDL_Renderer * renderer);
    6.78  static void SDL_DUMMY_DestroyTexture(SDL_Renderer * renderer,
    6.79 -                                  SDL_Texture * texture);
    6.80 +                                     SDL_Texture * texture);
    6.81  static void SDL_DUMMY_DestroyRenderer(SDL_Renderer * renderer);
    6.82  
    6.83  
    6.84 @@ -195,7 +199,9 @@
    6.85              return -1;
    6.86          }
    6.87  
    6.88 -        texture->driverdata = SDL_CreateRGBSurface(0, texture->w, texture->h, bpp, Rmask, Gmask, Bmask, Amask);
    6.89 +        texture->driverdata =
    6.90 +            SDL_CreateRGBSurface(0, texture->w, texture->h, bpp, Rmask, Gmask,
    6.91 +                                 Bmask, Amask);
    6.92      }
    6.93  
    6.94      if (!texture->driverdata) {
    6.95 @@ -206,10 +212,11 @@
    6.96  
    6.97  static int
    6.98  SDL_DUMMY_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
    6.99 -                          void **pixels, int *pitch)
   6.100 +                             void **pixels, int *pitch)
   6.101  {
   6.102      if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
   6.103 -        return SDL_SW_QueryYUVTexturePixels((SDL_SW_YUVTexture *) texture->driverdata, pixels, pitch);
   6.104 +        return SDL_SW_QueryYUVTexturePixels((SDL_SW_YUVTexture *) texture->
   6.105 +                                            driverdata, pixels, pitch);
   6.106      } else {
   6.107          SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
   6.108  
   6.109 @@ -221,8 +228,8 @@
   6.110  
   6.111  static int
   6.112  SDL_DUMMY_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
   6.113 -                         const SDL_Color * colors, int firstcolor,
   6.114 -                         int ncolors)
   6.115 +                            const SDL_Color * colors, int firstcolor,
   6.116 +                            int ncolors)
   6.117  {
   6.118      if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
   6.119          SDL_SetError("YUV textures don't have a palette");
   6.120 @@ -237,7 +244,7 @@
   6.121  
   6.122  static int
   6.123  SDL_DUMMY_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
   6.124 -                         SDL_Color * colors, int firstcolor, int ncolors)
   6.125 +                            SDL_Color * colors, int firstcolor, int ncolors)
   6.126  {
   6.127      if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
   6.128          SDL_SetError("YUV textures don't have a palette");
   6.129 @@ -253,7 +260,7 @@
   6.130  
   6.131  static int
   6.132  SDL_DUMMY_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   6.133 -                     const SDL_Rect * rect, const void *pixels, int pitch)
   6.134 +                        const SDL_Rect * rect, const void *pixels, int pitch)
   6.135  {
   6.136      if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
   6.137          return SDL_SW_UpdateYUVTexture((SDL_SW_YUVTexture *) texture->
   6.138 @@ -280,8 +287,8 @@
   6.139  
   6.140  static int
   6.141  SDL_DUMMY_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   6.142 -                   const SDL_Rect * rect, int markDirty, void **pixels,
   6.143 -                   int *pitch)
   6.144 +                      const SDL_Rect * rect, int markDirty, void **pixels,
   6.145 +                      int *pitch)
   6.146  {
   6.147      if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
   6.148          return SDL_SW_LockYUVTexture((SDL_SW_YUVTexture *) texture->
   6.149 @@ -308,15 +315,16 @@
   6.150  
   6.151  static void
   6.152  SDL_DUMMY_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
   6.153 -                    int numrects, const SDL_Rect * rects)
   6.154 +                       int numrects, const SDL_Rect * rects)
   6.155  {
   6.156  }
   6.157  
   6.158  static int
   6.159  SDL_DUMMY_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
   6.160 -                  Uint32 color)
   6.161 +                     Uint32 color)
   6.162  {
   6.163 -    SDL_DUMMY_RenderData *data = (SDL_DUMMY_RenderData *) renderer->driverdata;
   6.164 +    SDL_DUMMY_RenderData *data =
   6.165 +        (SDL_DUMMY_RenderData *) renderer->driverdata;
   6.166      SDL_Surface *target = data->screens[data->current_screen];
   6.167      SDL_Rect real_rect = *rect;
   6.168      Uint8 r, g, b, a;
   6.169 @@ -332,10 +340,11 @@
   6.170  
   6.171  static int
   6.172  SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
   6.173 -                  const SDL_Rect * srcrect, const SDL_Rect * dstrect,
   6.174 -                  int blendMode, int scaleMode)
   6.175 +                     const SDL_Rect * srcrect, const SDL_Rect * dstrect,
   6.176 +                     int blendMode, int scaleMode)
   6.177  {
   6.178 -    SDL_DUMMY_RenderData *data = (SDL_DUMMY_RenderData *) renderer->driverdata;
   6.179 +    SDL_DUMMY_RenderData *data =
   6.180 +        (SDL_DUMMY_RenderData *) renderer->driverdata;
   6.181      SDL_Window *window = SDL_GetWindowFromID(renderer->window);
   6.182      SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
   6.183  
   6.184 @@ -362,9 +371,11 @@
   6.185          }
   6.186          if (scaleMode != SDL_TextureScaleMode_None &&
   6.187              (srcrect->w != dstrect->w || srcrect->h != dstrect->h)) {
   6.188 -            return SDL_SoftStretch(surface, &real_srcrect, target, &real_dstrect);
   6.189 +            return SDL_SoftStretch(surface, &real_srcrect, target,
   6.190 +                                   &real_dstrect);
   6.191          } else {
   6.192 -            return SDL_LowerBlit(surface, &real_srcrect, target, &real_dstrect);
   6.193 +            return SDL_LowerBlit(surface, &real_srcrect, target,
   6.194 +                                 &real_dstrect);
   6.195          }
   6.196      }
   6.197  }
   6.198 @@ -373,7 +384,8 @@
   6.199  SDL_DUMMY_RenderPresent(SDL_Renderer * renderer)
   6.200  {
   6.201      static int frame_number;
   6.202 -    SDL_DUMMY_RenderData *data = (SDL_DUMMY_RenderData *) renderer->driverdata;
   6.203 +    SDL_DUMMY_RenderData *data =
   6.204 +        (SDL_DUMMY_RenderData *) renderer->driverdata;
   6.205  
   6.206      /* Send the data to the display */
   6.207      if (SDL_getenv("SDL_VIDEO_DUMMY_SAVE_FRAMES")) {
   6.208 @@ -406,7 +418,8 @@
   6.209  static void
   6.210  SDL_DUMMY_DestroyRenderer(SDL_Renderer * renderer)
   6.211  {
   6.212 -    SDL_DUMMY_RenderData *data = (SDL_DUMMY_RenderData *) renderer->driverdata;
   6.213 +    SDL_DUMMY_RenderData *data =
   6.214 +        (SDL_DUMMY_RenderData *) renderer->driverdata;
   6.215      int i;
   6.216  
   6.217      if (data) {
     7.1 --- a/test/testgl.c	Sun Jul 16 03:35:44 2006 +0000
     7.2 +++ b/test/testgl.c	Sun Jul 16 09:34:01 2006 +0000
     7.3 @@ -457,16 +457,16 @@
     7.4      if (accel) {
     7.5          SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
     7.6      }
     7.7 -    if (sync) {
     7.8 -        SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
     7.9 -    } else {
    7.10 -        SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 0);
    7.11 -    }
    7.12      if (SDL_SetVideoMode(w, h, bpp, video_flags) == NULL) {
    7.13          fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
    7.14          SDL_Quit();
    7.15          exit(1);
    7.16      }
    7.17 +    if (sync) {
    7.18 +        SDL_GL_SetSwapInterval(1);
    7.19 +    } else {
    7.20 +        SDL_GL_SetSwapInterval(0);
    7.21 +    }
    7.22  
    7.23      printf("Screen BPP: %d\n", SDL_GetVideoSurface()->format->BitsPerPixel);
    7.24      printf("\n");
    7.25 @@ -498,8 +498,8 @@
    7.26          printf("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value);
    7.27      }
    7.28      if (sync) {
    7.29 -        SDL_GL_GetAttribute(SDL_GL_SWAP_CONTROL, &value);
    7.30 -        printf("SDL_GL_SWAP_CONTROL: requested 1, got %d\n", value);
    7.31 +        printf("Buffer swap interval: requested 1, got %d\n",
    7.32 +               SDL_GL_GetSwapInterval());
    7.33      }
    7.34  
    7.35      /* Set the window manager title bar */