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

  • Home
  • SEARCH
  • 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 5973691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:50:09+00:00 2026-05-22T20:50:09+00:00

I am developing a 3D Rendering Engine for Android. I have experienced some issues

  • 0

I am developing a 3D Rendering Engine for Android. I have experienced some issues with the depth buffer. I am drawing some cubes, one big and two small ones that will fall on top of the bigger one. While rendering I have seen that obviously something with the depth buffer is wrong, as seen in this screen shot:

Depth Buffer Problem on Device

This screen shot was taken on an HTC Hero (running Android 2.3.4) with OpenGL ES 1.1 The whole application is (still) targeted at OpenGL ES 1.1. It does look the same on the Emulator.

These are the calls in my onSurfaceCreated method in the renderer:

public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    Log.d(TAG, "onsurfacecreated method called");

    int[] depthbits = new int[1];
    gl.glGetIntegerv(GL_DEPTH_BITS, depthbits, 0);
    Log.d(TAG, "Depth Bits: " + depthbits[0]);

    gl.glDisable(GL_DITHER);

    gl.glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);

    gl.glClearColor(1, 1, 1, 1);
    gl.glClearDepthf(1f);
    gl.glEnable(GL_CULL_FACE);
    gl.glShadeModel(GL_SMOOTH);
    gl.glEnable(GL_DEPTH_TEST);

    gl.glMatrixMode(GL_PROJECTION);
    gl.glLoadMatrixf(
            GLUtil.matrix4fToFloat16(mFrustum.getProjectionMatrix()), 0);

    setLights(gl);
}

The GL Call for the depth bits returns 16 on the device and 0 on the emulator. It would’ve made sense if it only didn’t work on the emulator since there obviously is no depth buffer present. (I’ve tried setting the EGLConfigChooser to true, so it would create a Config with as close to 16 bits depth buffer as possible, but that didn’t work on the emulator. It wasn’t necessary on the device.)

In my onDrawFrame method I make the following OpenGL Calls:

    gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    gl.glClearDepthf(1);

And then for each of the cubes:

    gl.glEnableClientState(GL_VERTEX_ARRAY);
    gl.glFrontFace(GL_CW);
    gl.glVertexPointer(3, GL_FIXED, 0, mVertexBuffer);
    // gl.glColorPointer(4, GL_FIXED, 0, mColorBuffer);
    gl.glEnableClientState(GL_NORMAL_ARRAY);
    gl.glNormalPointer(GL_FIXED, 0, mNormalBuffer);
    // gl.glEnable(GL_TEXTURE_2D);
    // gl.glTexCoordPointer(2, GL_FLOAT, 0, mTexCoordsBuffer);
    gl.glDrawElements(GL_TRIANGLES, mIndexBuffer.capacity(),
            GL_UNSIGNED_SHORT, mIndexBuffer);
    gl.glDisableClientState(GL_NORMAL_ARRAY);
    gl.glDisableClientState(GL_VERTEX_ARRAY);

What am I missing? If more code is needed just ask.

Thanks for any advice!

  • 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-05-22T20:50:10+00:00Added an answer on May 22, 2026 at 8:50 pm

    I got it to work correctly now. The problem was not OpenGL. It was (as Banthar mentioned) a problem with the projection matrix. I am managing the projection matrix myself and the calculation of the final matrix was somehow corrupted (or at least not what OpenGL expects). I can’t remember where I got the algorithm for my calculation, but once I changed it to the way OpenGL calculates the projection matrix (or directly call glFrustumf(…)) it worked fine.

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

Sidebar

Related Questions

I am developing an ASP.Net web application. Some of my users' browsers are rendering
I'm developing an image rendering service that takes a bunch of query string parameters
I am developing an application that distributes rendering across several devices (a university project).
I'm trying to add text rendering to a Carbon OpenGL app I'm developing for
I'm currently developing my own 3d engine, which has a very limited abilities in
I'm developing a mobile site in HTML for use on 2 Blackberry models, one
Developing websites are time-consuming. To improve productivity, I would code a prototype to show
Developing a .NET WinForms application: how can I check if the window is in
Developing a heavily XML-based Java-application, I recently encountered an interesting problem on Ubuntu Linux.
Developing a website and just trying to get back into the swing of (clever)

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.