I'm making a text renderer that uses FreeType 2 and legacy OpenGL. Problem is, FreeType 2's coordinate system has (0, 0) in the top left corner while OpenGL's coordinate system is Cartesian. This means I have to flip the bitmap. I expected glScalef to work with glBitmap but it has no effect. Can anyone tell me if it's possible to flip a bitmap vertically with glScalef, or if it is not possible, point me to some other source that can flip a bitmap upside down (Preferably efficiently as possible)?
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glScalef(1.0, -1.0, 1.0)
glBitmap(size_x, size_y, 0, 0, xadd, yadd, (GLubyte *) bitmap);
The function you are looking for is glPixelZoom
.
Pixel zoom factors are not limited to positive values. Negative zoom factors reflect the resulting image about the current raster position.
It definitely will have the desired effect on glDrawPixels
. There's a note in glBitmap
saying that it acts like glDrawPixels
but I cannot find any explicit statement on whether glPixelZoom
applies to glBitmap
or not, so YMMV.