I'm trying to create a Opengl application using wxPython and Boa on
Mandrake 9.1. I'm going through the redbook and taking their c source
and trying to convert it to a wxPython app. I tried to write example
3.1 in chapter 3
(http://fly.cc.fer.hr/~unreal/theredbook/chapter03.html) to run in
wxPython and have had no success, though I am able to rewrite using GLUT
in c and in python using GLUT. Can anyone see my error? If you comment
out the translate and scale funcs, a box appears.
Thanks,
Steven
···
#------------------------------------------------------
# This is based on the wxPython Demo wxGLCanvas.py
# Calling app omitted
class wxFrame1(wxFrame):
def _init_utils(self):
pass
def _init_ctrls(self, prnt):
wxFrame.__init__(self, style=wxDEFAULT_FRAME_STYLE, name='',
parent=prnt, title='wxFrame1', id=wxID_WXFRAME1, pos=(400, 275),
size=(1067, 733))
self._init_utils()
def __init__(self, parent):
self._init_ctrls(parent)
AGLPanel(self)
class AGLPanel(wxGLCanvas):
def __init__(self, parent):
wxGLCanvas.__init__(self, parent, -1)
self.init = False
EVT_SIZE(self, self.OnSize)
EVT_PAINT(self, self.OnPaint)
def OnSize(self, event):
glMatrixMode(GL_PROJECTION) # prepare for and then */
glLoadIdentity() # define the projection */
glFrustum(-1.0, 1.0, -1.0, 1.0, 1.5, 20.0)
glMatrixMode(GL_MODELVIEW) # back to modelview matrix */
size = self.GetClientSize()
glViewport(0, 0, min(size.width,size.height),
min(size.width,size.height)) #define the viewport */
glEnable(GL_DEPTH_TEST)
def OnPaint(self, event):
dc = wxPaintDC(self)
self.SetCurrent()
if not self.init:
self.InitGL()
self.init = True
self.OnDraw()
def InitGL(self):
glShadeModel(GL_FLAT)
def OnDraw(self):
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glColor3f(1.0, 1.0, 1.0)
glLoadIdentity() # clear the matrix */
glTranslatef(0.0, 0.0, -5.) # viewing transformation */
glScalef(1.0, 2.0, 1.0) # modeling transformation */
glutWireCube(1.0) # draw the cube */
self.SwapBuffers()