Advertisement

Question about the origin

Started by January 31, 2001 08:30 AM
2 comments, last by MarcusLM 23 years, 9 months ago
I am new to OpenGL and I am tinkering with some of the Nehe tutorials (Which are excellent, thank you for creating them) and I am noticing that the origin seems to be the dead center of my viewport. What I would like to do is have the origin at the bottom left corner of the viewport. What kind of translation, etc do I use to achieve this? I realize this is probably a ridiculously simple thing to ask, but I am a newbie. Anyway, any help appreciated. Thanks.
The simplest way is to look through the code and where it says:

    glMatrixMode(GL_PROJECTION);	// Select The Projection MatrixglLoadIdentity();	// Reset The Projection Matrix    


add just underneath:

glTranslate3f( 1, 1, 0 );

This will move the camera along a bit and up a bit.....obviously change the numbers until your happy, with where the origin is.


Once you're happy doing that you ought to look at the function, gluLookAt(...) which give much better control of the camera.

dan




Game production:
Good, quick, cheap: Choose two.

Edited by - Danack on January 31, 2001 2:30:12 PM
Game production:Good, quick, cheap: Choose two.
Advertisement
I still can''t this to work. Here is what I am doing up until the point where I want to flip the y axis direction (using Visual Basic):

glMatrixMode mmProjection '' Select The Projection Matrix
glLoadIdentity '' Reset The Projection Matrix

'' Calculate The Aspect Ratio Of The Window
glOrtho 0#, Width, Height, 0#, 0.1, 100#

'' Move Left 1.5 Units And Into The Screen 0.1
glTranslatef 0#, 0#, -0.1

Any ideas??

Marcus
Hiho,
is your game meant to be 2D or 3D ??
To flip around the y-Axis you can try several solutions :

1. glRotate(180,0,1,0); This will rotate in 3D
2. your are using :
glOrtho(0,width,height,0,-z,z) right ? change it to
glOrtho(0,width,0,height,-z,z)

Point 0 is now no longer on the bottom left but
on the top left !!!

This topic is closed to new replies.

Advertisement