Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


and in my on_draw function i call


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 enter image description here 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.


def on_draw():


for x in range(0,4):
    for y in range(0,4):
        if x % 2== 0 and y % 2==0:

        glTexCoord2f(0.0, 0.0)
        glTexCoord2f(0.0, 1.0)
        glTexCoord2f(1.0, 1.0) 
        glTexCoord2f(1.0, 0.0)


share|improve this question
You might consider adding a screenshot – rraallvv Jan 8 '13 at 5:18
What is your projection matrix? You may have a Z computation issue; as a quick test you can try to use a clear depth of -1.0 and GL_GEQUAL instead. – sam hocevar Jan 8 '13 at 9:51
I have updated the original question with a screenshot. I have tried a clear depth of -1.0 and GL_GEQUAL and it yields similar results. – user700508 Jan 8 '13 at 23:56
@user700508 When do you actually clear the depth buffer? Do you do it once, or everytime that you render a square? Looks liks you are loosing depth information at some point... Maybe more code could help us in finding the error – Dan Jan 9 '13 at 0:09
Sorry for the lack of code for where it references the clear function. I have added the draw function to show where I am calling glClear and what I am clearing and what I am drawing. Maybe I am doing something fundamentally wrong there. – user700508 Jan 9 '13 at 0:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.