y coordinate flipped opposite of windows for a good reason?

Right now I’m working on a game and we have the coordinates flipped so that they are from the upper-left corner instead of opengl’s lower-left.

Right now I have a Ken sprite from Street Fighter 2 walking accross the board with all of the animated sprites of him walking from the game. The problem I’m having (I assume because the coords are flipped) is that Ken does a little hop when he walks and also crouches down a little and that causes walking to look un-natural because his feet go below the level plane.

If I were to draw with Opengl’s default coordinate system, would that solve this issue? In other words, would I draw from y from the bottom of the sprite rather than the top?

You can download the source and binary here:
to see exactly what I’m talking about.

Should I clarify more?

I believe that the way (bottom-left origin in 2D) is the simplest and effortless method in order to switch between 3D and 2D. You don’t need a specific coordinates system or matrix for only 2D. These are shared on both 2D and 3D, and z-coords are simply set to 0 for 2D.

How did you flip the orientation? Did you use glPixelZoom(1,-1)? You can draw an image from top to bottom with this function, but you have to set the raster position to the top of the image.

All I did was switch around the glOrtho top and bottom coords and everything works just as I expected. Thanks!

//glOrtho params are: left right bottom top
//I have them switched to make origin bottom-left:
glOrtho(left, right, top, bottom, 0, 1);
//rather than upper-left:
glOrtho(left, right, bottom, top, 0, 1);

Is this the wrong way to flip coordinates? Because everything is severely messed up when the origin is at the bottom-left for some graphics cards (ATI I think). On most it seems to work fine though.

What is the correct way to flip coordinates?

Anyone know?

Leave the projection matrix as it is, and try to modify the modelview matrix instead. In order to flip Y-axis, use the following for viewing matrix;

[1  0  0  0]
[0 -1  0  0]
[0  0  1  0]
[0  0  0  1]

The second row, (0,-1,0,0) means that the up vector is now pointing to negative Y-axis, so the Y value of a vertex will be flipped (negated). However, if you are using glDrawPixels() to draw 2D images, use glPixelZoom() as I mentioned earlier.

I’ve been looking online for what function(s) to call to set the viewing matrix. All I can come up with is gluLookAt. But it only takes 9 parameters. The example above takes 16.

How do I do that?

It’s a matrix, you have to put it in glMultMatrix (or glLoadMatrix).

But for this particular matrix, you can also use glScalef(1.0, -1.0, 1.0);