I am learning to use pyglet and learning about applying 2D textures to planes in pyglet. When I apply the 2D texture to the plane it works fine. When I make multiple objects with the same texture , one in front of the other, i have a problem.
The texture behind the first texture draws through it. And the texture behind that has the same property.
I would like to disable this so the front texture is shown and obscures the back textures.
In my resize function I called
glClearDepth(1.0) glEnable(GL_DEPTH_TEST) glDepthFunc(GL_LEQUAL) glShadeModel(GL_SMOOTH)
and in my on_draw function i call
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) glEnable(GL_TEXTURE_2D)
I am using a perspective camera with
where velx is the x position for the camera and vely is the z position for the camera
Am I processing the texture incorrectly causing this? What should I do to change this?
The images positions are in order on the z axis -10,-20,-40, and -60.
[EDIT] Here is a screenshot of what I was saying The GreenBox is in the front and the Red box is behind it
This is the drawing function that i am using. I believe that it is clearing the depth buffer.
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) for x in range(0,4): for y in range(0,4): glPushMatrix() if x % 2== 0 and y % 2==0: glBindTexture(texture.target,texture.id) else: glBindTexture(texture2.target,texture2.id) glTranslatef(x*4.0,0,y*-10.0) glBegin(GL_QUADS) glTexCoord2f(0.0, 0.0) glVertex3f(-1,-1,-10) glTexCoord2f(0.0, 1.0) glVertex3f(-1,1,-10) glTexCoord2f(1.0, 1.0) glVertex3f(1,1,-10) glTexCoord2f(1.0, 0.0) glVertex3f(1,-1,-10) glEnd() glPopMatrix()