Is there is any guide for mixing Opengl and SDL rendering? |
Is there is any guide for mixing Opengl and SDL rendering? |
Bob Rubbens
Guest
|
From what I've read SDL basically uses the entire OpenGL state when you use the render api. You could have a look at the source and see how much SDL actually needs from the OpenGL state, but I've never read any guarantees about that from SDL's side. I could be wrong though. Maybe you can describe what exactly "did not work"? In what way did it not match your expectations?
On 11 May 2016 at 09:37, gabf83 wrote:
|
|||||||||||||
|
Is there is any guide for mixing Opengl and SDL rendering? |
Eric Wing
Guest
|
On 5/11/16, gabf83 wrote:
There have been previous threads on this and related topics, though they are scattered and hard to find. Here is my attempt to organize them. On mixing OpenGL and the SDL 2D renderer, Gabriel Jacobo developed this solution for integrating a GUI library called librocket. http://mdqinc.com/blog/2013/01/integrating-librocket-with-sdl-2/ https://bugzilla.libsdl.org/show_bug.cgi?id=1138 There was a discussion/proposal of adding a batching API for submitting quads to the 2D renderer. https://forums.libsdl.org/viewtopic.php?p=48449&sid=cc802ffa803aa9e6614a9ee23ff476a2 Gabriel Jacobo also proposed a direct triangle rendering function "SDL_RenderGeometry" to handle more arbitrary geometry submission to the 2D renderer. https://forums.libsdl.org/viewtopic.php?t=8850&sid=0e06d37272e22e0204ce68f8fb92c424 For your situation though, you might strongly consider using SDL_gpu by Jonathan Dearborn. You can think of it as another alternative SDL 2D renderer (which happens to be built on top of OpenGL right now). It tries to bridge that gap between keeping a lot of SDL's simpler/easier semantics, while still giving you a lot more access to OpenGL features. I think it has done a pretty good job striking that balance. It provides APIs to pass an SDL_surface and load it as GPU_Image which is very similar to an SDL_Texture. It provides GPU_Blit* functions which are very similar to SDL_RenderCopy*. And SDL_gpu provides access to GLSL shaders so you can load in your shaders. I'm currently writing a couple of demos using it, including a dynamic lighting system for 2D sprites using normal maps generated by popular tools out there. -Eric _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
Is there is any guide for mixing Opengl and SDL rendering? |
Sanette
Guest
|
Hi
my experience so far is that *some* mixing between openGL and Renderer is possible with some care. For instance you can render an SDL texture and then render directly some openGL quads onscreen. For this to work you need to reset things like shader programs at every frame. However I have never tried to use openGL to render directly onto and SDL texture. This might be impossible at this point. I hope that SDL can evolve in this direction in the future. S. Le 11/05/2016 09:37, gabf83 a écrit :
|
|||||||||||||
|
gabf83
|
Thanks for your replies. Fortunately, Gabriel Jacobo released a patch that provides the SDL Renderer with a Geometry Rendering function. I was able to patch SDL 2.0.0 and tested that it works and does exactly what I was looking for.
Interestingly, it appears that the trick is having the same OpenGL render context that SDL Render uses render whatever you want OpenGL to render for you. Regards Gabriel |
|||||||||||
|
Is there is any guide for mixing Opengl and SDL rendering? |
Sanette
Guest
|
interesting, coud you give the link to the patch ?
Le 30/05/2016 22:52, gabf83 a écrit :
|
|||||||||||||||
|
Re: Is there is any guide for mixing Opengl and SDL renderin |
gabf83
|
Sure,
This is the link to the bug where the patch is: http://bugzilla.libsdl.org/show_bug.cgi?id=1734 This is the post where it was shared: https://forums.libsdl.org/viewtopic.php?t=8850&sid=0e06d37272e22e0204ce68f8fb92c424 Really hopping this officially makes it to SDL next releases. Regards
|
|||||||||||||||||
|