wxMac - continuous rotation of graphics
Stefan Csomor
csomor at advancedconcepts.ch
Wed Sep 20 21:09:09 PDT 2006
Hi Eric
it might be that the wxYield is using up more resources than necessary,
you might test this by callind wxYield only every nth iteration and
using a Update() call on the window the other times.
But this setup is going to get slower on newer versions of OSX anyway,
as there redraws will ge synchronized with the vertical refresh, so
redrawing faster than half of the rate eg 30 times per second is not
recommended as it would lead to contention on the graphics pipieline.
What is you current rate through this loop per second ?
BEst,
Stefan
_____
From: Eric Dowty [mailto:edowty at shapesoftware.com]
Sent: Mittwoch, 20. September 2006 22:18
To: wx-users at lists.wxwidgets.org
Subject: wxMac - continuous rotation of graphics
Hello:
In upgrading from wxWidgets 2.4 to 2.6, I encountered speed
problems with graphics redraw. If I continously redraw while rotating a
moderately complex object, the speed is about half as fast with wx 2.6
(also 2.7) as 2.4. My code is the same for both 2.4 and 2.6 except as
noted below
At the moment, I am compiling wx 2.4 with Metrowerks, and wx
2.6/2.7 with XCode, but I doubt if the compiler could make this much
difference - there is no evidence of any problem elsewhere. Rather, I
am guessing it is a difference in the wxWidgets event loops between 2.4
and 2.6/2.7.
Here is an outline of the code - a loop which just rotates and
redraws continuously:
--------------------------------
PushEventHandler(new MyEvtHandler(this)); //handler for buttons,
mouse
while( TRUE ) {
rotate(); //rotates object
wxYield();
#if !defined(__WXMAC__) or (wxMINOR_VERSION == 4)
redrawgraph( ); //does OnPaint - skip this for wx 2.6 ONLY
#endif
if( wxgen.quitnow ) goto stoploop; //quitnow flag set if user
hits button or mouse
}
stoploop:
PopEventHandler(TRUE);
--------------------------------
Note that redrawgraph(), which directly calls ::OnPaint, is
needed for 2.4 but not 2.6.
The same sort of problem occurs if the user rotates with the
mouse. The speed comparison is for PPC, but I suppose that Intel code
has the same problem (I have not tried to load wxWidgets 2.4 on an Intel
machine and compile it with XCode).
How could I get V2.6/2.7 to redraw at maximum speed? Is there
some wait cycle which could be disabled? Does someone have some code
for a redraw loop, for example rotating an object with the mouse, that
really is as fast under 2.6 as 2.4?
Would it make sense to try a completely native event loop, as in
the GLCarbonAGLWindow sample (for example?)?
Eric Dowty
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wx-users/attachments/20060921/a154a6c3/attachment.htm
More information about the wx-users
mailing list