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

The Archive Base Latest Questions

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

I have a very simple program with my introductor OpenGL stuff. I have 3d

  • 0

I have a very simple program with my introductor OpenGL stuff. I have 3d vertex on the screen and the whole system is being rotated along y axis.

float rotation =0;
//update function
rotation = rotation +1;

The draw function looks something like this:

glPushMatrix();
        glTranslatef(500,390,0);
        glRotatef(rotation,0.0,1.0,0.0);
        glVertex3d(365,50,0);
glPopMatrix();

When the glVertex is being rotated, its position on the screen is changing obviously. But the coordinates of the point itself are not. How do I get the current coordinates of the point on the screen which has been rotated by glRotatef, when their ‘actual’ coordinates are stationary?

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

    How do I get the current coordinates of the point on the screen which has been rotated by glRotatef, when their ‘actual’ coordinates are stationary?

    You have to mimick the OpenGL transformation pipeline. Since you’re using old-and-dusted fixed function OpenGL, I’m going to show you how to do this with old-and-dusted GLU:

    First we need the current viewport and projection matrix

    GLint viewport[4];
    glGetIntegerv(GL_VIEWPORT, viewport);
    
    GLdouble projection[16];
    glMatrixMode(GL_PROJECTION);
    glGetDoublev(GL_PROJECTION_MATRIX, projection);
    
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
        glTranslatef(500,390,0);
        glRotatef(rotation,0.0,1.0,0.0);
    

    at this point the modelview matrix holds the modelview transform applied so get this one, too.

    GLdouble modelview[16];
    glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
    

    Now we have everything to project it.

    GLdouble obj_x, obj_y, obj_z; // point coordinates
    GLdouble win_x, win_y, win_z; // receives window coordinates
    gluProject( obj_x, obj_y, obj_z,
                modelview, projection, viewport,
                &win_x, &win_y, &win_z );
    

    There you go. I recommend looking at the sourcecode of gluProject as provided by MesaGL. But basically it’s these steps:

    clip = Projection · Modelview · obj{x,y,z,w}
    clip = clip / clip.w;
    win{x,y} = viewport{x,y} + viewport{width,height} * (clip{x,y} + 1)/2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple openGL program in C++. I have made a Sphere
I have a very simple test program, running on Solaris 5.8: #include <stdio.h> #include
It's a very simple program. I have a function defined on the top and
I have a very simple question. I have a program that accepts an integer
I have very simple OpenGL ES example similar to Hehe's example : http://nehe.gamedev.net/tutorial/ios_lesson_02__first_triangle/50001/ As
So I have a very simple program that reads the 3 first bytes of
I have a very simple program that I am trying to improve performance. One
I have a very simple SDL program that uses only 1MB of memory with
I have very simple C program: int foobar(int a) { int b = a;
I have a very simple program on OpenCV: #include <cv.h> #include <cxcore.h> #include <highgui.h>

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.