• Advertisement
Sign in to follow this  

Rendering in C# .NET

This topic is 3957 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

Hello, í´m trying to write a simple level editor in C#. I use Direct3D for rendering. I looked at a lot of examples for Direct3D in C#, and i noticed, that the rendering code is always called from Paint events. This is strange for me, since i used to program in raw C++ before, and therefore called my rendering stuff from the main loop, when no events are pending, and not in response to any events. Can i also use such an "idle event" to do my rendering stuff in .NET? thanks Gamma_strahler

Share this post


Link to post
Share on other sites
Advertisement
You can do this. The main loop in my application was like this:


[STAThread]
static void Main()
{
Application.EnableVisualstyles();

Application.SetCompatibleTextRenderingDefault(false);
// Instantiate the form
MainForm form = new MainForm();


using (form)
{
form.Show();

// Main loop
while (form.Created)
{
form.Render();
Application.DoEvents();
}
}
}


This was a basic shader editor i was working on and it had a live preview window.

form.render() called my renderers render() function in turn.

Share this post


Link to post
Share on other sites
This old thread here describes the managed version of the OnIdle loop. Dave's loop should work just fine as well though, both *should* be more efficient than using OnPaints since they don't generate events to drive the loop. ZMan did some more research on the performance of various loops, but I can't find the exact outcome atm.

Hope this helps :)

Share this post


Link to post
Share on other sites
Using the previously mentioned OnIdle event has always worked for me, and is what the DXMUT samples use.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement