How can I load 8 bit bmp with OpenGL?

╄→гoц情女王★ 提交于 2019-12-01 13:52:39

You should not use glDrawPixels, it is deprecated functionality. The best way to do it would probably be drawing a screen-sized quad (-1,-1 => 1,1 without any matrix transform) that you texture with these images.

For the textures you can specify several internal formats in glTexImage2D and similar functions. For example, you could use the GL_R3_G3_B2​ format to get your 8-bit size, but could as well use the compressed formats like S3TC. You could for example pass COMPRESSED_SRGB_S3TC_DXT1_EXT, which should reduce your image size to 4 bits per pixel, likely at better quality than the 8 bit format. You cannot use JPEG as a compression format in OpenGL (it's too complex).

Finally, why do you want to do this through OpenGL? blitting an image to a regular window will likely give you well enough performance. Then you could even store your image sequence as video and just blit the decoded frames. It's very unlikely you will ever get memory problems in this case.

Maybe you don't need to have 2000 images and display them at 60fps at all? Stable 25fps is just enough for any movie.

I encourage you to rethink your original problem and come up with a better suited solution (video, animation, vectors, maybe something else)

As for original question:

If you need images only once - put them to memory when you need them and discard them right after displaying.

Use DXT packed images. With a slight degrade in quality you get a constant x4/x8 compression ratio.

OpenGL is not very good at working with paletted textures these days (many vendors have poor implementations). But you can implement that with shaders.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!