Jump to content
  • Advertisement
Sign in to follow this  
mbanghart

Viewports and Windows

This topic is 3624 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 all, I am trying to create a "border" around my world. My logic is: - Define window and set background color to black - Define viewport which is smaller than window and set to different color Will that work? How do you do the first part? I am coding in C++. Thanks Here is a picture of what I am trying to do. Not sure if I posted it correctly window

Share this post


Link to post
Share on other sites
Advertisement
I'm not quite sure of what you are doing, are you trying to have a 2D world view port "floating" inside a 3D world viewport?

either way, you can achieve what you want by translating the following pseudo code


const int windowWidth = 800, windowHeight = 600;
const int border = 5, insetX = 30, insetY = 30, insetWidth = 200, insetHeight = 200;
void render()
{
glViewport(0, 0, windowWidth, windowHeight);
glClearColor(1,1,1,1);
glClear(GL_COLOR_BUFFER_BIT /*| GL_DEPTH_BUFFER_BIT */);

// render 3D world or other view..
render3DWorld();

glViewport(insetX-border, insetY-border, insetWidth+border, insetHeight+border);
glClear(GL_COLOR_BUFFER_BIT /*| GL_DEPTH_BUFFER_BIT */);
glScissor(insetX, insetY, insetWidth, insetHeight);
glEnable(GL_SCISSOR_TEST);

// render your 2D inset
render2DInset();

glDisable(GL_SCISSOR_TEST);
}



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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!