Wiki Page Content

Differences between revisions 13 and 14
Revision 13 as of 2016-01-01 18:47:27
Size: 792
Comment: Fixed OS name.
Revision 14 as of 2018-10-19 16:01:14
Size: 1347
Editor: Daniel
Comment:
Deletions are marked like this. Additions are marked like this.
Line 19: Line 19:
You can add your code example here
SDL_Window* window = SDL_CreateWindow("SDL2/OpenGL Demo", 30, 30,
    640, 480, SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE);
      
/* Create an OpenGL context associated with the window. */
SDL_GLContext glcontext = SDL_GL_CreateContext(window);

/* This makes our buffer swap syncronized with the monitor's vertical refresh */
SDL_GL_SetSwapInterval(1);

/* Clear context */
glClearColor(0,0,0,1);
glClear(GL_COLOR_BUFFER_BIT);

/* <Extra drawing fuctions here> */

/* Swap our buffer to display the current contents of buffer on screen */
SDL_GL_SwapWindow(window);

SDL_GL_SwapWindow

Use this function to update a window with OpenGL rendering.

Syntax

void SDL_GL_SwapWindow(SDL_Window* window)

Function Parameters

window

the window to change

Code Examples

SDL_Window* window = SDL_CreateWindow("SDL2/OpenGL Demo", 30, 30, 
    640, 480, SDL_WINDOW_OPENGL|SDL_WINDOW_RESIZABLE);
      
/* Create an OpenGL context associated with the window. */
SDL_GLContext glcontext = SDL_GL_CreateContext(window);

/* This makes our buffer swap syncronized with the monitor's vertical refresh */
SDL_GL_SetSwapInterval(1);

/* Clear context */
glClearColor(0,0,0,1);
glClear(GL_COLOR_BUFFER_BIT);

/* <Extra drawing fuctions here> */ 

/* Swap our buffer to display the current contents of buffer on screen */ 
SDL_GL_SwapWindow(window);

Remarks

This is used with double-buffered OpenGL contexts, which are the default.

On Mac OS X make sure you bind 0 to the draw framebuffer before swapping the window, otherwise nothing will happen. See this blog post for more info.


CategoryAPI, CategoryVideo

None: SDL_GL_SwapWindow (last edited 2020-03-29 15:38:46 by ChrisBush)

(Page Info.)
Feedback
Please include your contact information if you'd like to receive a reply.
Submit