Results 1 to 10 of 10

Thread: [OpenGL 2.0] Depth buffer problems

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Can you try to draw how it is supposed to look?
    A i see it if they were on the same level they would collide with each other.
    http://3das.noeska.com - create adventure games without programming

  2. #2
    Quote Originally Posted by noeska View Post
    A i see it if they were on the same level they would collide with each other.
    Yes, that's basically what I'm trying to achieve.

    EDIT
    Or maybe you could tell me how do I bring one sprite on front of the other once it was rendered already? Hm, maybe not the best descriptive way of telling you about the problem, that's why take a look at these two images:
    http://i52.tinypic.com/2rff2bt.jpg and http://i56.tinypic.com/2d91qf9.jpg
    What I mean is that no matter which sprite I choose, it's drawn on top of the other ones.
    Last edited by Brainer; 26-11-2010 at 06:38 PM.

  3. #3
    Do you have a specific reason to use depth buffer for 2D rendering? It is slower than normal and regarding your problem it would be easily solved with drawing order. When depth buffer is disabled, what sprite is drawn last will show on top of others. You can disable the buffer on the fly too to draw just that 1 sprite on top of others.
    glDisable(GL_DEPTH_TEST)

  4. #4
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25
    A sprite is a sprite, there is no depth, so I don't follow what you are thinking of. If it were 3D then it might make some sense, but as you are working with flat 2D sprites all you can really do is 2D tricks such as blending, ADD, OR, XOR and so on.

    If you want specific sprites to overlap over another then it's simply a matter of drawing order and you have to adjust that so that it is drawn last somehow. The use of a depth buffer seems like a waste of resources to do such things though.

    ...also, is this an iOS app I see? Very nice. Good work.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  5. #5
    Yeah, you both were right. Using layers helped me solve the problem. Thanks a lot!

  6. #6
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25
    Hey don't sweat it. Sometimes we all look for complicated solutions when a simple one would have sufficed. I've done this on many an occasion. I'm really starting to notice in some of my older projects from a few years back now.
    Jason McMillen
    Pascal Game Development
    Co-Founder





Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •