Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9224973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:27:45+00:00 2026-06-18T04:27:45+00:00

I have a 3D iPhone game done with OpenGL ES. It’s a big world

  • 0

I have a 3D iPhone game done with OpenGL ES.

It’s a big world but with some tiny, first-person-view bits I need to paint up close, so I can’t reduce the depth range (zNear vs zFar) that glFrustumf() takes any further.

When surfaces meet for a Z-fight, I paint them slightly apart to stop them flickering. I’m also making the camera’s distance determine how far apart I adjust them, in cases where this is useful and needed.

It’s mostly OK, but there are some things whose perspective suffers by the separation, and making the separation smaller causes flicker. I’d love to paint surfaces closer together.

Is there any way to increase the depth buffer precision, so surfaces can be closer together without a narrower depth range?

If not, is there any other way around this?

I’m still using OpenGL ES 1.1 in the app, but am willing to upgrade if it’s worth it.

Thanks for your help.


Here’s how I create the depth buffer…

In init method:

// Create default framebuffer object. The backing will be allocated for the current layer in -resizeFromLayer
glGenFramebuffersOES(1, &defaultFramebuffer);
glGenRenderbuffersOES(1, &colorRenderbuffer);
glBindFramebufferOES(GL_FRAMEBUFFER_OES, defaultFramebuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, colorRenderbuffer);

//Added depth buffer
glGenRenderbuffersOES(1, &depthRenderbuffer);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer);
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer);

In resizeFromLayer method:

// Allocate color buffer backing based on the current layer size
glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);
[context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:layer];
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);

//Added depth buffer
glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer);
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight);

Here’s how I create the frustum…

const GLfloat  zNear = 2.2;
const GLfloat  zFar = 30000;
const GLfloat  fieldOfView = 60.0;
GLfloat size = zNear * tanf(degreesToRadian(fieldOfView) / 2.0);

if (LANDSCAPE) { //for landscape clip & aspect ratio.
    //parameters are: left, right, bottom, top, near, far
    glFrustumf(-size/(backingWidth/backingHeight),
               size/(backingWidth/backingHeight),
               -size, size,
               zNear, zFar);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:27:46+00:00Added an answer on June 18, 2026 at 4:27 am

    Apparently 32-bit depth buffers aren’t supported in OpenGL ES 1.x.

    Also, it seems that 16-bit depth buffers aren’t supported on iOS, so using GL_DEPTH_COMPONENT16_OES was just behaving as 24-bit, which is why I didn’t see any improvement when I used GL_DEPTH_COMPONENT24_OES instead!

    I confirmed this by checking GL_DEPTH_BITS after trying to set the depth buffer to 16 bit:

    glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer);
    glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight);
    
    GLint depthBufferBits;
    glGetIntegerv(GL_DEPTH_BITS, &depthBufferBits );
    NSLog(@"Depth buffer bits: %d", depthBufferBits );
    

    Outputs:

    Depth buffer bits: 24

    Oh well, at least now I know. Hope this helps someone else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi dear developers! I'm just wrote my first iphone game. But i have faced
I am new to iphone game development, i have recently install cocoas2d. But the
I'm having some issues. I have a cocos2d game I'm just about done developing.
Sorry if a stupid question, but I currently have an iPhone game which uses
I have an iPhone game which I am porting to PC. The game uses
I have a pretty basic challenge-based iPhone game, and I wanted to know what
I am making an iPhone game. I have all the required app sizes except
I am developing an iPhone game in which birds bounce. I have set up
i added sprite to scene by this tutorials : http://www.raywenderlich.com/9743/how-to-create-a-simple-2d-iphone-game-with-opengl-es-2-0-and-glkit-part-1 but i have bad
I'm currently developing a doodle-jump style game in Cocos2d for iPhone and have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.