Archived

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

kill

2D stuff in OGL

Recommended Posts

Here's how I setup 2D for a 2D Pong game I did in OpenGL, which you can actually d/l from http://www.jps.net/mrhino/ .

code:

// set up viewing
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, float(WINDOW_WIDTH), 0.0, float(WINDOW_HEIGHT), -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);

That sets the projection and all that stuff to 2D, and then when you render, you just use the x and y coordinates using glVertex2i(x,y) or whatever your flavor. Hope that helps.

Kevin

Share this post


Link to post
Share on other sites
Gromit-

OpenGL does provide functionality to draw pixels (and hence bitmaps) but you're probably better off using textures to take advantage of OpenGL's features(read hardware acceleration).

This won't be pixel perfect but it can allow you to do cool stuff. Grand Theft Auto (which is basically 2D end though it was 3D) does this nice thing where the overhead view zooms out when you're moving really fast and then in when you're moving slow. GTA II does some really neat stuff where things fly toward the camera. If you started crunching bitmaps for that it'd look pretty ugly.

If you strictly need to use bitmaps though it's probably not the way to go.

Share this post


Link to post
Share on other sites
Hi. I am writing an action puzzle game, and recently I decided to write my graphics in OGL. My game is 2D, but I am using some 3D effects OGL provides. However, I just put everything in 3D space. What do people mean when they say OGL does stuff in 2D? Does it mean u turn of projection? Would someone please explain what this whole thing means, and if possible, how to do it.
Thanx

Share this post


Link to post
Share on other sites