Sign in to follow this  

[SDL] SDL & OpenGL

This topic is 4197 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, Could it be possible to render an image onto an OpenGL surface? I set up the SDL like this: SDL_Init (SDL_INIT_VIDEO); ScreenSurface = SDL_SetVideoMode (Config.Resolution.x, Config.Resolution.y, 0, SDL_OPENGL | SDL_HWSURFACE | SDL_NOFRAME | SDL_DOUBLEBUF); I tried something like this in the main loop: RenderWithOpenGL (); SDL_BlitSurface (TheImage, &Rect, ScreenSurface, &Rect); SDL_GL_SwapBuffers (); SDL_Flip (ScreenSurface); and I got a SIGSEV in some kind of Audio function in the SDL.dll.. Without the SDL_Flip () function everything executes but it fails to show the image.. If everything seems to be correct, then I probably have another error, where my program starts to rewrite itself.. :) All Suggestions are welcome, Thank You

Share this post


Link to post
Share on other sites
There is actually a flag you can use that allows for both at the same time (check the docs) but last time I checked (which was a while ago) it was buggy and slow. They may have improved it now.

Share this post


Link to post
Share on other sites
You can pass SDL_OPENGLBLIT instead of SDL_OPENGL. According to the documentation, however, "This option is kept for compatibility only, and will be removed in next versions. Is not recommended for new code."

I would reccomend just using textured quads.

Also note that there is no point in passing the SDL_HWSURFACE or SDL_DOUBLEBUF flags when using OpenGL.

Share this post


Link to post
Share on other sites
Thank You,
I thought it could be possible to use SDL's capabilities when I already linked it.
Is it possible to create 2 surfaces - 1 for OpenGL and the other for GUI.
Could I then somehow switch the surfaces on and off for rendering?

All suggestions are welcome,
Thank You again

Share this post


Link to post
Share on other sites
As I said if you're going to use glSDL you'll be able to use plain SDL functions and blit to surfaces using HW acceleration without a change a lot of changes to your code.
These are the only steps (from the readme) to be able to use glSDL in your code:

How To Use The glSDL Wrapper Hack
---------------------------------
1. Include glSDL.h instead of SDL.h.
2. Add SDL_GLSDL to the flags to SDL_SetVideoMode().
3. Do *NOT* use the glSDL_*() calls explicitly!
4. #define HAVE_OPENGL if OpenGL is present.
5. Link with SDL, SDL_image, OpenGL and math.
6. Enjoy!

As you already link with SDL, OpenGL and probably SDL_image only steps 1, 2, and 4 have to be considered. And maybe step 6 ;)

Share this post


Link to post
Share on other sites

This topic is 4197 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this