Managed DirectX in C# Forms - differences between SDK

Hi - this is a repost since my previous html one was garbaged... anyway

I've been trying to embed DirectX controls into a C# winforms application. However, there seems to be a major problem getting all the forms controls to paint... I thought it was something I was doing wrong, but then tried using the old Summer 2003 API and it all worked fine

Basically, I create a UserControl that handles all my rendering code, then add that to a forms application, which in turn sets up rendering flags and so forthAs an illustration, here's two screenshots (I tried using the img tag but it seems that the forum block it )

http://www.benwalkermusic.co.uk/images/workingSummer03.JPG

Summer 2003 - Working

http://www.benwalkermusic.co.uk/images/notworkingAug05.JPG

August 2005 - Where did the controls go

Same code, same layout, different SDK and obviously subtle code changes for Lights.Update instead of Commit but other than that, the two should be identical...

Help!! My Code is in C# 1.0 - not yet supporting .NET2.0, and MDX9.0c Aug 05 SDK, and I really don't particularly fancy porting all the project to an older SDK since all the lighting, renderstate, shader and CustomVertex methods are different.

thanks in advance

benw


Answer this question

Managed DirectX in C# Forms - differences between SDK

  • pleenaers

    What renderloop are you using Maybe the rest of the form is never getting painted Do you allow other windows messages to be processed Sure there were changes from Summer 03 to Aug05 but nothing I can think of that would affect things outside the directx device.

    I have a project using February SDK that does just what you are trying to do so there is no general problem.

    Are you using the DirectX framework code



  • Tyler Miller

    So do you actively call the UserControl_OnPaint when you need to render, or is there an OnIdle hook or a timer calling it, or do you Invalidate at the bottom of each OnPaint

    What happens if you add an OnPaint for one of the controls which isn't being drawn. Does it ever get called



  • Murali T N

    I'll hyperlink the sources:

    The main form is Form1

    The UserControl is UserControl1.cs

    The UserControl painting code is simply a protected override OnPaint method. To force the control to redraw, there is a this.Invalidate() call at the end of the rendering loop. Removing this allows the other controls on the main form to be drawn, but only ever renders the 3D scene once despite the OnPaint method being called once per cycle.

    Incidentally I tried the OnIdle hook method, and although that seems better it only ever draws when I'm moving the mouse over the Form.

  • wilson george

    The third parameter of Device's contructor should be the form instead of the control itself. Then pass the control in the PresentationParameters or Device.Present().

    Maybe that's the issue.


  • Dalli

    My renderloop is an override of the UserControl OnPaint event. The device is created through an override of OnCreateControl, and there are some flags in there to stop rendering whilst I'm working in the designer view or using other popups from the main form.


    The parent form has no concept of anything other than the fact that a UserControl has been added.

    "Are you using the DirectX framework code "

    I'm doing everything outside of the sample framework - so to create a device I call Device dev = new Device(...) inside the user control. I can post sources if required - there's nothing particularly clever going on, it was a tester for a standalone graphing application but didn't get any further than creating a device on a custom control and adding some potential property editors to a hosting form.

  • Managed DirectX in C# Forms - differences between SDK