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 9157115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:56:05+00:00 2026-06-17T12:56:05+00:00

I am working on a camera system in a 3d scene on Android. So

  • 0

I am working on a camera system in a 3d scene on Android.
So far, I used this initialisation code to:

public void onSurfaceCreated(GL10 gl, EGLConfig config) {
        Log.i(LOG_TAG, "onSurfaceCreated()");

        TextureLibrary.loadTextures(m_context, gl);

        //Set initial perspective and viewport
        gl.glMatrixMode(GL10.GL_PROJECTION); 
        float fov = .01f * (float) Math.tan(Math.toRadians(45.0 / 2.0));
        float aspectRatio = 1.9541f;
        gl.glFrustumf(-fov, fov, -fov / aspectRatio, fov / aspectRatio, 0.01f, 100.0f);
        gl.glViewport(0, 0, (int) _viewportWidth, (int) _viewportHeight);
        gl.glMatrixMode(GL10.GL_MODELVIEW);

        gl.glEnable(GL10.GL_DEPTH_TEST);
        gl.glEnable(GL10.GL_CULL_FACE);
        gl.glEnable(GL10.GL_TEXTURE_2D);
        gl.glFrontFace(GL10.GL_CW);
        gl.glCullFace(GL10.GL_BACK);

        initialise();
    }

But now, I would like to update the frustum in the render method, to perform zooms and/or image distortions. However, it seems like the the frustum update.

Here is the render code (trimmed of the some fat, which does not contain any GL State altering code, apart from the usual Push and PopMatrix):

private void render(GL10 gl)
    {
      //Frustrum update code
        gl.glMatrixMode(GL10.GL_PROJECTION); 
        float fov = .01f * (float) Math.tan(Math.toRadians(45.0 / 2.0));
        float aspectRatio = 1.9541f;
        gl.glFrustumf(-fov, fov, -fov / aspectRatio, fov / aspectRatio, 0.01f, 100.0f);
        gl.glMatrixMode(GL10.GL_MODELVIEW);

        gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
        gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);

        gl.glClearColor(0.3f, 0.3f, 0.3f, 1.0f);
        gl.glLoadIdentity();
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT);         

       //Render all the things here!

        gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
        gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
    }

As you can see, the snippet where the frustum is set is almost identical, and the values used are the same. However, when glFrustum is called in the render method, the program will not show anything being drawn. I find this strange, since the values used are exactly the same (when forcing the aspect ratio).

The viewport is still set/updated in the OnSurfaceChanged method, which is hit at least once.

public void onSurfaceChanged(GL10 gl, int width, int height) {
        _viewportWidth = width;
        _viewportHeight = height;
        gl.glMatrixMode(GL10.GL_PROJECTION); 
        gl.glViewport(0, 0, (int) _viewportWidth, (int) _viewportHeight);
        gl.glMatrixMode(GL10.GL_MODELVIEW);
    }

I think this may have something to do with OpenGL States, but I haven’t yet found a solution, out of everything I tried.

  • 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-17T12:56:06+00:00Added an answer on June 17, 2026 at 12:56 pm

    glFrustum() concatenates with the current matrix. As you haven’t done a glLoadIdentity(), this means you’re going to be multiplying with the previous frustum.

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

Sidebar

Related Questions

I am working on the camera code in android to take picture and save
I am new in android and working on the camera application. In this app
I'm working on a realtime imaging system. UI thread: grabs images from a camera
I'm working on a little Android app to stream some camera footage (as a
I am working on android camera app,I want green screen chroma key effect to
I am working on android camera app,I want green screen chroma key effect to
I try take photo from camera this way: private void photo() { String storageState
Can someone tell me the location of drivers (specifically camera drivers) in Android System
I am working on this code, and inside my first .java file I get
I'm working on a security camera application using the webcam that takes a photo

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.