I'm using a timer object and an OGL canvas to work with 80+ shapes
that need to move every time the timer fires. The result of how I'm
doing things ends up being very slowly rendered to the screen no
matter how quickly I do things. I'm probably doing something wrong,
and I'm very new to both timers and OGL. Any help on getting this to
run faster/properly would be greatly appreciated. Here are the
relevant parts of the code that I'm using currently:
def OnTimer(self, evt): #print "tick %i" % self.time
self.UpdateTime(self.time+1) # increases the time
wx.CallAfter(self.UpdateLocations)
evt.Skip()
def OnPlay(self, evt):
print "Play"
self.timer = wx.Timer(self)
self.timer.Start(5) # every second, do something
self.Bind(wx.EVT_TIMER, self.OnTimer)
def UpdateLocations(self):
for key, val in self.persons.items(): #shape.SetX(val.locations[self.time].x*6+6) #shape.SetY(val.locations[self.time].y*6+12)
dc = wx.ClientDC(self.canvas) #val.shape.Move(dc, val.locations[self.str_time].x*6+6,
val.locations[self.str_time].y*6+12)
val.shape.Move(dc, val.locations[self.str_time].x*6+6,
val.locations[self.str_time].y*6+12)
self.canvas.Refresh()
Try passing display=False to the Move methods so it won't redraw the whole canvas for every move.
···
On 10/8/09 10:34 PM, excid3 wrote:
I'm using a timer object and an OGL canvas to work with 80+ shapes
that need to move every time the timer fires. The result of how I'm
doing things ends up being very slowly rendered to the screen no
matter how quickly I do things. I'm probably doing something wrong,
and I'm very new to both timers and OGL. Any help on getting this to
run faster/properly would be greatly appreciated. Here are the
relevant parts of the code that I'm using currently:
def UpdateLocations(self):
for key, val in self.persons.items(): #shape.SetX(val.locations[self.time].x*6+6) #shape.SetY(val.locations[self.time].y*6+12)
dc = wx.ClientDC(self.canvas) #val.shape.Move(dc, val.locations[self.str_time].x*6+6,
val.locations[self.str_time].y*6+12)
val.shape.Move(dc, val.locations[self.str_time].x*6+6,
val.locations[self.str_time].y*6+12)
self.canvas.Refresh()
That helps, I think that having 80+ moving shapes and 500+ background
shapes behind it just make it hard to render timely. Still really
really slow unfortunately.
···
On Oct 9, 1:28 pm, Robin Dunn <ro...@alldunn.com> wrote:
On 10/8/09 10:34 PM, excid3 wrote:
> I'm using a timer object and an OGL canvas to work with 80+ shapes
> that need to move every time the timer fires. The result of how I'm
> doing things ends up being very slowly rendered to the screen no
> matter how quickly I do things. I'm probably doing something wrong,
> and I'm very new to both timers and OGL. Any help on getting this to
> run faster/properly would be greatly appreciated. Here are the
> relevant parts of the code that I'm using currently:
> def UpdateLocations(self):
> for key, val in self.persons.items():
> #shape.SetX(val.locations[self.time].x*6+6)
> #shape.SetY(val.locations[self.time].y*6+12)
> dc = wx.ClientDC(self.canvas)
> #val.shape.Move(dc, val.locations[self.str_time].x*6+6,
> val.locations[self.str_time].y*6+12)
> val.shape.Move(dc, val.locations[self.str_time].x*6+6,
> val.locations[self.str_time].y*6+12)
> self.canvas.Refresh()
Try passing display=False to the Move methods so it won't redraw the
whole canvas for every move.
--
Robin Dunn
Software Craftsmanhttp://wxPython.org
That helps, I think that having 80+ moving shapes and 500+ background
shapes behind it just make it hard to render timely. Still really
really slow unfortunately.
try VPython,
a few nice examples to look for: fountain, random, randombox,pipes
cheers,
Stef
···
On Oct 9, 1:28 pm, Robin Dunn <ro...@alldunn.com> wrote:
On 10/8/09 10:34 PM, excid3 wrote:
I'm using a timer object and an OGL canvas to work with 80+ shapes
that need to move every time the timer fires. The result of how I'm
doing things ends up being very slowly rendered to the screen no
matter how quickly I do things. I'm probably doing something wrong,
and I'm very new to both timers and OGL. Any help on getting this to
run faster/properly would be greatly appreciated. Here are the
relevant parts of the code that I'm using currently:
def UpdateLocations(self):
for key, val in self.persons.items(): #shape.SetX(val.locations[self.time].x*6+6) #shape.SetY(val.locations[self.time].y*6+12)
dc = wx.ClientDC(self.canvas) #val.shape.Move(dc, val.locations[self.str_time].x*6+6,
val.locations[self.str_time].y*6+12)
val.shape.Move(dc, val.locations[self.str_time].x*6+6,
val.locations[self.str_time].y*6+12)
self.canvas.Refresh()
Try passing display=False to the Move methods so it won't redraw the
whole canvas for every move.
--
Robin Dunn
Software Craftsmanhttp://wxPython.org
That helps, I think that having 80+ moving shapes and 500+ background
shapes behind it
I don't know what types of shapes you are using, but you might want to try wx.lib.floatcanvas -- that should be no problem 580 objects is not that many. In addition, FloatCanvas supports a separate background and foreground, in which case you'd only be re-rendering the 80 moving shapes.
-Chris
···
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception