Problem clearing video with OpenGL



I’ve been displaying video inside a Juce application using OpenGL using the methods glTexImage2D and glDrawPixels. Everything works fine, but sometimes, I’d like to turn the video display off. So, I cleared the screen using glClear(). I would like to call glClear() only once to save CPU cycles, but when I do so, the screen flickers between a cleared black screen and the last frame of video that was displayed. It’s rather strange. I’m not sure where this last frame of video is coming from. I’m definitely not drawing it. So, it’s being stored somewhere and repainted… Does anyone know where this last video frame is being stored and how I can get rid of it?

I am wondering whether this problem is linked to another odd behavior of this application. When I close the application and reopen it without a camera attached, then it shows the last frame of video from the last time the application ran. Don’t ask me where it’s getting it from. I have no idea… This behavior doesn’t actually bother me, but I do wonder whether it’s the same reason why I’m having this flickering problem.



I had something similar happen on one of my two machines. Both were running Windows XP SP2, but the identical program would cause flicker on my laptop when I called glClear(). Your description of flicker between the cleared screen and the last frame matches exactly what I saw. However, I found that I could clear the screen to black without flicker, but not to any other clolour. So, while this:

glClearColor (1.0f, 1.0f, 1.0f, 1.0f); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

caused flicker, this did not:

glClearColor (0.0f, 0.0f , 0.0f, 1.0f); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

I ended up chalking up the whole issue to an issue in the OpenGL implementation in the video driver. I have a feeling that on the offending machine there is a buggy software implementation of some of the OpenGL primitives. It is definitely using software for some of the commands since the CPU usage is higher than it should be.


Just curious how you were loading your video?

I want to load a few videos in the background then overlay their frames as textures on shapes.
I tried using QuickTimeMovieComponent to load then I’d write to a Graphic which wrote to an Image, but QuickTimeMovieComponent asserted when it realized it wasn’t part of a window.

NeHe has a good example but they rely on a windows based deciver – I’m OS X