Mixing SDL and OpenGL

Hello guys,

I just tried to mix SDL_RenderCopy with displaying some 3D using OpenGL, but it doesn’t seem to play very nice, basically what I get is a distorted view of some mess :slight_smile:

What I would like to do is to display for example an UI using SDL_RenderCopy and maybe display some 3D using OpenGL in a selected rectangle on a screen. What I need to keep in mind? It seems I might need to somehow save/restore some OpenGL context/state …

And basically if it’s not a good idea to mix these SDL and OpenGL calls, how can I get a OpenGL texture out from SDL_Texture so I can maybe render 3D to this texture?

Any ideas?

thanks,
Pavel Kanzelsberger

OpenGL simply doesn’t like it when something else is playing with the screen. It’s designed that way.

What you could do with your app is force use of the OpenGL backend, and then the SDL devs can ensure that OpenGL is back in it’s original state after it’s done with every operation. (This might be slower, though…)

Hello,

I’m sorry I forgot to mention that, of course I’m using OpenGL backend, my application simply won’t work without OpenGL support. So basically I don’t have any crashes so far, but simply I think the OpenGL state/context should be somehow preserved so they don’t mess with each other. I was just wondering what kind of things I have to save and restore before displaying custom OpenGL stuff. For now I tried to reset the glMatrixMode, but it doesn’t seem to be enough…

PavelOn 16.2.2010, at 17:22, nfries88 wrote:

OpenGL simply doesn’t like it when something else is playing with the screen. It’s designed that way.

What you could do with your app is force use of the OpenGL backend, and then the SDL devs can ensure that OpenGL is back in it’s original state after it’s done with every operation. (This might be slower, though…)


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

Pavel Kanzelsberger wrote:

Hello,

I’m sorry I forgot to mention that, of course I’m using OpenGL backend, my application simply won’t work without OpenGL support. So basically I don’t have any crashes so far, but simply I think the OpenGL state/context should be somehow preserved so they don’t mess with each other. I was just wondering what kind of things I have to save and restore before displaying custom OpenGL stuff. For now I tried to reset the glMatrixMode, but it doesn’t seem to be enough…

Pavel

OpenGL simply doesn’t like it when something else is playing with the screen. It’s designed that way.

What you could do with your app is force use of the OpenGL backend, and then the SDL devs can ensure that OpenGL is back in it’s original state after it’s done with every operation. (This might be slower, though…)


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

SDL should really support this internally, the programmer shouldn’t have to restore the GL context to it’s expected state in his own code.
At the same time, the programmer should need to ensure the GL context is back in its expected state before calling SDL code.> On 16.2.2010, at 17:22, nfries88 wrote:

Hi,

yes that’s correct and I am understanding this correctly, this is not
yet the case with SDL 1.3 … so is there any specific way to do this
until it’s developed in SDL? I will use some temporary code to avoid
problems right now, and remove the code when this feature is
introduced in SDL… any hints?

PavelOn 18.2.2010, at 23:45, nfries88 wrote:

Pavel Kanzelsberger wrote:
Hello,

I’m sorry I forgot to mention that, of course I’m using OpenGL
backend, my application simply won’t work without OpenGL support. So
basically I don’t have any crashes so far, but simply I think the
OpenGL state/context should be somehow preserved so they don’t mess
with each other. I was just wondering what kind of things I have to
save and restore before displaying custom OpenGL stuff. For now I
tried to reset the glMatrixMode, but it doesn’t seem to be enough…

Pavel

On 16.2.2010, at 17:22, nfries88 wrote:

Quote:
OpenGL simply doesn’t like it when something else is playing with
the screen. It’s designed that way.

What you could do with your app is force use of the OpenGL backend,
and then the SDL devs can ensure that OpenGL is back in it’s
original state after it’s done with every operation. (This might be
slower, though…)


SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

SDL should really support this internally, the programmer shouldn’t
have to restore the GL context to it’s expected state in his own code.
At the same time, the programmer should need to ensure the GL
context is back in its expected state before calling SDL code.


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


Pavel Kanzelsberger

E-Mail: pavel at kanzelsberger.com
Jabber: kanzelsberger at jabber.org, ICQ: 20990633