Can't get wxPython OpenGL to work

Hi, I'm having trouble getting the wxPython OpenGL demos working. I've tried both the demo that comes with wxPython and the sphere demo here: http//code.activestate.com/recipes/325392/

The wxPython demo gives me a black window with nothing in it, and no errors.
The sphere demo gives me a gray window, and the following error when I exit (source code copied below for convenience)

---------- Python ----------
C:\Users\xxxxxx\code\python\cad\opengl_sphere.py:1: DeprecationWarning: The wxPython compatibility package is no longer automatically generated or actively maintained. Please switch to the wx package as soon as possible.
  from wxPython.wx import *
Traceback (most recent call last):
  File "C:\Users\xxxxxx\code\python\cad\opengl_sphere.py", line 23, in OnPaint
    self.OnDraw()
  File "C:\Users\xxxxxx\code\python\cad\opengl_sphere.py", line 31, in OnDraw
    glutSolidSphere(2,20,20)
  File "C:\Python25\Lib\site-packages\OpenGL\platform\baseplatform.py", line 280, in __call__
    self.__name__, self.__name__,
OpenGL.error.NullFunctionError: Attempt to call an undefined function glutSolidSphere, check for bool(glutSolidSphere) before calling

I have the following installed
Vista 64 on HP Compaq 8510W
NVIDIA Quadro FX570M
Nvidia driver version 7.15.11.7470 (3-19-2008) - nvoglv64
GPU Caps viewer and furry donut rendering from 3dgeeks all work fine
Python 2.5.2
wxPython2.8

Based on http://pyopengl.sourceforge.net/documentation/installation.html, I have installed the following:
GLUT (copied glu32.dll to system32)
GLE (copied gle32.dll to system32)
PIL-1.1.6 (used installer)

After this did not work, I installed setuptools and tried:

easy_install PyOpenGL

Which return what looked like a good response on the command line, but the results upon running the demos was the same.

Can someone please help me diagnose this/these problems? I'm not sure if I have 2 problems or just 1.

thanks a lot in advance.
Michael

opengl_sphere.py:

from wxPython.glcanvas import wxGLCanvas
from wxPython.wx import *
from OpenGL.GLUT import *
from OpenGL.GLU import *
from OpenGL.GL import *
import sys,math

name = 'ball_glut'

class myGLCanvas(wxGLCanvas):
    def __init__(self, parent):
  wxGLCanvas.__init__(self, parent,-1)
  EVT_PAINT(self, self.OnPaint)
  self.init = 0
  return

    def OnPaint(self,event):
  dc = wxPaintDC(self)
  self.SetCurrent()
  if not self.init:
      self.InitGL()
      self.init = 1
  self.OnDraw()
  return

    def OnDraw(self):
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        glPushMatrix()
  color = [1.0,0.,0.,1.]
  glMaterialfv(GL_FRONT,GL_DIFFUSE,color)
  glutSolidSphere(2,20,20)
  glPopMatrix()
        self.SwapBuffers()
        return
  
    def InitGL(self):
        # set viewing projection
        light_diffuse = [1.0, 1.0, 1.0, 1.0]
        light_position = [1.0, 1.0, 1.0, 0.0]

        glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse)
        glLightfv(GL_LIGHT0, GL_POSITION, light_position)

        glEnable(GL_LIGHTING)
        glEnable(GL_LIGHT0)
        glEnable(GL_DEPTH_TEST)
        glClearColor(0.0, 0.0, 0.0, 1.0)
        glClearDepth(1.0)

        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        gluPerspective(40.0, 1.0, 1.0, 30.0)

        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()
        gluLookAt(0.0, 0.0, 10.0,
                  0.0, 0.0, 0.0,
                  0.0, 1.0, 0.0)
        return
    
def main():
    app = wxPySimpleApp()
    frame = wxFrame(None,-1,'ball_wx',wxDefaultPosition,wxSize(400,400))
    canvas = myGLCanvas(frame)
    frame.Show()
    app.MainLoop()

if __name__ == '__main__': main()

Did you also try the file at GLCanvas - wxPyWiki?

I would update the import statements on the code before thinking all is lost.

Josh

···

On Sun, Jan 4, 2009 at 4:04 PM, Michael <sonic@coherentminds.com> wrote:

Hi, I'm having trouble getting the wxPython OpenGL demos working. I've
tried both the demo that comes with wxPython and the sphere demo here:
http//code.activestate.com/recipes/325392/

The wxPython demo gives me a black window with nothing in it, and no errors.
The sphere demo gives me a gray window, and the following error when I exit
(source code copied below for convenience)

---------- Python ----------
C:\Users\xxxxxx\code\python\cad\opengl_sphere.py:1: DeprecationWarning: The
wxPython compatibility package is no longer automatically generated or
actively maintained. Please switch to the wx package as soon as possible.
  from wxPython.wx import *
Traceback (most recent call last):
  File "C:\Users\xxxxxx\code\python\cad\opengl_sphere.py", line 23, in
OnPaint
    self.OnDraw()
  File "C:\Users\xxxxxx\code\python\cad\opengl_sphere.py", line 31, in
OnDraw
    glutSolidSphere(2,20,20)
  File "C:\Python25\Lib\site-packages\OpenGL\platform\baseplatform.py", line
280, in __call__
    self.__name__, self.__name__,
OpenGL.error.NullFunctionError: Attempt to call an undefined function
glutSolidSphere, check for bool(glutSolidSphere) before calling

I have the following installed
Vista 64 on HP Compaq 8510W
NVIDIA Quadro FX570M
Nvidia driver version 7.15.11.7470 (3-19-2008) - nvoglv64
GPU Caps viewer and furry donut rendering from 3dgeeks all work fine
Python 2.5.2
wxPython2.8

Based on PyOpenGL Installation, I
have installed the following:
GLUT (copied glu32.dll to system32)
GLE (copied gle32.dll to system32)
PIL-1.1.6 (used installer)

After this did not work, I installed setuptools and tried:

easy_install PyOpenGL

Which return what looked like a good response on the command line, but the
results upon running the demos was the same.

Can someone please help me diagnose this/these problems? I'm not sure if I
have 2 problems or just 1.

thanks a lot in advance.
Michael

opengl_sphere.py:

from wxPython.glcanvas import wxGLCanvas
from wxPython.wx import *
from OpenGL.GLUT import *
from OpenGL.GLU import *
from OpenGL.GL import *
import sys,math

name = 'ball_glut'

class myGLCanvas(wxGLCanvas):
    def __init__(self, parent):
  wxGLCanvas.__init__(self, parent,-1)
  EVT_PAINT(self, self.OnPaint)
  self.init = 0
  return

    def OnPaint(self,event):
  dc = wxPaintDC(self)
  self.SetCurrent()
  if not self.init:
      self.InitGL()
      self.init = 1
  self.OnDraw()
  return

    def OnDraw(self):
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
        glPushMatrix()
  color = [1.0,0.,0.,1.]
  glMaterialfv(GL_FRONT,GL_DIFFUSE,color)
  glutSolidSphere(2,20,20)
  glPopMatrix()
        self.SwapBuffers()
        return
  
    def InitGL(self):
        # set viewing projection
        light_diffuse = [1.0, 1.0, 1.0, 1.0]
        light_position = [1.0, 1.0, 1.0, 0.0]

        glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse)
        glLightfv(GL_LIGHT0, GL_POSITION, light_position)

        glEnable(GL_LIGHTING)
        glEnable(GL_LIGHT0)
        glEnable(GL_DEPTH_TEST)
        glClearColor(0.0, 0.0, 0.0, 1.0)
        glClearDepth(1.0)

        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        gluPerspective(40.0, 1.0, 1.0, 30.0)

        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()
        gluLookAt(0.0, 0.0, 10.0,
                  0.0, 0.0, 0.0,
                  0.0, 1.0, 0.0)
        return

def main():
    app = wxPySimpleApp()
    frame = wxFrame(None,-1,'ball_wx',wxDefaultPosition,wxSize(400,400))
    canvas = myGLCanvas(frame)
    frame.Show()
    app.MainLoop()

if __name__ == '__main__': main()

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

--
Josh English
Joshua.R.English@gmail.com