Jump to content
  • Advertisement
Sign in to follow this  
mbanghart

Window Size and Projection

This topic is 3645 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 not sure that I understand windowsize,projection and world size properly. I am trying to create a program with a world of size (wX,wY). The total window size should be larger though and is in the variables (winX,winY). My program is only in 2D. How do I set the world background color and how do I set the "world" background color? I am doing the following atm and it is not working right. glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(winX,winY); glutInitWindowPosition(windowPosx,windowPosy); glutCreateWindow("Program"); glutDisplayFunc(display); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0.0,wX,0.0,wY); glMatrixMode(GL_MODELVIEW); glClear(GL_COLOR_BUFFER_BIT);

Share this post


Link to post
Share on other sites
Advertisement
Quote:
what is the purpose of gluOrtho2D(0.0,wX,0.0,wY) ?

That call creates a matrix for projecting 2D coordinates onto the screen.

Vertex coordinates with x-values between 0 and wX will appear on the screen at positions from screen-left to screen-right. Similarly for y-values and 0 to wY projected to the screen height.

I would strongly recommend you get yourself a copy of OpenGL Programming Guide, otherwise know as "The Red Book." It is the Bible of OpenGL programming and describes all the OpenGL functions.

Share this post


Link to post
Share on other sites
I ordered it. How do you setup a different color for the window background and another color for the "world"?

Thanks
Marc

Share this post


Link to post
Share on other sites
Quote:
How do you setup a different color for the window background and another color for the "world"?

To set the window background:

glClearColor(floatRed, floatGreen, floatBlue, floatAlpha);
glClear(GL_COLOR_BUFFER_BIT);

where the red/green/blue/alpha parameters describe the color you want (which you may already know).

I'm not sure what you mean by "world" color. If you mean setting the color of an object you want to render, set glColor (rather than glClearColor) before you draw the object.

If you mean the background displayed for the "world," that's the window background color.

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!