Newbie needs help: how to set dimensions of display screen?

hey!
I am new to mac as well as opengl(though I have some experience with VC++).

I am building on some basic foundation code I downloaded, but I could specify co-ordinate values only between -1.0 to 1.0 in all the the three axes.
How do I change these values so that I can set the scale for the axes? where do I do that?

What is depth test? Whenever I enable that my display gets weird. Can anyone explain this, please?
I have to rebuild a VC++ application that uses OpenGL extensively. Is there a difference in the OpenGL coding for mac and Windows(apart from the setup of course)?

The changes needed depend on if you are using GLUT or not. If you use GLUT then you shouldn’t need to change much for the windowing, but if you used the Win32 APIs to make windows in VC++ then you’ll have to change the window code for it.

As for the depth test, it’s used to determine if there are fragments that are totally covered by other fragments and will not even process them if they are. This saves some time.

The scalling bit. You’ll need to set up a projection using either glFrustum or glOrtho with the correct arguments in order to set the viewing volume. I believe that it defaults to -1 to 1 on all axis.

If you really don’t know much about Macintosh programming then I suggest that you pick up a book ( Macintosh Programming for Dummies is a great beginning book ) and read through it to get a basic grasp of what’s going on. Then you can look through the AGL ( Apple Graphics Library ) specification to see how to set up an aglContext to use with OpenGL.

Hope that helps some,
–Kainsin

Thanks!
I am using GLUT.
So If you could tell me more about the scaling it would be very helpful,please.
What fuctions to use in specific.

Probably the easiest way to start out is by using gluPerspective.

First enter the projection matrix by calling:

glMatrixMode( GL_PROJECTION );

Then use gluPerspective as follows:

gluPerspective( GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar );

fovy is the field of vision angle in the y direction ( in degrees ), aspect is the ratio of the width and height of the screen ( use screenwidth/screenheight ), zNear is the near clipping plane and zFar is the far clipping plane.

To make sure that you wont miss anything try setting up gluPerspective as such:

gluPerspective( 45, screenwidth/screenheight, .001, 100 );

–Kainsin

I almost forgot, make sure to go back to the model view matrix by calling:

glMatrixMode( GL_MODELVIEW );

–Kainsin

Danger, Will Robinson!

ALWAYS ALWAYS ALWAYS ALWAYS call glLoadIdentity() before defining a projection matrix! I learned that the hard way! If you don’t, everything screws up severely if the code is called a second time.

Just a warning, so no one else wonders why everything suddenly shrinks after they resize their window.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.