OpenGL depth buffer deosn't seem to work in wx.glcanvas?

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

OpenGL depth buffer deosn't seem to work in wx.glcanvas?

bradcan
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
 working modified version

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()
Reply | Threaded
Open this post in threaded view
|

Re: OpenGL depth buffer deosn't seem to work in wx.glcanvas?

Robin Dunn
On 10/24/12 11:48 AM, bradcan wrote:

> 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'm not sure what is going on there, but I see it on my Linux box too.
You may want to experiment with setting some GL attributes when creating
the context.  It may be that the defaults used on wxGTK are not
sufficient, or perhaps wx is assuming that OpenGL has different default
attributes than it does.



--
Robin Dunn
Software Craftsman
http://wxPython.org

--
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en
Reply | Threaded
Open this post in threaded view
|

Re: OpenGL depth buffer deosn't seem to work in wx.glcanvas?

bradcan
On Oct 25, 2012; 12:00am, Robin wrote:

>It may be that the defaults used on wxGTK are not
>sufficient, or perhaps wx is assuming that OpenGL has different default
>attributes than it does.

I'm sure you're right. One clue is the difference between  self.SwapBuffers() and glutSwapBuffers() the former being
essential, the latter does NOT work at all when using glcanvas, ie we can call gl... directly for most things, but not all.

The wxPython documents here: http://wxpython.org/onlinedocs.php offer some clues.
My first problem is that these docs. are C++, not Python, despite being listed as "wxPython".

Whatever: I see the constructor for wxGLCanvas has the parameter attribList=0 and a list of possible attributes including
WX_GL_DEPTH_SIZE and the example code snippet:
attribList[index]= WX_GL_DEPTH_SIZE;
attribList[index+1]=32;

Unfortunately, the constant WX_GL_DEPTH_SIZE is NOT defined! ie:
print "the depth buffer constant is:", WX_GL_DEPTH_SIZE produces the Python error:
"NameError: global name 'WX_GL_DEPTH_SIZE' is not defined"

Where are the constants defined?
And how-to code attribList in Python. Can you point me to an example?

---
Charles Bradshaw
Determined old hack.
---
Reply | Threaded
Open this post in threaded view
|

Re: OpenGL depth buffer deosn't seem to work in wx.glcanvas? SOLVED

bradcan
In reply to this post by Robin Dunn
Solved it !

This Python code works:

from wx.glcanvas import WX_GL_DEPTH_SIZE

attribs=[WX_GL_DEPTH_SIZE,16,0,0];
glcanvas.GLCanvas.__init__(self, parent, -1,attribList=attribs)

Note: On my machine the value must be 16, presumably determined by hardware.?
Anything else produces a blank canvas!

Thanks for the help.
Reply | Threaded
Open this post in threaded view
|

Re: OpenGL depth buffer deosn't seem to work in wx.glcanvas?

Bruce Sherwood
In reply to this post by bradcan
I'll comment that the wx.glcanvas demo mentioned here doesn't work for me on Windows. The following canvas example does work:

http://wiki.wxpython.org/GLCanvas%20update

On Wednesday, October 24, 2012 12:50:13 PM UTC-6, oldbrad wrote:
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

m the wxPython-users mailing list archive at Nabble.com.

--
To unsubscribe, send email to [hidden email]
or visit http://groups.google.com/group/wxPython-users?hl=en
Reply | Threaded
Open this post in threaded view
|

Re: OpenGL depth buffer deosn't seem to work in wx.glcanvas? SOLVED

bradcan
Hi Bruce
That demo doesn't work either under Fedora. For the same reason, one has to pass the depth buffer attribute like this:
 
        attribs=[WX_GL_DEPTH_SIZE,16,0];                 # Needed by wxGTK the defaults are not enough. Obscure!
        glcanvas.GLCanvas.__init__(self, parent, -1,attribList=attribs)

I struggled for many days and tried most of the samples google could find. The fundamental problem seems to be that very few have been tested under X.
Reply | Threaded
Open this post in threaded view
|

Re: OpenGL depth buffer deosn't seem to work in wx.glcanvas? SOLVED

Thomas-2
In reply to this post by bradcan
I have a similar situation where a wx app requires WX_GL_DEPTH_SIZE to be 16 on one platform (RHEL 6.3 64 bit with wx 2.8.12), whereas 32 will work on another (OS X 10.6 with wx 2.9).  Does anyone know of a straightforward way to determine the max allowable depth prior to creating the GLCanvas?

Thanks,
Thomas

On Thursday, October 25, 2012 9:07:56 AM UTC-4, oldbrad wrote:
Solved it !

This Python code works:

from wx.glcanvas import WX_GL_DEPTH_SIZE

attribs=[WX_GL_DEPTH_SIZE,16,0,0];
glcanvas.GLCanvas.__init__(self, parent, -1,attribList=attribs)

Note: On my machine the value must be 16, presumably determined by
hardware.?
Anything else produces a blank canvas!

Thanks for the help.




--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/OpenGL-depth-buffer-deosn-t-seem-to-work-in-wx-glcanvas-tp5714984p5714991.html
Sent from the wxPython-users mailing list archive at Nabble.com.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: OpenGL depth buffer deosn't seem to work in wx.glcanvas? SOLVED

Anna Petrášová


On Tuesday, February 5, 2013 2:44:28 PM UTC+1, Thomas wrote:
I have a similar situation where a wx app requires WX_GL_DEPTH_SIZE to be 16 on one platform (RHEL 6.3 64 bit with wx 2.8.12), whereas 32 will work on another (OS X 10.6 with wx 2.9).  Does anyone know of a straightforward way to determine the max allowable depth prior to creating the GLCanvas?

Hi all,

I am also interested in this question. I have been using GLCanvas for some time without problems and recently (probably due to upgrading to Ubuntu 12 with newer wxPython) the rendering order became strange. Setting WX_GL_DEPTH_SIZE to 16 works for me. I don't understand if the attribList parameter needs to be used on all platforms and which value to use? for example, will 16 work where 32 works, or only one value is right? What should a developer of a multiplatform application do?

Thanks very much,
Anna
 

Thanks,
Thomas

On Thursday, October 25, 2012 9:07:56 AM UTC-4, oldbrad wrote:
Solved it !

This Python code works:

from wx.glcanvas import WX_GL_DEPTH_SIZE

attribs=[WX_GL_DEPTH_SIZE,16,0,0];
glcanvas.GLCanvas.__init__(self, parent, -1,attribList=attribs)

Note: On my machine the value must be 16, presumably determined by
hardware.?
Anything else produces a blank canvas!

Thanks for the help.




--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/OpenGL-depth-buffer-deosn-t-seem-to-work-in-wx-glcanvas-tp5714984p5714991.html
Sent from the wxPython-users mailing list archive at Nabble.com.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: OpenGL depth buffer deosn't seem to work in wx.glcanvas? SOLVED

Bruce Sherwood
This is pretty puzzling, as the use VPython makes of OpenGL is pretty basic, in large part because the architecture dates back to 2000 with the exception of materials, which requires GPUs.

VPython has always been, and still is, rather fiercely multiplatform. However, there have always been problems with Linux, most typically related to the need for and difficulty of updating the graphics driver. Note that these arcane OpenGL issues are not a problem on Windows and Mac.


On Sat, Mar 2, 2013 at 9:30 AM, annakrat <[hidden email]> wrote:


On Tuesday, February 5, 2013 2:44:28 PM UTC+1, Thomas wrote:
I have a similar situation where a wx app requires WX_GL_DEPTH_SIZE to be 16 on one platform (RHEL 6.3 64 bit with wx 2.8.12), whereas 32 will work on another (OS X 10.6 with wx 2.9).  Does anyone know of a straightforward way to determine the max allowable depth prior to creating the GLCanvas?

Hi all,

I am also interested in this question. I have been using GLCanvas for some time without problems and recently (probably due to upgrading to Ubuntu 12 with newer wxPython) the rendering order became strange. Setting WX_GL_DEPTH_SIZE to 16 works for me. I don't understand if the attribList parameter needs to be used on all platforms and which value to use? for example, will 16 work where 32 works, or only one value is right? What should a developer of a multiplatform application do?

Thanks very much,
Anna
 

Thanks,
Thomas

On Thursday, October 25, 2012 9:07:56 AM UTC-4, oldbrad wrote:
Solved it !

This Python code works:

from wx.glcanvas import WX_GL_DEPTH_SIZE

attribs=[WX_GL_DEPTH_SIZE,16,0,0];
glcanvas.GLCanvas.__init__(self, parent, -1,attribList=attribs)

Note: On my machine the value must be 16, presumably determined by
hardware.?
Anything else produces a blank canvas!

Thanks for the help.




--
View this message in context: http://wxpython-users.1045709.n5.nabble.com/OpenGL-depth-buffer-deosn-t-seem-to-work-in-wx-glcanvas-tp5714984p5714991.html
Sent from the wxPython-users mailing list archive at Nabble.com.

--
You received this message because you are subscribed to a topic in the Google Groups "wxPython-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wxpython-users/lbzhzaBNkxQ/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: OpenGL depth buffer deosn't seem to work in wx.glcanvas? SOLVED

Anna Petrášová
In reply to this post by Anna Petrášová


On Saturday, March 2, 2013 5:30:58 PM UTC+1, annakrat wrote:


On Tuesday, February 5, 2013 2:44:28 PM UTC+1, Thomas wrote:
I have a similar situation where a wx app requires WX_GL_DEPTH_SIZE to be 16 on one platform (RHEL 6.3 64 bit with wx 2.8.12), whereas 32 will work on another (OS X 10.6 with wx 2.9).  Does anyone know of a straightforward way to determine the max allowable depth prior to creating the GLCanvas?

Hi all,

I am also interested in this question. I have been using GLCanvas for some time without problems and recently (probably due to upgrading to Ubuntu 12 with newer wxPython) the rendering order became strange. Setting WX_GL_DEPTH_SIZE to 16 works for me. I don't understand if the attribList parameter needs to be used on all platforms and which value to use? for example, will 16 work where 32 works, or only one value is right? What should a developer of a multiplatform application do? 

Thanks very much,
Anna


 Hi all

is there any progress concerning this question? I found out that there is IsDisplaySupported method which can check if the attributes are supported, however it's only in the wxPython version 2.9. Since I need to support also older version 2.8 it's not a solution. Do we at least know on what depth buffer number depends? Is there a way to test if creating of the glcanvas with the given attributes failed? Which numbers could work apart from 16 and 32?

Thanks,
Anna

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: OpenGL depth buffer deosn't seem to work in wx.glcanvas? SOLVED

Thomas-2
Thanks for the info on IsDisplaySupported.  I have a similar situation where I need to support wxPython 2.8.x.  Regarding your last question, I have found on one of my systems that WX_GL_DEPTH_SIZE of 24 will work (whereas 32 fails).  Interestingly, on that system IsDisplaySupported returns True for any value of WX_GL_DEPTH_SIZE <= 24 (including negative numbers).

Thomas

On Friday, April 19, 2013 2:28:19 AM UTC-4, annakrat wrote:


On Saturday, March 2, 2013 5:30:58 PM UTC+1, annakrat wrote:


On Tuesday, February 5, 2013 2:44:28 PM UTC+1, Thomas wrote:
I have a similar situation where a wx app requires WX_GL_DEPTH_SIZE to be 16 on one platform (RHEL 6.3 64 bit with wx 2.8.12), whereas 32 will work on another (OS X 10.6 with wx 2.9).  Does anyone know of a straightforward way to determine the max allowable depth prior to creating the GLCanvas?

Hi all,

I am also interested in this question. I have been using GLCanvas for some time without problems and recently (probably due to upgrading to Ubuntu 12 with newer wxPython) the rendering order became strange. Setting WX_GL_DEPTH_SIZE to 16 works for me. I don't understand if the attribList parameter needs to be used on all platforms and which value to use? for example, will 16 work where 32 works, or only one value is right? What should a developer of a multiplatform application do? 

Thanks very much,
Anna


 Hi all

is there any progress concerning this question? I found out that there is IsDisplaySupported method which can check if the attributes are supported, however it's only in the wxPython version 2.9. Since I need to support also older version 2.8 it's not a solution. Do we at least know on what depth buffer number depends? Is there a way to test if creating of the glcanvas with the given attributes failed? Which numbers could work apart from 16 and 32?

Thanks,
Anna

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: OpenGL depth buffer deosn't seem to work in wx.glcanvas?

bradcan
In reply to this post by bradcan
I'm posting an update to this thread because things seemed to have changed with versions since 2013.

In the GLCanvas sub class we need this snippet:

        # We need additional attribs for wxGTK the defaults are not enough. Very Obscure!!
        attribs=[WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_DEPTH_SIZE,24]; 
        super(Canvas,self).__init__(parent, -1, attribList=attribs)

Also note this:
        self.context = glcanvas.GLContext(self)            # OpenGL context (obviously!)

But the following must be delayed until the canvas is displayed. In my case I put the it in InitGl(self) which is called by OnPaint(self, event)
        self.SetCurrent(self.context)

In the above self is GLCanvas subclass.

These obscure snippets are running under Linux Mint as of Sept 2017



On Wednesday, October 24, 2012 at 7:48:06 PM UTC+1, bradcan wrote:
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:
<a href="http://xoomer.virgilio.it/infinity77/wxPython/glcanvas/wx.glcanvas.html?highlight=glcanvas#module-glcanvas" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fxoomer.virgilio.it%2Finfinity77%2FwxPython%2Fglcanvas%2Fwx.glcanvas.html%3Fhighlight%3Dglcanvas%23module-glcanvas\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEDHqH1Z7MSEEwPpsVb3a_Jn0dQKg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fxoomer.virgilio.it%2Finfinity77%2FwxPython%2Fglcanvas%2Fwx.glcanvas.html%3Fhighlight%3Dglcanvas%23module-glcanvas\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEDHqH1Z7MSEEwPpsVb3a_Jn0dQKg&#39;;return true;">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 <<a href="http://www.unionsteammodels.co.uk/files/broken.ogv" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.unionsteammodels.co.uk%2Ffiles%2Fbroken.ogv\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG34YzwKAtfpYdAnv0MqJAcebrufg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.unionsteammodels.co.uk%2Ffiles%2Fbroken.ogv\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG34YzwKAtfpYdAnv0MqJAcebrufg&#39;;return true;">http://www.unionsteammodels.co.uk/files/broken.ogv>  
working modified version
<<a href="http://www.unionsteammodels.co.uk/files/working.ogv" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.unionsteammodels.co.uk%2Ffiles%2Fworking.ogv\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFVhOr9pmObCUifj9zlyw6XYBmSKA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.unionsteammodels.co.uk%2Ffiles%2Fworking.ogv\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFVhOr9pmObCUifj9zlyw6XYBmSKA&#39;;return true;">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: <a href="http://wxpython-users.1045709.n5.nabble.com/OpenGL-depth-buffer-deosn-t-seem-to-work-in-wx-glcanvas-tp5714984.html" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwxpython-users.1045709.n5.nabble.com%2FOpenGL-depth-buffer-deosn-t-seem-to-work-in-wx-glcanvas-tp5714984.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEk-MIf90N9bxo6PmGJOJTR2XBS_Q&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwxpython-users.1045709.n5.nabble.com%2FOpenGL-depth-buffer-deosn-t-seem-to-work-in-wx-glcanvas-tp5714984.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEk-MIf90N9bxo6PmGJOJTR2XBS_Q&#39;;return true;">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.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.