Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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 it's own disadvantages:

 

1. overriding the paint event:

protected override void WndProc(ref Message m)

(if anyone interested i can show how it's 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 don't want to have a loop the redraws again the whole buffer all the time.

 

Thanks, Leonardo

Posted
The SetStyle commands only work if you use Form_Paint. You shouldn't 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 don't have any it will have a flicker frenzy if you draw anything more than a Clear command.
.Net allows software to be written for any version of Windows and not break like Unmanaged applications unless using Unmanaged procedures like APIs. If your program uses large amounts of memory but releases it when something else needs it, then what's the problem?
Posted

Hi Andre,

 

That's exactly the funny thing ! - I'm using DirectX3D in a loop, but when i override the PAINT event, the Direct3D draws nothing !

 

How come?

 

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

 

Thankd, LDV

Posted

I don't 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:

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 I'll need to see a relevant sample to figure out what's going on, the device's creation parameters may also be useful.

.Net allows software to be written for any version of Windows and not break like Unmanaged applications unless using Unmanaged procedures like APIs. If your program uses large amounts of memory but releases it when something else needs it, then what's the problem?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...