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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:43:41+00:00 2026-05-31T05:43:41+00:00

I have an OpenGL ES scene which is made up of about 20 objects.

  • 0

I have an OpenGL ES scene which is made up of about 20 objects. In the render method for each object I have code which scales, rotates and positions (using glmultmatrix) that object in the correct place in each scene (see code below).

My question is how can I then apply a transformation to the entire scene as a whole ? E.g scale / enlarge the entire scene by 2 ?

glPushMatrix();
glLoadIdentity();

//Move some objects.

if (hasAnimations) {

    glTranslatef(kBuildingOffset);
    //scale
    glScalef(kModelScale);

    //glMultMatrixf(testAnimation);

    zRotation = kBuildingzRotation
    xRotation = kBuildingxRotation
    yRotation = kBuildingyRotation
    glRotatef(yRotation, 0.0f, 1.0, 0.0f);
    glRotatef(xRotation, 1.0f, 0.0f, 0.0f);
    glRotatef(zRotation, 0.0f, 0.0f, 1.0f);

    //NSLog(@"ANIMATION FRAME IS %d", animationFrame);
    //NSLog(@"MATRICE IS %f", animationArray[0][0]);
    glMultMatrixf(animationArray[animationFrame]);
    //glMultMatrixf(matricesArray);
    glMultMatrixf(matricePivotArray);

    //glMultMatrixf(testAnimation);
}

//First rotate our objects as required.

if ([objectName isEqualToString:@"movingobject1"]) {

    glTranslatef(kFan1Position); 
    glScalef(kModelScale);
    glMultMatrixf(matricesArray);

    glTranslatef(0, 0, 0);

    zRotation +=kFanRotateSpeed;
    yRotation =kyFanFlip;
    xRotation = kxFanRotation;
    glRotatef(zRotation, 0.0f, 0.0f, 1.0f);
    glRotatef(yRotation, 0.0f, 1.0f, 0.0f);
    glRotatef(xRotation, 1.0f, 0.0, 0.0f);

    glTranslatef(0.0, 0.0, -300);

}

if ([objectName isEqualToString:@"movingobject2"]) {

    glTranslatef(kFan2Position);
    glScalef(kModelScale);
    glMultMatrixf(matricesArray);

    glTranslatef(0, 0, 0);

    zRotation +=kFanRotateSpeed;
    yRotation = kyFanFlip;
    xRotation = kxFanRotation;
    glRotatef(-kFan3YOffset, 0.0, 1.0, 0.0);
    glRotatef(zRotation, 0.0f, 0.0f, 1.0f);
    glRotatef(yRotation, 0.0f, 1.0f, 0.0f);
    glRotatef(xRotation, 1.0f, 0.0, 0.0f);
    glRotatef(kFan3YOffset, 0.0f, 1.0f, 0.0f);

    glTranslatef(0.0, 0.0, -300);

}

if ([objectName isEqualToString:@"movingobject3"]) {

    glTranslatef(kFan3Position); 
    glScalef(kModelScale);
    glMultMatrixf(matricesArray);

    glTranslatef(0, 0, 0);

    zRotation +=kFanRotateSpeed;
    yRotation =kyFanFlip;
    xRotation =kxFanRotation;
    glRotatef(-kFan2YOffSet, 0.0, 1.0, 0.0);
    glRotatef(zRotation, 0.0f, 0.0f, 1.0f);
    glRotatef(yRotation, 0.0f, 1.0f, 0.0f);
    glRotatef(xRotation, 1.0f, 0.0f, 0.0f);
    glRotatef(kFan2YOffSet, 0.0, 1.0, 0.0);

    glTranslatef(0.0, 0.0, -300);

}

//Then position the rest of the scene objects.

if (![objectName isEqualToString:@"movingobject1"])
    if (![objectName isEqualToString:@"movingobject2"])
        if(![objectName isEqualToString:@"movingobject3"])
            if (!hasAnimations) {

    glLoadIdentity();
    glTranslatef(kBuildingOffset);

//scale
    glScalef(kModelScale);

    zRotation = kBuildingzRotation
    xRotation = kBuildingxRotation
    yRotation = kBuildingyRotation
    glRotatef(yRotation, 0.0f, 1.0, 0.0f);
    glRotatef(xRotation, 1.0f, 0.0f, 0.0f);
    glRotatef(zRotation, 0.0f, 0.0f, 1.0f);

if ([Matrices count]!=0) {
    glMultMatrixf(matricesArray);
}

if (hasPivotNode) {
    glMultMatrixf(matricePivotArray);
}
}

[mesh render];
glPopMatrix();
//restore the matrix
  • 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-31T05:43:43+00:00Added an answer on May 31, 2026 at 5:43 am

    You should be able to achieve this easily enough by pushing the transform matrix you desire on to the matrix stack before you do any of your object-specifc transforms, but then don’t load the identity matrix each time you push another matrix onto the stack. Practically speaking, this will transform all subsequent matrix operations. This is the basic pattern…

    // Push an identity matrix on the bottom of the stack...
    glPushMatrix();
    glLoadIdentity();
    
    // Now scale it, so all subsequent transforms will be
    // scaled up 2x.
    glScalef(2.f, 2.f, 2.f);
    
    foreach(mesh) {
    
        glPushMatrix();
        //glLoadIdentity(); This will erase the scale set above.
        glDoABunchOfTransforms();
        [mesh render];
        glPopMatrix();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a textured object in my OpenGL ES scene (version 1.1) for which
I have an OpenGL scene in which the user can rotate the camera. I
I have a scene in OpenGL, which is rotated and translated, and I would
I am trying to assemble a scene in opengl, using already made objects. The
I have an opengl scene rendering on an EAGLView layer and some other elements
So I have some openGL code (such code for example) /* FUNCTION: YCamera ::
I have an OpenGL scene with a top left coordinate system. When I glScale
I have an NSTimer that runs at 60hz. With an OpenGL scene loaded and
I am a beginner at using openGL. I have used a program which I
we've been creating several half-transparent 3D cubes in a scene by OpenGL which displays

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.