Advertisement

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

Started by July 01, 2002 04:10 AM
4 comments, last by IvanScheers 22 years, 8 months ago
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
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
[email=erydo@gdnmail.net" style="color: #ff0000; text-decoration:none; cursor:help;](o= erydo =o)[/email]
Advertisement
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.


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.
It''s not so much an SDL & OpenGL thing - it''s dependent on what SDL uses on your system (ie DirectDraw).


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
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).

This topic is closed to new replies.

Advertisement