Dirty Rectangles with Surface Flipping
 
 
black eyez  

I feel pretty dumb right now :P I can't seem to figure out how to do dirty rectangles when using surface flipping... I have it workin perfectly in windowed mode, but because of the flipping in fullscreen, I get the black backbuffer flickering in there...

Any ideas?

david goodlad
  - aka black eyez
    webmaster: the black hole



 
MetalWarrior  

Now you've got me feeling dumb =)

Exactly what's a dirty rectangle?



 
Eric Coleman  

What do you mean by the "black backbuffer flickering?"



 
black eyez  

Okay erm  

K, firstly, dirty rectangles is where you only redraw/update the part of the screen that has been changed each frame, instead of redrawing the entire screen. This allows for large speed increases...

And basically the problem is that in fullscreen mode, the backbuffer/primary surface switch each frame, so there is no simple way to implement it that I've been able to find... So the flickering occurs when the backbuffer is empty/black and it flips onto the primary surface. 
 

david goodlad
  - aka black eyez
    webmaster: the black hole



 
MetalWarrior  

Okay, um... so why not just do that with the backbuffer, but use a flip as normal to the primary surface? For instance, the backbuffer won't clear itself between blts, so just only blt to the backbuffer what's changed.

Either that or use Blt onto the primary surface, even in fullscreen mode.



 
Voodoo VB  

I'm not sure this is what you need, but there is a smart refresh a.k.a dirty rectangles tutorial on the site.

Peter



 
Necronite  

We have 'Dirty Rectangles' (I call it smart refresh  ) in our game. The way we had to do it, unfortunately, is to create a screen sized surface (we called it MainSurf) which is blitted onto the backbuffer each frame. Otherwise you get the problem that you update the backbuffer, only too have it flipped too the foreground, and then the current backbuffer hasn't been updated.

Just blit the whole MainSurf onto the backbuffer before you flip each frame. This is slower than using the backbuffer direct (which I still think is impossible), but once smart redraw is implemented we still achieved a 400% fps increase.. Which I was pretty happy with  



 
black eyez  

I'm glad SOMEBODY understands what I'm saying here  Thanks necronite, that was one of the things that I thought of, but didn't think it would give me much of a speed increase! hehehe

Thanks
 

david goodlad
  - aka black eyez
    webmaster: the black hole



 
Eric Coleman  

There are two ways to handel fullscreen mode. One is with page flipping, which you're doing, and the other is to have a seperate surface which with to blit stuff to.

If you want to use page flipping, you must draw on the backbuffer, not the primary surface. And when you draw on the backbuffer, you must draw on it as though its two frames old, (which it is.)

You could also create two seperate surfaces, instead of a single surface with a backbuffer.

If you have two surfaces, you'll have to bitblt, instead of flip, your working surface to the primary surface after you're done drawing on it. If you use this method, I think you'll be able to use the same code that you use for window mode.


MetalWarrior  

Yeah, that's kinda what I meant by just Blt even in fullscreen...