SDL2和OpenGL具有两个窗口

时间:2014-03-06 14:46:18

标签: opengl sdl

我正在尝试使用两个带SDL2的窗口创建一个应用程序。为了使绘制过程更快并且能够运行3d动画我使用的是OpenGL。但是当我打开第二个窗口时,我怎么能说OpenGL(gl函数)在第二个窗口中绘制? 我搜索了libsdl维基但无法找到任何东西。

1 个答案:

答案 0 :(得分:5)

您正在寻找SDL_GL_MakeCurrent功能。

  

使用此功能设置OpenGL上下文以渲染到OpenGL窗口。

示例:

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