Painting Event - getting rid off - but error

LDV

Active member
Joined
Dec 29, 2003
Messages
31
Hi,

The problem is, that after i draw my stuff on the device using Direct3D, the painting even in Window Mode, repaint the Form on my Drawings....I found a few solutions, each one have its own disadvantages:

1. overriding the paint event:
protected override void WndProc(ref Message m)
(if anyone interested i can show how its done)
but then when i try some Surface StrechRectangle things, it dosen;t draw them for me on the screen.

2. I tried to use:
this.SetStyle(ControlStyles.UserPaint, true);
or
this.SetStyle(ControlStyles.AllPaitningInWmPaint, true);
or both of them together.
but then i get the screen to flicker much, or the problem is not solved.

Any ideas?

I dont want to have a loop the redraws again the whole buffer all the time.

Thanks, Leonardo
 
The SetStyle commands only work if you use Form_Paint. You shouldnt enable the SetStyles for Direct3D, Direct3D does not use GDI+ so GDI+ commands will only muck it up, you should draw in the paint event or use a loop. If Direct3D is flickering, how many backbuffers do you have? If you dont have any it will have a flicker frenzy if you draw anything more than a Clear command.
 
Hi Andre,

Thats exactly the funny thing ! - Im using DirectX3D in a loop, but when i override the PAINT event, the Direct3D draws nothing !

How come?

The problem im also having is that the PAINT even draws the screen just after i draws it with direct3D, and thats the reason i wanted to cancel it.

Thankd, LDV
 
I dont usually have any difficulty with rendering in loops or paint events, it may have something to do with your method, can you show the Paint event code?

Usually you structure the loop as:
Code:
Start Loop
Device.clear
Device.BeginScene
DrawPrimitives/Meshes/etc
Device.EndScene
Device.Present

Application.DoEvents
End Loop
Your code should be structured like this but Ill need to see a relevant sample to figure out whats going on, the devices creation parameters may also be useful.
 
Back
Top