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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:43:10+00:00 2026-05-30T04:43:10+00:00

I have an orthogonal perspective which I initialize like so: gl.glViewport(0, 0, Constants.SCREEN_WIDTH, Constants.SCREEN_HEIGHT);

  • 0

I have an orthogonal perspective which I initialize like so:

gl.glViewport(0, 0, Constants.SCREEN_WIDTH, Constants.SCREEN_HEIGHT);   
gl.glMatrixMode(GL10.GL_PROJECTION);    
gl.glLoadIdentity();                    
gl.glOrthof(0,Constants.GAME_AREA_WIDTH, Constants.GAME_AREA_HEIGHT, 0, 1, 10);
gl.glMatrixMode(GL10.GL_MODELVIEW);     
gl.glLoadIdentity();

What I want to do here is have a square start off the top of the screen (at like (x,-100,z) and the that square should descend (on y) while at the same time roate (on z).

The square’s upper-left is what I use as reference for the square’s position.

Ok, now, I think I get how to roate it around itself. I translate the thing to (-squareSize/2, -squareSize/2,z), rotate it along z, then translate back. And indeed, if I only test this rotation it works ok:

    gl.glLoadIdentity();
    angle = angle + 3;
    if(angle>360) {
        angle = angle - 360;
    }
    gl.glTranslatef(xCurrent+size/2, yCurrent+size/2,0);
    gl.glRotatef(angle, 0, 0, 1);
    gl.glTranslatef(-(xCurrent+size/2), -(yCurrent+size/2),0);
//omitted: enable client state, draw elements, disable client state.

With just this, no matter where I place my square (even small negative values for x and y which only make it partially show on the screen), it will rotate around its center.

However I can’t figure out how to add the downwards translation on y. If I do something like this:

    angle = angle + 3;
    if(angle>360) {
        angle = angle - 360;
    }
    gl.glTranslatef(xCurrent+size/2, yCurrent+size/2,0);
    gl.glRotatef(angle, 0, 0, 1);
    gl.glTranslatef(-(xCurrent+size/2), -(yCurrent+size/2),0);

    yCurrent = yCurrent + realSpeed;
    if(yCurrent>Constants.GAME_AREA_HEIGHT+size) {
        yCurrent=-size;
    }
    gl.glTranslatef(0f, yCurrent,0f);

it will only work ok if my square start at (0,0,z) – in which case it will move down and rotate around it’s center.

If however I start it at any positive or negative non 0 value for either x or y, it will still move down, but do a weird spiral motion instead of rotating agains its center.

  • 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-30T04:43:12+00:00Added an answer on May 30, 2026 at 4:43 am

    The OpenGL matrix stack post multiplies. Which effectively means that you should do the most local transformation last.

    So what you probably want to do is to perform a glTranslatef to the tile’s current position, then do the translate/rotate/untranslate sequence to effect your rotation.

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

Sidebar

Related Questions

I have rotation matrix which is not orthogonal. Whats wrong. I can't get it.
I have a number of stored procs which I would like to all run
I have three vectors which are orthogonal b_vect = [1 2] L_vect = [10
I have a set of options, some orthogonal (can be combined in any combination),
Have just started using Visual Studio Professional's built-in unit testing features, which as I
I have an application which I am developing using WPF\Prism\MVVM. All is going well
Have created a ATL COM project through which I am inserting Menu Items to
I would like my dependencies (association, inheritance, etc) represented as non-orthogonal lines. How do
Have advancements in CPU design like dynamic instruction scheduling narrowed the performance gap between
I'm having some troubles converting a orthogonal camera to a perspective one, using OpenGL.

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.