Sign in to follow this  
u235

SDL and OpenGL rendering calls

Recommended Posts

Can I initialize SDL for use with OpenGL and then use pure SDL calls to render the stuff I want to be 2D and OpenGL calls to render the stuff I want to be 3D? Thanks.

Share this post


Link to post
Share on other sites
No, once you call SDL_SetVideoMode mode with the opengl flag you can no longer use SDL_BlitSurface on the screen surface.

You should use OpenGL to render both anyway you will get better performance.

Share this post


Link to post
Share on other sites
You can however use "regular" SDL calls to create and modify software surfaces that you can then upload to textures for use by OpenGL.

I have used this technique for example with SDL_ttf to generate a bitmap font from a font the user chooses. The resulting surface is then uploaded as a texture and then OpenGL uses it from there.

OpenGL does have it's quirks when doing 2d and 3d (or 2d in 3d) so I always refer to this post for switching between 2d and 3d in OpenGL. It is pretty old but also informative.

Share this post


Link to post
Share on other sites
Thanks for the info. I think I will give that a try. I tried 2D in OpenGL with SDL once before, but when I passed in the pixels array from a surface to glDrawPixels, it came out kind of messed up. It was upside down, which I expected, but there were artifacts which I couldn't explain. I'll try to find some docs though and figure it out. Thanks.

Share this post


Link to post
Share on other sites

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