• Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

We're also offering banner ads on our site from just \$5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.

# Projection Matrix Question(s).

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

2 replies to this topic

### #1miguelishawt  Members   -  Reputation: 100

Like
0Likes
Like

Posted 14 January 2012 - 09:06 AM

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);

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).

### #2SiCrane  Moderators   -  Reputation: 9626

Like
0Likes
Like

Posted 14 January 2012 - 09:22 AM

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.

### #3dpadam450  Members   -  Reputation: 932

Like
0Likes
Like

Posted 17 January 2012 - 01:58 AM

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).

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS