From: Ian Krepps <Ian.K<repps@rm...> - 2004-10-15 13:18:41
Using glcanvas I have implemented a crude map browser. I am now trying to draw wxpython graphics onto the canvas, lines, rectangles etc - the endstate is to track mouse movements, but just a libe would be good for now.
Do I need to create a transparent bitmap and overlay this on top of the glCanvas ?
Is there an easier way? Right now I am trying to draw to the wx.PaintDC (see code below) and not having much luck. When I insert a draw command such as DrawLine the appication spins in an infinite loop.
I am using a glFrustum projection and varying the camera position to zoom and pan - I would track mouse movement with opengl lines but mapping opengl to window coords is difficult (possible ?)
Here is the code that spins me in a loop
def OnPaint(self, event=None):
dc = wx.PaintDC(self)
self.DoDrawing(dc) #call to draw some shapes in pixel coord
self.SetCurrent() #set this canvas to recieve Opengl calls
size = self.GetClientSize()
#glViewport( 0,0, *size ) #viewport fixed
self.DrawGL() #call to draw opengl model
#??need to confirm if I double buffer only opengl and/or wxpython??
def DoDrawing(self, dc = None): #draw wxpython graphics
if dc is None:
dc = wx.Client(self)
pen = wx.Pen(wx.WHITE,4,wx.SOLID)
dc.DrawRectangle(10,10,300,300) #does not like this