Jump to content
  • Advertisement
Sign in to follow this  
mbanghart

Border around world

This topic is 3649 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, I am trying to create a black border around my world (as defined in Ortho). Is this the way to do it: Define window Define a smaller viewport Create world within viewport - How do you specify the background for the viewport? Thanks

Share this post


Link to post
Share on other sites
Advertisement
As in "border" do you mean a frame? Like "you're looking into a TV" frame?
If so, you would normally render your world and just stick that frame on top in orthographic mode. There's no real trick to it.

Share this post


Link to post
Share on other sites
If you are using gluPerspective for you main rendering you can move to glOrtho as was suggested draw a single quad with texture that has the image of a frame with alpha channel to do alpha test on that texture to remove the inside cube so the outer frame is only shown.

If you are just in glOrtho you can do as above just no need to swap back and forth between glOrtho and gluPerspective.

Share this post


Link to post
Share on other sites
I still dont understand. Just to make sure everyone understands what I am trying to do, here is a picture.

window outer border ______________
| black border|
| __________ |
| | | |
| | world | |
| | | |
| | | |
| | | |
| |________| |
|_____________|

Here is my code"

void myInit()
{
createDisplayLists();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(worldxBegin,worldxEnd,worldyBegin,worldyEnd,10,-10);
glMatrixMode(GL_MODELVIEW);
glClearColor (wc1, wc2, wc3, 0.0);
}//void

int
main(int argc, char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500,500);

//Center on screen
GLint windowPosx = (glutGet (GLUT_SCREEN_WIDTH) - 500)/2;
GLint windowPosy = (glutGet (GLUT_SCREEN_HEIGHT) - 500)/2;
glutInitWindowPosition(windowPosx,windowPosy);
glutCreateWindow("Hallo");

glutDisplayFunc(display);
myInit();
glutMainLoop();

return 0;
}

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!