Hello, I’m trying to draw a buffer to screen using glDrawPixels, but it ends up upside down. I know this is because OpenGL has (0,0) in lower-left corner while my image has (0,0) in top-left corner. So I’ve read some threads here and from what I understand this should solve the problem:
void setup_2d()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, width, 0, height, 0.1, 1);
glPixelZoom(1, -1);
glRasterPos3f(0, height, -0.3);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
// ...
glDrawPixels(width, height, format,
GL_UNSIGNED_BYTE, (void*)buffer);
// ...
However it produces only blackness. Replacing
glPixelZoom(1, -1);
glRasterPos3f(0, height, -0.3);
with:
glPixelZoom(1, 1);
glRasterPos3f(0, 0, -0.3);
produces the image, only upside down (as expected.)
What am I doing wrong?