image tearing


I am experiencing some image tearing/ flicker when I alternate drawing different images.

Meaning odd counts, I draw

img2.draw(170.0f, 109.0f);  

Even Counts, I draw

img2.draw(170.0f, 109.0f);  

openframeworks enable double buffering by default through.


Am I missing something.

try turning on vertical sync.


This makes sure the images are drawn at the correct timing for your monitor.

Tried This

	ofRunApp(new testApp());  

and this

	ofRunApp(new testApp());  

No effect :frowning:

It should be in your testApp::setup function

Nope, still not working.

I tried this on two computers.

Once on a desktop and once on my laptop. In fact it looks more aWefull on the desktop.

Is there anyway I can do this manually, I read something about swapbuffer.

But I am not sure how to use it.

It only happens for PNG images I loaded.

Is this a problem of swapping those images back and forth into buffers or some kind?

There seem to be no flicker when I ran the AdvanceGraphicExample though.

what graphics card / system ?

you may need to check the graphics card control panel and set vertical sync to “application controlled”. graphics card settings for vertical sync override the application setting for vertical sync.

also, code a simple app to show what you are having trouble with and post it. it could be that you are doing something else to cause the tearing. thanks.

take care

Here comes Theo’s brother to the rescue :lol:

I tried NeHe Tutorial 20, it is very smooth.

But of course the difference is the example does not bring the background to the foreground.

Im using a graphic card that is suppose to work in this case. Only thing is it does not support shaders. By the way it does not have this setting…it is just a Intel graphic accelerator. (model no in a previous post) Does this mean Im out of options in this case?

What kind of graphic card are you using? In case I need to shop for one…at least I know it is gonna work if I use openFrameworks.

Here comes Theo’s brother to the rescue


all graphics cards work with OF if they support opengl.

if you are having an issue with a certain code, then please post it as requested above. otherwise we will have trouble to help you.


What size are your images?

If it is an intel graphics card that means it doesn’t have any graphics memory and so shares with the computer - large images 60 times a second could cause the tearing you a describing as the graphics card struggles to get the data from your regular memory.

thats just a guess but let me know the dimensions and post your code and it will be easier to understand what is going on.


Actually, it is just a normal piece of code.

I use two 200 X 500 PNG image to test out

//in testApp.h  
	ofImage img1;  
	ofImage img2;  
void testApp::setup(){	   
	counter = 0;  
	bSmooth = false;  
	ofSetWindowTitle("graphics example");  
void testApp::draw(){  
	if (a==0)  
		img1.draw(170.0f, 109.0f);  
		a = a+1;  
		img2.draw(170.0f, 109.0f);  

Well that would most certainly flicker, but you say you are getting tearing, yes ?
Does it happen if you run the app in fullscreen as well ?

Tearing looks a bit like this:

only usually only one “split” so to speak.

Sorry if this is super obvious stuff, just trying to make sure we are all on the same page!


Hi Hahakid :lol:

Its a flicker. Tearing looks very serious from your photo. Just reposted, yes it happens in full screen too.
Do you happen to know any workaround?

can you post a whole zip - src code and data folder? especially the pngs…

your code is alternating between two images, which would obviously flicker.

ie, you are drawing one image one frame and the second image the second frame. is there something else that’s happening that’s problematic?


Hi there!

Ok, I haven’t tried you code there, but from looking at it I see you are drawing one image or the other every frame.

Depending what is on those images that would normally flicker no ?

Especially if they are pretty different from each other.

I don’t think I’m understanding the problem.

You mention the Nehe 20 tutorial, but that has to do with masking. And as far as I remember he is animating the background (can’t check it now ).


It is the only example where Images are loaded and Rendered onto Textures…I think. Similar case I am facing here…except for the alternating images part.

Maybe the sleep command is messing with the graphics timing.
Try changing the code to this (make sure vertical sync is on):

   int numFramesPer = 30;  
   if(a >= numFramesPer * 2) a=0;   
   if (a < numFramesPer) {   
      img1.draw(170.0f, 109.0f);   
   else if(a >= numFramesPer){   
      img2.draw(170.0f, 109.0f);   
    a = a+1;  

:lol: Ha ha ha…funny

It has become more like tearing. Sigh…

If I were to write my own sync function, hmmm…how abouts to do it man?

I also tried slower ones like 2 seconds…unfortunately the flicker is still there.

Hey armage

I just tested the code with two images 600 by 600 pixels png.

I tried switching the images every second,
then 5 times a second
then 30 times a second

I don’t see any tearing at all. So I would guess it would be to do with your graphics card not openFrameworks.

In general we recommend NVIDIA based cards.
Then ATI which tend not to like openGL as much.
Intel graphics are at the bottom as their 3D support is pretty terrible.

could you possibly:

(a) post the whole code and data folder as a zip as requested in this thread

(b) shoot a short video to document the problems you are having

I have an intel integrated graphics card and can’t see the problem. I strongly believe your problem is code related or some sort of optical illusion.

we’re are all trying to help here but we need you to better document the issues you are having – otherwise, we wont be able to help you.

take care,