Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / Forcing OnPaint each program loop (using wxGLCanvas

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Forcing OnPaint each program loop (using wxGLCanvas
#3288
Posted by: 2004-01-31 08:48:25
I'm working on a crossplatform project (windows and linux) that makes use of OpenGL.

The problem I'm having is that in every example I've seen using wxWindows and OpenGL, the rendering calls are only made with user input.  That is, the Refresh function is called when the user rotates the camera for example.

However, the more standard way is for the window to be repainted EVERY program loop (ie every turn of MainLoop in wxApp).

I'd rather not use a timer, as I would like lower end systems to run this, and they may not be able to draw the screen in the time interval used.  Instead I'm just using a deltatime I calculate each frame.

I've tried overriding MainLoop and inserting a call to refresh the wxGLCanvas, but no dice.

I've tried looking for some sort of wxApp.DoEvents, but again no dice.  (This is found in many languages, and makes the OS check for any pending messages before making the next render).

Anyone succeeded in doing this?
Message2. Re: Forcing OnPaint each program loop (using wxGLCanvas
#3293
Posted by: upCASE 2004-02-01 01:46:24
Hi!
There was a posting on the mailing list recently that covered this topic. The advice given there was using the idle events. I tried it with timers before, but it seems that using idle events it works pretty well.
Use a OnPaint method and do all the drawing there. Use EVT_IDLE() and call a method that simply does a this->Refresh();

upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message3. Re: Forcing OnPaint each program loop (using wxGLCanvas
#3297
Posted by: 2004-02-01 05:56:26
That works beautifully, thanks!

Consider myself to be a fairly intermediate level programmer, but new to wxWindows: lots to learn :)
Message4. Re: Forcing OnPaint each program loop (using wxGLCanvas
#3298
Posted by: guidance 2004-02-01 12:43:16
wxTheApp->Yield() or wxSafeYield() could be the equivalence of DoEvents in VB etc.
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2022-12-9  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0