It can work very fast wit OpenGL if you have a 3D card.
If you don’t then OpenGL is emulated by a library in Windows and it’s extremely slow. Making better implementation of this library would be gently speaking, agains Microsoft’s policy.
Ok, some thoughts:
OpenGL is not an image display library. It’s meant for rendering.
glDrawPixels actually transfers image data to GPU which is costly. It may even happen that passing image as texture using glTexSubImage2D and then drawing a GL_QUAD covered with this texture would be faster.
You’ll certainly get very high framerates, even on old hardware if you could pass all images as textures to graphics card and then just display them directly from card. There is of course memory limit so that’s suitable for short animations.
You can also use texture compression if you choose to use textres
-load image from BMP and pass to GPU using glTexSubImage2D - choose compressed format of the texture (assuming you created this image earlier with glTexImage2D).
-use glGetCompressedTexImage to get compressed version of texture back to CPU - store it in system memory
-repeat for all images
Now you have a set of compressed textures in system memory - you can pass them directly to GPU prior to displaying them. Compressed image means less data to transfer and thus even higher framerate.
Before many years I used this function to display bitmap:
SetDIBitsToDevice (hdc, x, y, width, height, 0, 0, 0, height, data, &bi, DIB_RGB_COLORS);
where “bi” is BITMAPINFO structure and data is pointer to RGB array. But this is really not OpenGL.
OK, now I am getting around 80 FPS, Both with SDL and opengl, thanks
But there is a very visible and very annoying flicker. I tried playing with vsync setting in control panel and I am using SwapBuffers to update display so am assuming that double buffering must be enabled. But the flicker doesn’t goes away.
How do I fix this for OpenGL? How do I check if double-buffering is enabled and is getting used? How do I enable/check vsync from within my program?
I tried to use glXSwapIntervalSGI(1); in my program, but linker couldn’t find it’s implementation. Is there anything need to be done (aside from including <GL/glx.h> and defining GLX_GLXEXT_PROTOTYPES) to make it work? AFAIK, glX functions implemented in libGL, which is linked to project. “GLX_SGI_swap_control” is not among listed extensions. May that be the cause?
Originally posted by Gremour: I tried to use glXSwapIntervalSGI(1); in my program, but linker couldn’t find it’s implementation. Is there anything need to be done (aside from including <GL/glx.h> and defining GLX_GLXEXT_PROTOTYPES) to make it work? AFAIK, glX functions implemented in libGL, which is linked to project. “GLX_SGI_swap_control” is not among listed extensions. May that be the cause?
You mean “glxext.h”, right? GLX_SGI_swap_control should be listed under the client glx extensions if it is supported. If not, try to use GLX_MESA_swap_control instead.