Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Setting up the OpenGL support

  • Loading branch information
slouken committed Jul 16, 2006
1 parent a185206 commit 4f62229ecb5cdc1c6aa1e997aa15a093265a0972
Showing with 250 additions and 110 deletions.
  1. +1 −0 include/SDL_compat.h
  2. +9 −3 include/SDL_video.h
  3. +25 −0 src/SDL_compat.c
  4. +10 −27 src/video/SDL_sysvideo.h
  5. +137 −25 src/video/SDL_video.c
  6. +61 −48 src/video/dummy/SDL_nullrender.c
  7. +7 −7 test/testgl.c
@@ -172,6 +172,7 @@ extern DECLSPEC int SDLCALL SDL_DisplayYUVOverlay(SDL_Overlay * overlay,
SDL_Rect * dstrect);
extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay * overlay);
extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int *value);
extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void);

/* Ends C function definitions when using C++ */
#ifdef __cplusplus
@@ -1499,6 +1499,10 @@ extern DECLSPEC int SDLCALL SDL_GL_MakeCurrent(SDL_WindowID windowID,
*
* \brief Set the swap interval for the current OpenGL context.
*
* \param interval 0 for immediate updates, 1 for updates synchronized with the vertical retrace
*
* \return 0 on success, or -1 if setting the swap interval is not supported.
*
* \sa SDL_GL_GetSwapInterval()
*/
extern DECLSPEC int SDLCALL SDL_GL_SetSwapInterval(int interval);
@@ -1508,16 +1512,18 @@ extern DECLSPEC int SDLCALL SDL_GL_SetSwapInterval(int interval);
*
* \brief Get the swap interval for the current OpenGL context.
*
* \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.
*
* \sa SDL_GL_SetSwapInterval()
*/
extern DECLSPEC int SDLCALL SDL_GL_GetSwapInterval(void);

/**
* \fn void SDL_GL_SwapBuffers(void)
* \fn void SDL_GL_SwapWindow(SDL_WindowID windowID)
*
* Swap the OpenGL buffers, if double-buffering is supported.
* \brief Swap the OpenGL buffers for the window, if double-buffering is supported.
*/
extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void);
extern DECLSPEC void SDLCALL SDL_GL_SwapWindow(SDL_WindowID windowID);

/**
* \fn void SDL_GL_DeleteContext(SDL_GLContext context)
@@ -36,6 +36,7 @@ static SDL_TextureID SDL_VideoTexture;
static SDL_Surface *SDL_VideoSurface;
static SDL_Surface *SDL_ShadowSurface;
static SDL_Surface *SDL_PublicSurface;
static SDL_GLContext *SDL_VideoContext;
static char *wm_title;

char *
@@ -335,6 +336,11 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
SDL_FreeSurface(SDL_VideoSurface);
SDL_VideoSurface = NULL;
}
if (SDL_VideoContext) {
SDL_GL_MakeCurrent(0, SDL_VideoContext);
SDL_GL_DeleteContext(SDL_VideoContext);
SDL_VideoContext = NULL;
}
if (SDL_VideoWindow) {
SDL_GetWindowPosition(SDL_VideoWindow, &window_x, &window_y);
}
@@ -432,6 +438,13 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)

/* If we're in OpenGL mode, just create a stub surface and we're done! */
if (flags & SDL_OPENGL) {
SDL_VideoContext = SDL_GL_CreateContext(SDL_VideoWindow);
if (!SDL_VideoContext) {
return NULL;
}
if (SDL_GL_MakeCurrent(SDL_VideoWindow, SDL_VideoContext) < 0) {
return NULL;
}
SDL_VideoSurface =
SDL_CreateRGBSurfaceFrom(NULL, width, height, bpp, 0, 0, 0, 0, 0);
if (!SDL_VideoSurface) {
@@ -1418,4 +1431,16 @@ SDL_FreeYUVOverlay(SDL_Overlay * overlay)
}
}

int
SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
{
return SDL_GL_GetWindowAttribute(SDL_VideoWindow, attr, value);
}

void
SDL_GL_SwapBuffers(void)
{
SDL_GL_SwapWindow(SDL_VideoWindow);
}

/* vi: set ts=4 sw=4 expandtab: */
@@ -227,36 +227,21 @@ struct SDL_VideoDevice
void (*VideoQuit) (_THIS);

/* * * */
/* OpenGL support */

/* Sets the dll to use for OpenGL and loads it */
/* OpenGL support
*/
int (*GL_LoadLibrary) (_THIS, const char *path);

/* Retrieves the address of a function in the gl library */
void *(*GL_GetProcAddress) (_THIS, const char *proc);

/* Get attribute information from the windowing system. */
int (*GL_GetAttribute) (_THIS, SDL_GLattr attrib, int *value);

/* Make the context associated with this driver current */
int (*GL_MakeCurrent) (_THIS);

/* Swap the current buffers in double buffer mode. */
void (*GL_SwapBuffers) (_THIS);

/* Determine whether the mouse should be in relative mode or not.
This function is called when the input grab state or cursor
visibility state changes.
If the cursor is not visible, and the input is grabbed, the
driver can place the mouse in relative mode, which may result
in higher accuracy sampling of the pointer motion.
*/
void (*CheckMouseMode) (_THIS);
SDL_GLContext(*GL_CreateContext) (_THIS, SDL_Window * window);
int (*GL_MakeCurrent) (_THIS, SDL_Window * window, SDL_GLContext context);
int (*GL_SetSwapInterval) (_THIS, int interval);
int (*GL_GetSwapInterval) (_THIS);
void (*GL_SwapWindow) (_THIS, SDL_Window * window);
void (*GL_DeleteContext) (_THIS, SDL_GLContext context);

/* * * */
/* Event manager functions */

/* Handle any queued OS events */
/* Event manager functions
*/
void (*PumpEvents) (_THIS);

/* * * */
@@ -266,8 +251,6 @@ struct SDL_VideoDevice
int current_display;
Uint32 next_object_id;

/* Driver information flags */

/* * * */
/* Data used by the GL drivers */
struct

0 comments on commit 4f62229

Please sign in to comment.