Advertisement

Why do i got flickering?

Started by November 19, 1999 10:28 PM
5 comments, last by Pikachu 25 years, 1 month ago
Yo might want to explain a little more about your setup cause there could be a number of things creating this
Hard to say without seeing the code. I recently created a double buffer that used a Window's HDC to print text on the screen. Every time I called "Flip" I could see a bad flicker. I changed the DC to the DirectDraw
GetDC and the flicker went away!

------------------
Still Learning...

Still Learning...
Advertisement
Flickering is usually caused by not using double buffering.

------------------
Dance with me......

I'm using double buffer. I made a simple directdraw class to handle that stuff. Front buffer and back buffering. The only thing I do in the main of my program is drawing the map and move it. I move it just to check to make sure it clips right. The main is this:

ddGame.SetDrawSurface(DDSBACK);
dmMap.DrawMap(ddGame.lpddsBack, 0);
ddGame.SetDrawSurface(DDSPRIMARY);
ddGame.WaitForVSync();
ddGame.Flip(DDSBACK);

dmMap.vTopLeft.X -= inc;
dmMap.vTopLeft.Y -= inc;

if (counter++ == 80) {
inc = -inc;
counter = 0;
}

ddGame is my direcrt draw class, dmMap is my map.

Using VC++ 6.0, Direct 7.0

I think your problem is how you're setting what the program draws to. When using the Flip() function, you never need to draw to the primary surface. You draw to the backbuffer, and then flip, and the pointers to the primary and backbuffer are automatically switched. So the next frame you just draw to the backbuffer again, and flip from either of them, and repeat...

Jonathan

Ok this is probly simple but i can't figure it out. I'm not tackling 3d yet, just working on an isometrics game. I got a map that draws but I'm getting flickering. I use Direct Draw's WaitForVSync but I still notice it. What could cause this?

~ Thanx in advance

Advertisement
Oh, sorry. Little confusion. Let me explain what happen in my class. The set draw surface sets the destination for all the actions, ie flipping by calling ddGame.Flip(DDSBACK); takes the back surface and flips it to the active surface, ie the primary one.

This topic is closed to new replies.

Advertisement