Jump to content
  • Advertisement
Sign in to follow this  

Viewports and Windows

This topic is 3798 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
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);

// render 3D world or other view..

glViewport(insetX-border, insetY-border, insetWidth+border, insetHeight+border);
glScissor(insetX, insetY, insetWidth, insetHeight);

// render your 2D inset


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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!