setting up an (actual) 2d projection

Hello, I am a hobbyist programmer who uses CodeBlocks and MingW32 on Windows XP. I am wondering where I could go to find out how to set up a 2d OpenGL context. This works fine for me:

if (h <= 0)
{
    h = 1;
}

glViewport(0, 0, (GLsizei)w, (GLsizei)h);

glMatrixMode(GL_PROJECTION); 
glLoadIdentity();

gluPerspective(60.0f, float(w) / float(h), 1.0f, 100.0f); 

//gluOrtho2D() would go here instead of gluPerspective,
//jah?

glMatrixMode(GL_MODELVIEW); 
glLoadIdentity();

followed by:

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

gluLookAt(0.0, 0.0, 1.74,
          0.0, 0.0, 0.0,
          0.0, 1.0, 0.0);

However, I’ve read elsewhere that setting up a 2D context can increase speed, and I’m thinking about experimenting with some 2D animation to see how much faster it is than SDL_BlitSurface() type animation. So…what gives? As in, where do I go to see a 2D setup or how would I modify the code above? Also, can I keep using glVertex2f() functions for drawing in a 2D context or would I have to get into glVertex2d()? It doesn’t seem like it, considering the “2” should be the operative point there. Thx in advance for any responses! -B

OpenGL does not care the slightest bit whether you use gluPerspective or gluOrtho2D.

In the end, it will be the same, a 4x4 matrix multiplication.
In theory sending 2 float coordinates instead of 3 might be faster, but using immediate mode (glBegin etc) is totally useless for anything caring about performance.

Using opengl would do hardware blitting opposed to sdl which would do software blitting. Use gluortho to set a 2d projection and don’t use glulookat unless you want a isometric looking display.

thx for the info

thx for the info, I set up glOrtho or gluOrtho2D and now I’ve got 640x480 instead of 639x479.

Thanks for that information about glBegin, etc.; I’ve found by experience recently with some online tutorial code, that OpenGL animation is only faster if you don’t use that immediate mode, otherwise it’s SLOWER compared to SDL_BlitSurface!