Archived

This topic is now archived and is closed to further replies.

archon

2D plane in OGL

Recommended Posts

Hello, I''m trying to create a 2D playing field for a space hockey game with a grid on it and I want position a camera for players points of view and have the grid stretch out in 3D perspective, and use the changing perspective as the camera moves to simulate motion, only I don''t know how to do this in OpenGL(not that I know how to do it at all), any suggestions?

Share this post


Link to post
Share on other sites
position the camera over the playing field looking straight down

change the fov IN THE FOLLOWING piece of code to simulate a zoomin/out with the camera

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(FOV,w/h,near,far);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();


http://members.xoom.com/myBollux

Share this post


Link to post
Share on other sites
Thanks!
One more question I have is, how do you draw a 2D plane in the first place? Do you draw a rectangle with a very small width and then rotate it to be flat and stretching out? Would it be better to draw a number of rectangles bounded by a world rectangle or a single rectangle with a grid texture mapped to the surface?

Thanks again...

Share this post


Link to post
Share on other sites
this''ll draw a quad that''ll cover the whole screen using a 2d viewmatrix
if u wanna do the same thing in 3d its called billboarding

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0,w,0,h);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glBegin(GL_QUADS);
glTexCoord2f(0,0); glVertex2f(0,0);
glTexCoord2f(1,0); glVertex2f(w,0);
glTexCoord2f(1,1); glVertex2f(w,h);
glTexCoord2f(0,1); glVertex2f(0,h);
glEnd();

http://members.xoom.com/myBollux

Share this post


Link to post
Share on other sites