Should OpenGL textures be displayed?

Suppose I load an array of bytes as RGB from a given file.

I read that OpenGL loves storing its textures “in reverse order,” and I saw demos save their images upside down.

So, in my program, should I cancel the loaded byte of the RGB array byte or in turn?

+5
source share
1 answer

This is because the Bitmap format (.bmp) saves it in the reverse order. I am not sure who came up with this, but this is a file format matter. So yes, you must do this if you are using your own .bmp bootloader. You can, however, use the one that has already been written, which has "flipped" the image for you. Again, this is just .bmp. OpenGL works by default in the absence of flipped images.

Here's a little trick: if you don't want to change your .bmp loader, you can tell OpenGL to flip the image for you:

glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glScalef(1.0f, -1.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);

, " ". , OpenGL . , .bmp . . - .bmp.

: .bmp, , OpenGL ( .bmp), OpenGL .

+6

All Articles