Robin Dunn wrote:
Alex Zeiger wrote:
How would you double buffer an ogl.ShapeCanvas object? I've tried making a separate DC for a buffer (eg bufferdc = wx.BufferedDC(self)) and then using this for the drawing, but when I do diagram.Redraw(self.dc) it either crashes or still flickers.
Is it possible to double buffer an ogl object? Basically, all I want to do is stop the diagram.Redraw() from flickering. Any help is appreciated.
OGL should already be doing some double buffering internally. Perhaps the flicker is coming from a parent window that is not cliping its children properly?
I don't think so. My program is pretty much like the example in the demo. I create and add shapes to a diagram, create and prepare my DC, and then use diagram.Redraw(dc) to draw the diagram whenever a change is made. However, I notice a distinct flickering as each object in the diagram is redrawn.
I've tried numerous things to double buffer the redraw. Unfortunately, I don't fully understand the use of the device context object. The only wx documentation I've found on the net involve basic frame buffering, and don't seem to apply to OGL. However, I've tried following the guide at http://wiki.wxpython.org/index.cgi/DoubleBufferedDrawing
In my OnSize function, I use:
self.bitmapbuffer = wx.EmptyBitmap(w, h)
And in my OnPaint, I use:
self.dc = wx.BufferedPaintDC(self.bitmapbuffer)
My application's a simple board game. So when the user clicks the canvas area, alterations are made to the diagram, and then I call my Draw funcion and perform:
self.dc = BufferedPaintDC(wx.ClientDC(self), self.bitmapbuffer)
self.diagram.Redraw(self.dc)
Unfortunately, this buffering attempt produces an infinite stream of errors in the theme of:
Exception exceptions.AttributeError: "wxBufferedPaintDC instance has no attribut
e 'thisown'" in ignored
Traceback (most recent call last):
File "boardcanvas.py", line 153, in OnPaint
self.dc = wx.BufferedPaintDC(self.bitmapbuffer)
File "C:\Python23\lib\site-packages\wxPython\gdi.py", line 1026, in __init__
self.this = gdic.new_wxBufferedPaintDC(*_args,**_kwargs)
TypeError: Type error in argument 1 of new_wxBufferedPaintDC. Expected _wxWindow
_p.