SDL2 with OpenGL

Alright guys thank very much for your support!!!

Oh… And by the way, Sam, can you make my account able to post to the forum and contribute to the wiki???

It’s not clear what “that case” is. It sounds like you just want to use
OpenGL with SDL2. For that, do not create a renderer. An SDL renderer is
mostly for avoiding the use of OpenGL so you can use a cross-tech API that
works for OpenGL, Direct3D, and potentially others. If you just want
OpenGL and you want direct OpenGL calls, then don’t bother with SDL

Jonny DOn Thu, Feb 28, 2013 at 8:18 AM, Sik the hedgehog < sik.the.hedgehog at> wrote:

I’m given the impression he just wants an OpenGL window, he probably
doesn’t care about mixing both things. He was just asking which method
is considered more appropriate in that case.

2013/2/28, Gabriel Jacobo :

2013/2/28 Sik the hedgehog <sik.the.hedgehog at>

The renderer is needed when you pretend to use SDL’s own rendering
functions (which also support non-OpenGL backends). That it
initializes OpenGL (when the appropriate hint is set) is just a nice
side-effect, although SDL will also try to make use of OpenGL on its

No idea how safe it’s to use a renderer to initialize OpenGL (provided
you don’t touch SDL rendering functions save for SDL_RenderPresent).
Does anybody know? Though I suppose SDL_GLContext in that case would
be more appropriate.

There’s a few examples of how to use SDL_Render* with OpenGL calls here:

There are a few hoops to jump through as SDL keeps some very useful stuff
(shaders, shader management, its internal state, etc) hidden, so you have
to maneouver around that. But it’s doable.

On a related not, the SDL_RenderGeomtry function was in part inspired by
these tricks you need to do to be able to mesh (pun intended) both

2013/2/28, Aggelos Kolaitis :

Using OpenGL with SDL2, as far as my knowledge goes, can be
two ways, with or without a renderer.
Without a renderer, I simply create a window and an SDL_GLContext and
refreshing the screen is done with SDL_GL_SwapWindow

With a renderer, I create a window and a renderer for that window,
refreshing the screen is done with SDL_RenderPresent

In what means do these two differ, and, if they do, which is better,
more stable, more reliable, more prefered etc???


SDL mailing list
SDL at

2013/2/28, neoaggelos at :

Oh… And by the way, Sam, can you make my account able to post to the forum
and contribute to the wiki???

Regarding the forum:

Yeah, that’s quite easy to overlook. It took me several months before
I figured out what was going on.