Hello All
I'm working on a wxPython glcanvas program running under Fedora 17 Linux
system and I'm experiencing the following problem.
I have downloaded the wx.glcanvas example from here:
http://xoomer.virgilio.it/infinity77/wxPython/glcanvas/wx.glcanvas.html?highlight=glcanvas#module-glcanvas
This produces a cube with some of the faces not shown correctly. If I use
the same example code, but remove it from wx, ie just use PyOpenGL, the
problem goes away. The problem seems to be that the GL depth buffer is not
working correctly when I inherit from wx.glcanvas!
Any help would be much appreciated.
I include links to clips to demonstrate that my hardware and OpenGL are
working properly:
original broken version <http://www.unionsteammodels.co.uk/files/broken.ogv>
working modified version
<http://www.unionsteammodels.co.uk/files/working.ogv>
My working version uses a glutCreateWindow instead of glcanvas, the code is
here: (sorry about the length):
from OpenGL.GL import *
from OpenGL.GLUT import *
class MyGL():
def __init__(self):
glutInit(sys.argv)
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA |
GLUT_DEPTH)
self.w=320; self.h=240;
glutInitWindowSize(self.w, self.h)
glutInitWindowPosition(20, 20)
self.window = glutCreateWindow("Test 3")
glutIdleFunc(self.Draw)
glutMotionFunc(self.Mouse)
glutReshapeFunc(self.Resize)
glClearColor(1.0, 1.0, 1.0, 1.0) # Black
glClearDepth(1.0) # Enables Clearing Of The Depth Buffer
glDepthFunc(GL_LESS) # The Type Of Depth Test To Do
glEnable(GL_DEPTH_TEST) # Enables Depth Testing
glShadeModel(GL_SMOOTH) # Enables Smooth Color Shading
self.x=self.y=self.lastx=self.lasty=self=0
def InitGL(self):
# set viewing projection
glMatrixMode(GL_PROJECTION)
glFrustum(-0.5, 0.5, -0.5, 0.5, 1.0, 3.0)
# position viewer
glMatrixMode(GL_MODELVIEW)
glTranslatef(0.0, 0.0, -2.0)
glEnable(GL_DEPTH_TEST)
glEnable(GL_LIGHTING)
glEnable(GL_LIGHT0)
def Mouse(self,x,y):
self.x=x; self.y=y;
def Resize(self,w,h):
self.w=w; self.h=h
glViewport(0, 0, w, h)
def Draw(self):
# clear color and depth buffers
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
# draw six faces of a cube
glBegin(GL_QUADS)
glNormal3f( 0.0, 0.0, 1.0)
glVertex3f( 0.5, 0.5, 0.5)
glVertex3f(-0.5, 0.5, 0.5)
glVertex3f(-0.5,-0.5, 0.5)
glVertex3f( 0.5,-0.5, 0.5)
glNormal3f( 0.0, 0.0,-1.0)
glVertex3f(-0.5,-0.5,-0.5)
glVertex3f(-0.5, 0.5,-0.5)
glVertex3f( 0.5, 0.5,-0.5)
glVertex3f( 0.5,-0.5,-0.5)
glNormal3f( 0.0, 1.0, 0.0)
glVertex3f( 0.5, 0.5, 0.5)
glVertex3f( 0.5, 0.5,-0.5)
glVertex3f(-0.5, 0.5,-0.5)
glVertex3f(-0.5, 0.5, 0.5)
glNormal3f( 0.0,-1.0, 0.0)
glVertex3f(-0.5,-0.5,-0.5)
glVertex3f( 0.5,-0.5,-0.5)
glVertex3f( 0.5,-0.5, 0.5)
glVertex3f(-0.5,-0.5, 0.5)
glNormal3f( 1.0, 0.0, 0.0)
glVertex3f( 0.5, 0.5, 0.5)
glVertex3f( 0.5,-0.5, 0.5)
glVertex3f( 0.5,-0.5,-0.5)
glVertex3f( 0.5, 0.5,-0.5)
glNormal3f(-1.0, 0.0, 0.0)
glVertex3f(-0.5,-0.5,-0.5)
glVertex3f(-0.5,-0.5, 0.5)
glVertex3f(-0.5, 0.5, 0.5)
glVertex3f(-0.5, 0.5,-0.5)
glEnd()
# self.rot = self.rot + 0.2;
# if self.size is None:
# self.size = self.GetClientSize()
# w, h = self.size
# w = max(w, 1.0)
# h = max(h, 1.0)
xScale = 180.0 / self.w
yScale = 180.0 / self.h
glRotatef((self.y - self.lasty) * yScale, 1.0, 0.0, 0.0);
glRotatef((self.x - self.lastx) * xScale, 0.0, 1.0, 0.0);
self.lastx=self.x; self.lasty=self.y
# self.SwapBuffers()
glutSwapBuffers()
g=MyGL()
g.InitGL()
glutMainLoop()
···
--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/OpenGL-depth-buffer-deosn-t-seem-to-work-in-wx-glcanvas-tp5714984.html
Sent from the wxPython-users mailing list archive at Nabble.com.