Sign in to follow this  

Rendering in a CLR Windows Forms application

This topic is 3594 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there, I'm trying to use DirectX in a CLR C++ Windows Forms Application, but I've got one big of a problem: where to put the rendering loop. In a basic Win32 C++ program no problem, you add it to the message loop. In a C# Managed DirectX program, it's quite interesting to see how it works: in the main function you've got: using (Form1 frm = new Form1()) { while(frm.Created) { frm.Render(); Application.DoEvents(); } } And in a C++ CLR program, I don't have a clue. Your form is created as this: Application::Run(gcnew Form1()); But that's it. So what I'm doing right now is that I'm initializing all the DirectX in the Form_Load method and then launch a thread which is basically while(1) Render();. Although it's working, I'm wondering if there's a way to do it in a "cleaner" manner. Thank you.

Share this post


Link to post
Share on other sites
I personally use Tom Miller's OnApplicationIdle loop, and you should be able to easily invoke the same loop from C++/CLI. I'd recommend against rendering in a seperate thread - depending on which version of DirectX you're using, it might not be supported. There are also other limitation on when you can call Direct3D methods from other threads, so avoiding having to sync the extra thread might save you quite a bit of work.

Share this post


Link to post
Share on other sites

This topic is 3594 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this