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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:37:47+00:00 2026-06-14T17:37:47+00:00

I am using gluLookAt() to set the camera position and orientation GLU.gluLookAt(xPosition, yPosition, zPosition,

  • 0

I am using gluLookAt() to set the “camera” position and orientation

GLU.gluLookAt(xPosition, yPosition, zPosition,
              xPosition + lx, yPosition, zPosition + lz
              0, 1, 0);

my lz and lx variables represent my forward vector

lz = Math.cos(angle);
lx = -Math.sin(angle);

When turn around in the 3D world, it appears that I am rotating around an axis that is always infront of me

I know this because my xPosition and yPosition variables stay the same, but I appear to spin around an object when im close to it and I turn.

Axis Diagram

I know there is not a problem with the maths that I have used here, because I have tried using code from past projects that have worked properly but the problem still remains.

This is what I am doing in the rendering loop

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//draw scene from user perspective
glLoadIdentity();
GLU.gluLookAt(camera.getxPos(), camera.getyPos(), camera.getzPos(), 
      camera.getxPos()+camera.getLx(), camera.getyPos(),     camera.getzPos()+p1.getLz(),
      0, 1, 0);


glBegin(GL_QUADS);
glVertex3f(-dim, dim, 0);
glVertex3f(dim, dim, 0);
glVertex3f(dim, 0, 0);
glVertex3f(-dim, 0, 0);
glEnd();

pollInput();
camera.update();

I have tried rendering a box where the player coordinates are and I got this result. The camera appears to be looking from behind the player coordinates. To use an analogy right now its like a 3rd Person game and It should look like a first person game

The small box here is rendered in the camera coordinates, to give some perspective the bigger box is infront.

Third Person
Third Person 2

  • 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-14T17:37:49+00:00Added an answer on June 14, 2026 at 5:37 pm

    Solved!

    The problem was that I was initially calling gluLookAt() while the matrix mode was set to GL_PROJECTION.

    I removed that line and moved it to just after I had set the matrix mode to GL_MODELVIEW and that solved the problem.

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

Sidebar

Related Questions

I'm trying to calculate a lookat matrix myself, instead of using gluLookAt(). My problem
I'm using a Perspective View with gluPerspective and gluLookAt and I have the x,y
Using InteliJ IDEA , I am trying to set up multiple projects to run
I'm implementing a simple camera system in OpenGL. I set up gluPerspective under the
I'm making a program using the glu library but when i compile i got
I'm trying to use gluLookAt to move the camera in my iPhone game, but
I'm having some troubles converting a orthogonal camera to a perspective one, using OpenGL.
I am using glLookAt to control my camera view. I use the following code
using c++ on windows, trying to set the locale to be used by the
Using a CSS image sprite, I'm creating an 'interactive' image where hovering over certain

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.