Jump to content
  • Advertisement
Sign in to follow this  
IndrekSnt

[SDL] SDL & OpenGL

This topic is 4535 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
Advertisement
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
... or use hxRender instead of the SDL functions for a more powerful implementation of using OpenGL quads. (Hardware support of rotation and scaling as well as alpha-blending.)

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
Ok, Thanks

I think its still better to use code from my other projects and use OpenGL for rendering the GUI..

Or to learn CEGUI for this..

Thank You

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!