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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:58:00+00:00 2026-05-16T04:58:00+00:00

I’m trying to use gluLookAt in an Android app to move the camera around,

  • 0

I’m trying to use gluLookAt in an Android app to move the “camera” around, but I’m not seeing any results. I’ve looked around and I gather that any glLoadIndentity() calls will reset the matrix, cancelling the effect of the gluLookAt.

Problem is, no matter what I put in my gluLookAt call, nothing moves.

So here’s the relevant part of my surface setup:

public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    gl.glDisable(GL10.GL_DITHER);
    gl.glEnable(GL10.GL_TEXTURE_2D);
    gl.glShadeModel(GL10.GL_SMOOTH);
    gl.glClearColor(0f, 0f, 0f, 0.5f);
    gl.glClearDepthf(1.0f);
    gl.glEnable(GL10.GL_DEPTH_TEST);
    gl.glDepthFunc(GL10.GL_LEQUAL);
    gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
}

public void onSurfaceChanged(GL10 gl, int width, int height) {
    gl.glViewport(0, 0, width, height);

    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glLoadIdentity();
    GLU.gluPerspective(gl, 45f, (float) width / (float) height, 0.01f, 200f);

    gl.glMatrixMode(GL10.GL_MODELVIEW);
}

And then my frame-drawing method is:

public void onDrawFrame(GL10 gl) {
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    GLU.gluLookAt(gl, 0, 0, 100, 0, 0, 0, 0, 1, 0);

    for (int i = 0; i < obj.size; i++) { // obj is an array of positions
        obj = mObj[i];

        gl.glPushMatrix();
        gl.glLoadIdentity();
        gl.glTranslatef(obj.position.x(), obj.position.y(), obj.position.z());
        gl.glRotatef(obj.rotation.x(), 1f, 0f, 0f);
        gl.glRotatef(obj.rotation.y(), 0f, 1f, 0f);
        gl.glRotatef(obj.rotation.z(), 0f, 0f, 1f);
        obj.draw(gl); // the objects 'draw' themselves
        gl.glPopMatrix();

    }

}

And here’s an example of the draw() function of my objects, which essentially draw a bunch of elements:

class SomeObject {

    public void draw(GL10 gl) {
        gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
        gl.glEnableClientState(GL10.GL_NORMAL_ARRAY);

        gl.glEnable(GL10.GL_CULL_FACE);
        gl.glFrontFace(GL10.GL_CCW);
        gl.glCullFace(GL10.GL_BACK);            

        gl.glColor4f(1f, 0f, 0f, 1f);
        gl.glDrawElements(GL10.GL_TRIANGLES, SomeObject.fCount, GL10.GL_UNSIGNED_BYTE, faceBuffer);
        gl.glColor4f(1, 1, 1, 1);

        gl.glDisableClientState(GL10.GL_NORMAL_ARRAY);
        gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
    }
}
  • 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-16T04:58:01+00:00Added an answer on May 16, 2026 at 4:58 am

    Give this version a shot:

    public void onDrawFrame(GL10 gl) {
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
        gl.glLoadIdentity();
        GLU.gluLookAt(gl, 0, 0, 100, 0, 0, 0, 0, 1, 0);
    
        for (int i = 0; i < obj.size; i++) { // obj is an array of positions
            obj = mObj[i];
    
            gl.glPushMatrix();
            gl.glTranslatef(obj.position.x(), obj.position.y(), obj.position.z());
            gl.glRotatef(obj.rotation.x(), 1f, 0f, 0f);
            gl.glRotatef(obj.rotation.y(), 0f, 1f, 0f);
            gl.glRotatef(obj.rotation.z(), 0f, 0f, 1f);
            obj.draw(gl); // the objects 'draw' themselves
            gl.glPopMatrix();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.