Jump to content
  • Advertisement
Sign in to follow this  
MiguelMartin

OpenGL Projection Matrix Question(s).

This topic is 2524 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

Okay I'm am REALLY confused with the Projection matrix and how I set it up, I know how to use it but I just don't understand how you can tell what the coordinate system of your scene are. OK so lets say I setup the Viewing Frustum like so:


glMatrixMode(GL_PROJECTION);
glLoadIdentity();

gluPerspective(60, 640/480, 1, 100);


What Point is the top left of the screen? How do I tell what the maximum value of the frustrum for the top, right, etc.? It's really giving me a head ache. I don't see how to effectively use gluPerspective.

For example: How do I know whether to use really small numbers or really big ones when creating primtives in my scene?

Oh and, seeing as the Viewing Frustrum can move around and such, is the OpenGL entire coordinate system, is there a maximum value you can place on object on the y-axis (or any other axis) e.g. MAX_DOUBLE or something? S:

Is there a way to set up my coordinate system to a Cube with the size of 1000 units. (NOT the viewing frustrum just the coordinate system, or something). Also, is there a way to have a function somewhat similar to gluPerspective and glFrustrum so I can set the length of the sides (i.e. width/height of the frustum) or something (I doubt this is possible, but worth asking).

Sorry that this may seem like a really nooby question but I am EXTREMELY confused (and sorry if some parts made abosolutely no sense at all).

Share this post


Link to post
Share on other sites
Advertisement
I'm not sure how to answer most of your questions, however, a couple of comments: 1) 640/480 probably doesn't do what you want it to do. This does integer division, not floating point division. 2) It sounds like what you really want isn't a perspective view but an orthographic view. For that you'd want to use glOrtho() instead.

Share this post


Link to post
Share on other sites
640/480 as he stated is an int divided by an int, which returns an int (IE not a decimal number) 640.0/480.0 is what you want so that you maintain the decimal point fraction (1.3333).

There is a glFrustum function, but mainly gluPerspective is just perspective projection as we see the world. There is a way to figure out what the left edge of the screen is but you have to remember that inifite # of points will project to a single point on the screen. For now I wouldn't worry about it, just make a scene with perspective and put cubes etc inside of it. Typically you might say that 1 openGL unit is 1 foot, so if you make a cube that you want to represent a book, it might be (.8, 1, .1) in 3D size.

"What Point is the top left of the screen?" You don't really need to know this in 3D, if you want to actually fill the top left pixel, you might want 2D orthographic projection such as glOrtho(0,640, 0, 480).

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!