[SDL] SDL & OpenGL
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
You can't do opengl and sdl blitting at once. Either don't use opengl or set up textured quads.
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.
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.
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.
... 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.)
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
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
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:
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 ;)
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 ;)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement