🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
OpenGL question - Simple
I just started openGl programming and I have put a triangle on the screen, but how come when I specify a coordinate of for example,
glVertex3f(1.0,0.0,0.0), it does not move 1 pixel right, it moves a whole bunch, so if i put a coordinate like 5.0,0.0,0.0, that will not show on the screen.
How do i get it to where when I say move 1 pixel right, 1 up, and 1 back , it will do exactly that instead of having to type 0.5,0.5,0.25 for example.
thanks
Well, lucky me. The truth about OpenGL is that it''s resolution independant, if you tell it to be (it basically IS). Usually it''s a safe bet that there''s -1.5 to 1.5 (for values) for the horizontal resolution and -1.0f to 1.0 for the vertical resolution. The reasoning for this is so that if you run your game at 2048x1536, you don''t have eight times bigger viewing area than 320x240. It''s really a great feature, especially if you''re ever going to do a GUI (I just did one, but it''s not complete yet) for a game. Anyways, if you want it to move with bigger numbers, translate it further away.
The problem is that when you draw something just in front of the camera one cord i much more than one pixel try to move the object away from the camera. (Change the Z-value in the cord)
Zredna
Zredna
If the near clipping plane is 3 units wide and 2 units high how Frag_Daddy_ says, you must add 3/xresolution units to the x coordinate to move 1 pixel right and 2/yresolution units to the y coordinate to move 1 pixel up.
GA
GA
its all up to how youve got your projection matrix setup if u want (0,0) to correspond to the lower left and (10,100) is 10 pixels to the right + 100 up.
go
glViewPoint(0,0,winWidth,winHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0,winWidth,0,winHeight);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.375,0.375,0.0);
note this''ll give u only a 2d window, what u want for 2d grafic ega 2d game or a HUD
go
glViewPoint(0,0,winWidth,winHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0,winWidth,0,winHeight);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.375,0.375,0.0);
note this''ll give u only a 2d window, what u want for 2d grafic ega 2d game or a HUD
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement