Jump to content
  • Advertisement
Sign in to follow this  
tonypr

Rendering in a CLR Windows Forms application

This topic is 3905 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!