SDL with OpenGL at the same time.....
I know it is possible to open an OpenGL Window through SDL, but can I have them both open at the same time? What I mean is can I use SDL to render the tiles of a tile map, and then render 3D tanks with OpenGL over the Tiles so it looks like one scene, or do I have to texture map quads in OpenGL to make the maps?
My Current Project Angels 22 (4E5)
Quote:
Original post by Sir Sapo
I know it is possible to open an OpenGL Window through SDL, but can I have them both open at the same time? What I mean is can I use SDL to render the tiles of a tile map, and then render 3D tanks with OpenGL over the Tiles so it looks like one scene, or do I have to texture map quads in OpenGL to make the maps?
You are going to have to use total OpenGL.
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
Quote:
Original post by Sir Sapo
I know it is possible to open an OpenGL Window through SDL, but can I have them both open at the same time? What I mean is can I use SDL to render the tiles of a tile map, and then render 3D tanks with OpenGL over the Tiles so it looks like one scene, or do I have to texture map quads in OpenGL to make the maps?
If you take a look at the NeHe SDL OpenGL basecode, it does exactly this. You can use SDL_BlitSurface() for 2D objects and OpenGL calls for 3D objects by passing the SDL_OPENGLBLIT flag to SDL_SetVideoMode.
However, there are some disadvantages to this: 1) Much Slower as SDL doesn't know the current state for OpenGL 2) the SDL_OPENGLBLIT flag is depreciated, and not recommended for new code (according to the sdl website) 3) you don't reap the benifits of using OpenGL for 2D, such as hardware acceleration, rotation, scaling, lighting,... (the list goes on).
I would highly recommend using the SDL_OPENGL flag and avoid using SDL_BlitSurface() calls, as the SDL_OPENGLBLIT flag may be removed in later versions (possibly 1.3) of SDL, and your code would break.
Quote:
Original post by Sir Sapo
I know it is possible to open an OpenGL Window through SDL, but can I have them both open at the same time? What I mean is can I use SDL to render the tiles of a tile map, and then render 3D tanks with OpenGL over the Tiles so it looks like one scene, or do I have to texture map quads in OpenGL to make the maps?
At this stage with SDL - it is most perferrable that you use all OpenGL functions. Basically you would have to do something like this:
glOrtho Mode
... Draw Tiles ...
glPerspective Mode
... Draw Tanks ...
So, yes, you would need to texture map quads in OpenGL if you wanted the best and fastest performance. I actually think it is impossible to accompish what you are saying with mixing the 2D and 3D like that - The SDL will be drawn on top of the OpenGL. If you switch rendering order, it still would not matter - **I think** the SDL will end up being on top. I say this because before I used the OpenGL flag, I used SDL to make user interfaces around the OpenGL window - but I could never mix the two and have it come out just right - 3D on top of SDL - but I may be wrong.
Quote:
Original post by wyrzy Quote:
Original post by Sir Sapo
I know it is possible to open an OpenGL Window through SDL, but can I have them both open at the same time? What I mean is can I use SDL to render the tiles of a tile map, and then render 3D tanks with OpenGL over the Tiles so it looks like one scene, or do I have to texture map quads in OpenGL to make the maps?
If you take a look at the NeHe SDL OpenGL basecode, it does exactly this. You can use SDL_BlitSurface() for 2D objects and OpenGL calls for 3D objects by passing the SDL_OPENGLBLIT flag to SDL_SetVideoMode.
However, there are some disadvantages to this: 1) Much Slower as SDL doesn't know the current state for OpenGL 2) the SDL_OPENGLBLIT flag is depreciated, and not recommended for new code (according to the sdl website) 3) you don't reap the benifits of using OpenGL for 2D, such as hardware acceleration, rotation, scaling, lighting,... (the list goes on).
I would highly recommend using the SDL_OPENGL flag and avoid using SDL_BlitSurface() calls, as the SDL_OPENGLBLIT flag may be removed in later versions (possibly 1.3) of SDL, and your code would break.
For Christ's sake, you guys have to stop telling the no0bs about that worthless hack. I don't care even if you are telling them not to use it, but you just have to know they are going to try it anyways.
Sir Sapo, promise me you will not listen to this man's crazyness! Promise me that you will use textured quads instead!
If you need help doing it, take a look at the source of my library, hxRender. Heck, tweak with it and it may fit exactly what you are looking for. Just forget you ever heard about using SDL_BlitSurface with the OpenGL flags.
HxRender | Cornerstone SDL TutorialsCurrently picking on: Hedos, Programmer One
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement