Jump to content
  • Advertisement
Sign in to follow this  
learnedseeker

Creating multiple viewports in SDL/OpenGL project, how to implement?

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

Obviously the window/event etc is handled by SDL.

 

The main game has basically 3.5 viewports. There is the main viewport, which is purely opengl; then there will be a GUI across the bottom, a notification bar on the left hand side, and a minimap in the bottom left side. Not sure if I should make that a separate context or attach it to the giu bar...

 

Question is, how exactly should I implement it? Should I create a glcontext for the main window viewport, then 3 seperate SDL_Renderer viewports for the other three windows? Or should I just kind of "toss" the overlays on top of the 1 single glcontext, and not render graphics that are behind the sdl viewports?

 

And uhh,... How exactly would you implement that? 3 separate renderer objects in SDL?

 

thanks,

 

learnedseeker

Edited by learnedseeker

Share this post


Link to post
Share on other sites
Advertisement

You could create different contexts but thats simply creating more windows. 

I've implemented back in OpenGL 2.1 a split screen using the glViewPort and glScissor

 

Basically all you need to do is something like this: 

glViewPort(0,0,Width,Height);

<render>

glViewPort(0,200,Width,

 

With SDL I think it's sdl_setClipRect,

I'm not familiar with sdl as im with openGl. 

Edited by WoopsASword

Share this post


Link to post
Share on other sites

You don't need any additional OpenGL contexts for multiple viewports.

 

You only need to call glViewport() to change which part of the screen to render, and then render as usual. You'd, of course, do this for each viewport.

 

If I'm understanding you question correctly, you want to overlay an HUD and minimap (etc...) over your 3D scene (much like any FPS, for example).

To do this, you don't need to change viewports at all.

You just need to render your 2D HUD (and minimap) after you render the 3D scene.

 

Changing viewports is used for things like, a 3D model editor (Blender, 3DS Max, etc) that has several views for the scene your editing, like this:

Blender%20minion%202015-1.png

 

If you want to check out a tutorial for multiple viewports, you can go to to NeHe's.

It does use deprecated OpenGL, but the viewports part is still used i modern OpenGL.

 

EDIT: WhoopASword beat me to it rolleyes.gif

Edited by __SKYe

Share this post


Link to post
Share on other sites


To do this, you don't need to change viewports at all.
You just need to render your 2D HUD (and minimap) after you render the 3D scene.

 

Okay so, you basically "toss" the GUI elements on top of the gl context. Cool. Gotcha.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!