• Advertisement

Archived

This topic is now archived and is closed to further replies.

SDL / OpenGL : mixed use for 2D / 3D

This topic is 5683 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

Hi, I''m working on a sim and am checking out SDL and OpenGL for use in the rendering engine. I''ve compiled the ''rotating rainbow cube demo'' source from the SDL Documentation Project http://sdldoc.csn.ul.ie/guidevideoopengl.php#AEN150 . After rendering the 3D scene with OpenGL, I''d like to add 2D stuff with SDL : transparent window bitmap, panel graphics, sprites etc. However, I can''t find turorials or examples of how to do it. Doing a SDL_BlitSurface just before or after SDL_GL_SwapBuffers didn''t show anything on the screen apart from the OpenGL rotating cube. How should I do it ? Ivan

Share this post


Link to post
Share on other sites
Advertisement
This is because you cannot;
You can either use SDL exclusively for drawing, window management, events, etc. or use OpenGL for drawing and SDL for the other stuff, but you can''t use both for drawing simultaneously...
Sorry

- Erydo

Share this post


Link to post
Share on other sites
You cannot use the 2D functionality of SDL while using OpenGL. Instead, in OpenGL, use an orthographic projection matrix the size of the screen and use OpenGL like a 2D API.

Share this post


Link to post
Share on other sites
Thanks for the input.

A pity SDL can''t be used for drawing if OpenGL is being used... It would''ve been soooo easy if SDL could write to the (OpenGL) video buffer also. Since it''s just an SDL_Surface I would have thought it could.

Well I''ll study OpenGL some more for doing the 2D stuff.

Ivan


> You cannot use the 2D functionality of SDL while
> using OpenGL. Instead, in OpenGL, use an orthographic
> projection matrix the size of the screen and use
> OpenGL like a 2D API.

Share this post


Link to post
Share on other sites
quote:
Original post by IvanScheers
A pity SDL can''t be used for drawing if OpenGL is being used... It would''ve been soooo easy if SDL could write to the (OpenGL) video buffer also. Since it''s just an SDL_Surface I would have thought it could.

SDL relies on other API''s and libraries to do it''s drawing (for the most part). Most (or all) of those are not written to be compatible with OpenGL (compatible as in ''able to render at the same time''). Becaues of this, the people behind SDL see no reason to even try to make their graphics rendering code available while you''re using OpenGL (since it is far more work than it''s worth).

Share this post


Link to post
Share on other sites

  • Advertisement