I am trying to display image files seamlessly and without any effects. I am using code from this OpenGL Tutorial.
The image comes in two pieces (Two Triangles) one triangle fills and another starts to fill the rest of the slot. I have images which I need to display them one after another quickly without distraction.
Anyone has any ideas what should I change in this code?
Thanks in advance.
So, what is your problem?
Sorry not to be more descriptive.
I am displaying images every 100msec (10 frame/sec) and when each image is loading it comes in two triangles instead of coming in one quad shape and it is sort of slow and distracting. Which part of the code should I move to Init section? How can I get rid of this effect in
This Sample Tutorial ?
You can try double buffering.
Replace GLUT_SINGLE with GLUT_DOUBLE as argument to glutInitDisplayMode and replace glFlush() with glutSwapBuffers() in the display function.
Thanks Nico you are a star! It worked …
One more question: there are some black images which I don’t want to display do you know how I can check if an image is black?
Maybe, you can generate mipmaps for all pictures and check if the last mipmap level is a black pixel. If your pictures dimension are not power of two, you can render the picture in a power of two texture using a fbo and then generate mipmap…
I don’t know if it is a good solution, it is just a suggestion.
Notice that you will need bilinear filtering to make it work with this method.
The Image Dimensions are 320x240. How should I check the mipmap level is a black pixel? Any recommended tutorials?
Thanks for the Reply.
http://www.sdltutorials.com if you get it to work please let me know as i am having compile problems
I have never tried myself that, but what I suggest you is to load your images in texture rectangle since your pictures are rectangles. You can do that with the extension GL_ARB_texture_rectangle.
But you can’t generate mipmap levels with a texture rectangle since mipmaping divide texture size by 2 until a one pixel sized texture.
So what you can do is to use framebuffer object to render this texture to another which size is a power of 2 (you will need another extension: GL_EXT_framebuffer_object). And finally you can generate mipmaps, render it on the framebuffer which size is 1x1 and call the glReadPixels function to read pixel on the screen. I know it is a very long shot and I assume there some libraries more specialized on this kind of computations…
You can find more information here:
tutorial on rendering to texture with fbo: