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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:41:02+00:00 2026-06-14T19:41:02+00:00

I need to change my object’s position with respect to camera position. I mean,

  • 0

I need to change my object’s position with respect to camera position. I mean, my object should always be just in front of the camera. It should follow camera movements.What do I need to add my object drawing function?

  • 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-14T19:41:04+00:00Added an answer on June 14, 2026 at 7:41 pm

    If you’re using old-style fixed function matrices, the easiest way to position an object relative to the camera is to do it after removing the camera matrix from the stack. For example, you might have a matrix setup like this:

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt(...); //Or other camera functions.
    for(/*each object*/)
    {
      glPushMatrix();
       //Setup object matrices.
      glTranslatef();
      glRotatef();
    
      //Setup object rendering.
      glDrawElements(); //Draw the object
    
      glPopMatrix();
    }
    

    Then switch it around into this:

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glPushMatrix();
    gluLookAt(...); //Or other camera functions.
    for(/*each object*/)
    {
      glPushMatrix();
       //Setup object matrices.
      glTranslatef();
      glRotatef();
    
      //Setup object rendering.
      glDrawElements(); //Draw the object
    
      glPopMatrix();
    }
    glPopMatrix(); //Remove camera matrix. MODELVIEW is now identity.
    for(/*each camera-relative object*/)
    {
      glPushMatrix();
       //Setup object matrices.
      glTranslatef();
      glRotatef();
    
      //Setup object rendering.
      glDrawElements(); //Draw the object
    
      glPopMatrix();
    }
    

    If you’re using shaders, this is even easier. If you have a matrix stack, just do the same stack-based operation as you see here. If you’re doing something else to build your matrices, just don’t factor the camera matrix into the transform.

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

Sidebar

Related Questions

I need to change the DPI of the System.Drawing.Bitmap object from the default value
Need to change li position by clicking to move up or to move down.
If I need to change the opacity of an object that is rendered through
I need to change a slide's layout programmaticaly with C# (Add-In Express 2009 for
I need to change a static property on an object in our web application.
I need to change the direction of the growth of JTextField object when more
I have a business object that I need to change one of its properties.
I have a Canvas object at start. I need to change color of some
I have a object with a data type of float, I need to change
I need to change the type of object from stdClass to myClass, so like

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.