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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:26:15+00:00 2026-06-13T08:26:15+00:00

How to make a step by step display animation in openGL?? I’M doing a

  • 0

How to make a step by step display animation in openGL??

I’M doing a reprap printer project to read a GCode file and interpret it into graphic.
now i have difficulty make a step by step animation of drawing the whole object.
i need to draw many short lines to make up a whole object.
for example:

|-----|
|     |
|     |
|-----|

the square is made up of many short lines, and each line is generated by code like:

glPushMatrix();
.....
for(int i=0; i< instruction[i].size(),i++)
{  ....
   glBegin(GL_LINES);
     glVertex3f(oldx, oldy, oldz);
     glVertex3f(x, y, z);
   glEnd();
}
glPopMatrix();

now i want to make a step animation to display how this square is made. I tried to refresh the screen each time a new line is drawn, but it doesn’t work, the whole square just come out at once. anyone know how to make this?

  • 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-13T08:26:16+00:00Added an answer on June 13, 2026 at 8:26 am

    Typical OpenGL implementations will queue up large number of calls to batch them together into bursts of activity to make optimal use of available communication bandwidth and GPU time resources.

    What you want to do is basically the opposite of double buffered rendering, i.e. rendering where each drawing step is immediately visible. One way to do this is by rendering to a single buffered window and call glFinish() after each step. Major drawback: It’s likely to not work well on modern systems, which use compositing window managers and similar.

    Another approach, which I recommend, is using a separate buffer for incremental drawing, and constantly refreshing the main framebuffer from this one. The key subjects are Frame Buffer Object and Render To Texture.

    First you create a FBO (tons of tutorials out there and as answers on StackOverflow). A FBO is basically an abstraction to which you can connect target buffers, like textures or renderbuffers, and which can be bound as the destination of drawing calls.

    So how to solve your problem with them? First you should not do the animation by delaying a drawing loop. This has several reasons, but the main issue is, that you loose program interactivity by this. Instead you maintain a (global) counter at which step in your animation you are. Let’s call it step:

    int step = 0;
    

    Then in your drawing function you have to phases: 1) Texture update 2) Screen refresh

    Phase one consists of binding your framebuffer object as render target. For this to work the target texture must be unbound

    glBindTexture(GL_TEXTURE_2D, 0);
    glBindFramebuffer(GL_FRAMEBUFFER, animFBO);
    glViewport(0, 0, fbo.width, fbo.height);
    set_animFBO_projection();
    

    the trick now is, that you clear the animFBO only once, namely after creation, and then never again. Now you draw your lines according to the animation step

    draw_lines_for_step(step);
    

    and increment the step counter (could do this as a compound statement, but this is more explicit)

    step++;
    

    After updating the animation FBO it’s time to update the screen. First unbind the animFBO

    glBindFramebuffer(GL_FRAMEBUFFER, 0);
    

    We’re now on the main, on-screen framebuffer

    glViewport(0, 0, window.width, window.height);
    set_window_projection(); //most likely a glMatrixMode(GL_PROJECTION); glOrtho(0, 1, 0, 1, -1, 1);
    

    Now bind the FBO attached texture and draw it to a full viewport quad

    glBindTexture(GL_TEXTURE_2D, animFBOTexture);
    draw_full_viewport_textured_quad();
    

    Finally do the buffer swap to show the animation step iteration

    SwapBuffers();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's see if I can make the step-by-step clear: namespace InventoryManager.Controllers { public class
I'm trying to make a program that lets you input any one-step equation, and
I'm trying to make a tab page based application in Xcode 4.3. First step
i make one class file for jar. and this class have use wurfl. and
I have a form wizard. On step one I need to display a warning
Currently I am using MySQLi to parse a CSV file into a Database, that
I'm trying to make my website display the other pages as a www.example.com/pageone/ link
I have read articles on exception handling in ASP.NET MVC. I want to make
Right now I'm learning Opencart, and I'm trying to make my latest product display
I want to make chat application and for the first step, I need to

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.