shoc
shoc

Reputation: 143

SDL2 and OpenGL functions with two windows

I am trying to make one application with two windows with SDL2. To make draw process faster and capable to run 3d animations I am using OpenGL. But when I open second window, how can I said to OpenGL (gl functions) to draw in second window? I searched into libsdl wiki but cant find anything.

Upvotes: 5

Views: 6614

Answers (1)

user142162
user142162

Reputation:

You are looking for the SDL_GL_MakeCurrent function.

Use this function to set up an OpenGL context for rendering into an OpenGL window.

Example:

SDL_GL_MakeCurrent(window, gl_context);
// OpenGL functions will draw to window
// ...
SDL_GL_MakeCurrent(window2, gl_context);
// OpenGL functions will draw to window2

Upvotes: 11

Related Questions