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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:53:23+00:00 2026-05-31T08:53:23+00:00

I am trying to write code that will cycle between rendering an animation and

  • 0

I am trying to write code that will cycle between rendering an animation and rendering a heads up display. The animation works, however I am having difficulty switching between the animation’s projection matrix and another orthographic projection matrix for the HUD.

The main loop runs as follows:

init();
while (isAnimationRunning) {
    drawAnimation();
    drawHUD();
}

And the initialization of the surface is:

void init(){
    glEnableClientState(GL10.GL_VERTEX_ARRAY);
    glClearColor(1, 1, 1, 1);
    glMatrixMode(GL11.GL_PROJECTION);
    glLoadIdentity();
    glViewport(0, 0, windowWidth, windowHeight);
    GLU.gluPerspective(gl11, 45.0f, windowWidth / windowHeight, 0.1f, 100.0f);
}

And the code for the animation rendering

void drawAnimation() {
        glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
        glMatrixMode(GL10.GL_MODELVIEW);
        glLoadIdentity();
        GLU.gluLookAt(gl11, x, y, zoom, x, y, 0, 0, 1, 0);
            drawAnimationTextures();
}

And the code for the HUD rendering

void drawHUD(){
        glMatrixMode(GL10.GL_MODELVIEW);
        glPushMatrix();

            // IF THIS LINE IS REMOVED THE ANIMATION DISPLAYS BUT NOT THE HUD
        glLoadIdentity(); 

        glClear(GL10.GL_COLOR_BUFFER_BIT);
        GLU.gluLookAt(gl11, 0, 0, 2, 0, 0, 0, 0, 1, 0);

        glMatrixMode(GL10.GL_PROJECTION);
        glPushMatrix();
        glLoadIdentity();
        GLU.gluPerspective(gl11, 45, aspectRatio, 0.1f, 100.0f);
        glOrthof(-aspectRatio, aspectRatio, -1, 1, -4, 4);

        drawHUDTexture();

    glPopMatrix();
        glMatrixMode(GL10.GL_MODELVIEW);
        glPopMatrix();
}

The screen is blank when this code is implemented. Any ideas what the problem might be?

////////////////////////

void drawTexture(float x, float y, float z, float sizeX, float sizeY,...){
            glEnable(GL10.GL_TEXTURE_2D);
            glPushMatrix();
            bindTexture(texture);
            glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
            glFrontFace(GL10.GL_CW);
            glColor4f(RGB[0], RGB[1], RGB[2], alpha);
            glTranslatef(x, y, z);
            glScalef(sizeX, sizeY, sizeZ);
            glVertexPointer(3, GL10.GL_FLOAT, 0, squareVertexBuffer);
            glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer);
            glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
            glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
            glPopMatrix();
}
  • 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-31T08:53:24+00:00Added an answer on May 31, 2026 at 8:53 am

    Why are you clearing the framebuffer in both routines? You should call it once only in your top level loop. If the animation appears when you comment out the loadidentity but still have the glclear there I am puzzled.

    It looks like the hud overwrites the whole screen, make it semi transparent to check this, it may be so large you’re just seeing a small part of it.

    plus your hud code is setting up a perspective view, then an ortho view – which one do you want?

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

Sidebar

Related Questions

I'm trying to write some Python code that will establish an invisible relay between
I'm trying to write PHP code that will display the logged in user's name.
I'm trying to write code that will load an image from a resource, and
I am trying to write some code that that will draw the line which
I'm trying to write a piece of code that will do the following: Take
Hi I am trying to write an application that will play morse code. I
I'm trying to write some code that will take any object and convert it
I am trying to write some code that will function like google calendars quick
I'm trying to write some code that various sites will embed, calling a script
I am trying so write a bit of code that will search for a

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.