Using SDL2 with OpenGL

Using OpenGL with SDL2, as far as my knowledge goes, can be accomplished in 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, while refreshing the screen is done with SDL_RenderPresent

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

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
own.

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.

2013/2/28, Aggelos Kolaitis :> Using OpenGL with SDL2, as far as my knowledge goes, can be accomplished in

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, while
refreshing the screen is done with SDL_RenderPresent

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


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

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

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
own.

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:
http://wiki.libsdl.org/moin.cgi/SDL_GL_BindTexture

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 "worlds"
together> 2013/2/28, Aggelos Kolaitis :

Using OpenGL with SDL2, as far as my knowledge goes, can be accomplished
in
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, while
refreshing the screen is done with SDL_RenderPresent

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



Gabriel.

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>

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
own.

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:
http://wiki.libsdl.org/moin.cgi/SDL_GL_BindTexture

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 "worlds"
together

2013/2/28, Aggelos Kolaitis :

Using OpenGL with SDL2, as far as my knowledge goes, can be
accomplished
in
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,
while
refreshing the screen is done with SDL_RenderPresent

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



Gabriel.

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
renderers.

Jonny DOn Thu, Feb 28, 2013 at 8:18 AM, Sik the hedgehog < sik.the.hedgehog at gmail.com> 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 gmail.com>

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
own.

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:
http://wiki.libsdl.org/moin.cgi/SDL_GL_BindTexture

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
"worlds"
together

2013/2/28, Aggelos Kolaitis :

Using OpenGL with SDL2, as far as my knowledge goes, can be
accomplished
in
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,
while
refreshing the screen is done with SDL_RenderPresent

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



Gabriel.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org