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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:20:38+00:00 2026-05-26T20:20:38+00:00

I am trying to rotate a quad around its center, but when I run

  • 0

I am trying to rotate a quad around its center, but when I run the app the quad rotates around the 0,0 position of the screen, I cant work out why, as everything looks fine to me. Any help would be greatly appreciated.

glPushMatrix();
glTranslatef(pxob->x, pxob->y, 0);

glRotatef(pxob->theta,0.0f,0.0f,1.0f);

glBegin(GL_QUADS);
    glColor3f((28.0f / 255.0f), (28.0f / 255.0f), (28.0f / 255.0f)); 

    glVertex3f(pxob->x - (SIZE / 2), pxob->y- (SIZE / 2), 0);
    glVertex3f(pxob->x + (SIZE / 2), pxob->y- (SIZE / 2), 0);
    glVertex3f(pxob->x + (SIZE / 2), pxob->y + (SIZE / 2), 0);
    glVertex3f(pxob->x- (SIZE / 2), pxob->y + (SIZE / 2), 0);
glEnd();
glPopMatrix();

EDIT:
Thank you Krom, for all your help and guiding me through it. I did have to call glTranslatef before glRotatef though as it wanted to still rotate around the 0,0 position. Thanks again!

  • 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-26T20:20:38+00:00Added an answer on May 26, 2026 at 8:20 pm

    You need to glRotatef first, then glTranslatef.

    This is because first object needs to be multiplied by rotation matrix (rotate object around its center), and then apply the translation matrix (move the rotated object to desired position).

    If you do it the other way round the translated object will be rotated around 0;0 coordinates.

    EDIT: Looking at your code – you build the quad with X/Y offset whereas you’ve already applied it to glTranslatef. Thats probably a mistake. The code should be:

    glVertex3f(-SIZE / 2, -SIZE / 2, 0);
    glVertex3f( SIZE / 2, -SIZE / 2, 0);
    glVertex3f( SIZE / 2,  SIZE / 2, 0);
    glVertex3f(-SIZE / 2,  SIZE / 2, 0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to rotate a custom shape around its center, but can not
I'm trying to rotate a node around a custom center point in Ogre3D, but
I've been trying to rotate a polygon around a specified center point but everything
I'm trying to rotate a body around its own center by applying an orthogonal
I am trying to rotate image single round from it's center point but I
I'm trying to rotate an UIImageView constraint by it's center with CGAffineTransformRotate but the
I am trying to rotate an image using slider..its working well but when i
I'm trying to rotate an image around the center. This works generally using RotateAnimation,
I'm trying to rotate a triangle around it's center point. I'm aware that OpenGL
I am trying to rotate a Sprite in three dimensions around its centerpoint, and

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.