Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm using DirectX 9 via SlimDX (C#). My screen flickers a lot during rendering. I dug a little deeper and see that the surface is being cleared early. Here's an example: http://pastebin.com/HXyAUwLp.

I'm using Windows XP on a low-end card. I've seen it act correctly on this computer, but I obviously have something wrong with my drawing routines or something and have reached the end of my resources.

The draw method starts at line 135 in that paste. To make the action more apparent, make sure the code in one or more of the preprocessor directives executes.

This shows that the buffer is being cleared before Present. I think things are supposed to work such that one scene to be visible until after Present, after which, the next scene is present. The user should never see the Cleared surface.

Let me know if you need more information.

share|improve this question
    
i'm no dx expert, but i'm guessing it must be becouse you dont use double buffering. –  Toni Apr 27 '12 at 14:46
    
Le pardon, but why are there 500-700ms Sleep calls in the code that have on/off switches? –  bobobobo Apr 27 '12 at 15:01
    
@Toni Line 109 specified one back buffer. (Changing to 2 doesn't help.) –  Limited Atonement Apr 27 '12 at 15:04
    
@bobobobo I explained it in my question. It makes the problem more apparent. When sleeping before or after present, you see that during the sleep, the surface is black (which is, to the best of my knowledge, incorrect behaviour). –  Limited Atonement Apr 27 '12 at 15:05
    
I think it might have to do with the .net form's buffer settings. I believe you have to set it to double buffering also. –  Toni Apr 27 '12 at 15:13

2 Answers 2

The answer doesn't have to do with DoubleBuffered, but rather with the default behaviour of System.Windows.Forms.Forms, which paint their own background when they need to paint. The answer is to add an override in the form:

protected override void OnPaintBackground(PaintEventArgs e)
{ }

Which fixes the problem.

share|improve this answer
1  
i stand corrected –  Toni Apr 27 '12 at 16:02

Something to do with the .net controls not having doublebuffering enabled by default and the default redraw functionality.. There should be some ways to go around that.

Using slimdx's RenderForm instead of .net's Form works as you yourself noticed in above commentary.

share|improve this answer
    
Thanks for the help. Did you run the example? –  Limited Atonement Apr 27 '12 at 15:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.