Advertisement

Units in Ogl

Started by January 30, 2005 04:37 PM
1 comment, last by iddqd42 19 years, 10 months ago
The one thing that keeps me from start using Ogl is that i cant seem to understand how the units work... im using the latest version of nehe basecode and i was thing about making a small tetris game (really small and simple...) and i figured since the width is 10 squares wide, it would be nice having the "board" 10.0f large... the thing is that it is really huge and need to "zoom out" a great deal to see it... how can decrease(and increase for that matter) the size of unit, the game will be running at 800x600 so having one unit to be equal to ~25 pixels would be great (my "board" is 18 units high)... glViewport (0, 0, (GLsizei)(width), (GLsizei)(height)); glMatrixMode (GL_PROJECTION); glLoadIdentity (); gluPerspective (45.0f, (GLfloat)(width)/(GLfloat)(height), 1.0f, 100.0f); is that where i am doing something wrong? well, thanks for reading ;) // iddqd^
The more you know, the more you know that you dont know.
You using a 3D prospective. What you really want is an othographic projection so use glOtho() instead of gluPerspective().

void glOrtho(
GLdouble left,
GLdouble right,
GLdouble bottom,
GLdouble top,
GLdouble near,
GLdouble far
);

so for a 10X10 window you would do

glOrtho(0,10,0,10,-1,1);

(you need to adjust near and far as appropriate).

Dan
Advertisement
Thanks a lot dan, that worked smootly! =)
The more you know, the more you know that you dont know.

This topic is closed to new replies.

Advertisement