Jump to content
  • Advertisement
Sign in to follow this  

Setting up a message loop for CAD system

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

This may be a stupid question but I've search my little butt off and can't find anything about it. I know in a game loop you want continuous rendering because there's usually action happening but in a cad (computer aided design) system, there's no need for that, right? You really only need to redraw the window when the user moves the camera or modifies the content. 

 

Maybe I'm over-thinking it and I should just do it the game way. I figured I could save some CPU cycles if it wasn't trying to constantly render.

 

Has anyone programmed a CAD application and, if so, how did you set up your message loop?

Share this post


Link to post
Share on other sites
Advertisement

A CAD application is a typical desktop application. As such it is driven by events for which a loop is waiting, inclusively sleeping if no events are pending.

 


Maybe I'm over-thinking it and I should just do it the game way.

Nope! Do it the correct way and use the system's typical event loop. One don't wants a CAD application to take over the machine, so that other tasks are slowed down up to be unusable. One don't wants the graphics card to be heating for nothing. One don't wants to hear the fans annoying noise for no reason.

 

Comparing an application's event loop with a game loop, then the game loop is "over-thinking" w.r.t. the needs for CAD. The event loop is implemented and used a trillion times and works well.

 


... how did you set up your message loop?

Although more or less the same on each platform, the details depend just on the platform specifics. In general: Sleep until events are pending, fetch the events, handle them. That's all.

Share this post


Link to post
Share on other sites

I would just use existing UI stuff like wxWidgets, QT etc. Then you can put an OpenGL/DirectX context in a window to do whatever you need there, and have event loops, window layout, and a list of basic and advanced UI controls readily available.

 

 

Don't know about QT, but for wxWidgets there is a built in wxGLCanvas and wxGLContext. See http://www.wxwidgets.org/docs/tutorials/opengl.htm and http://docs.wxwidgets.org/trunk/classwx_g_l_canvas.html .

 

You can also easily tell it to repaint a specific window (usually for custom controls as a result of input, you could also do it when running an animation) which will then you your custom rendering code.

Edited by SyncViews

Share this post


Link to post
Share on other sites

Basicly, rather than rendering in the message loop, put your rendering in the WM_PAINT handler of the window. The it will be redrawn when windows needs it too, and you can also invalidate the client rectangle when your user edits the cad model, causing the window to be rendered

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!