Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SDL2 and OpenGL functions with two windows

Tags:

opengl

sdl

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.

like image 334
shoc Avatar asked Jan 12 '23 01:01

shoc


1 Answers

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
like image 99
Tim Cooper Avatar answered Jan 18 '23 23:01

Tim Cooper