#### Archived

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

# 2D plane in OGL

This topic is 6443 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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);
gluPerspective(FOV,w/h,near,far);
glMatrixMode(GL_MODELVIEW);

http://members.xoom.com/myBollux

##### 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 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);
gluOrtho2D(0,w,0,h);
glMatrixMode(GL_MODELVIEW);

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

• 11
• 19
• 12
• 9
• 34
• ### Forum Statistics

• Total Topics
631398
• Total Posts
2999840
×