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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:29:10+00:00 2026-06-17T07:29:10+00:00

I am having some performance problems with OpenGL. I essentially want to create a

  • 0

I am having some performance problems with OpenGL. I essentially want to create a grid of squares. I first tried to implement it where each square I would translate to where I want a square, then multiply the model and view matrix, pass it into the shader program and draw the square. I would do this for each square. After creating about 50 squares the frame rate would start to drop to less than what I desire.

I then tried a VBO method where I basically would generate a vertex buffer each time the squares change location. Frame rate increased dramatically with this approach, but I have too much latency when something changes because it has to regenerate all the vertex locations.

What I think I need is a matrix stack… I used opengl 1.1 before and would use push/pop. I don’t really understand the concepts of what that was doing though and how to reproduce it. Does anyone know where a good example of a matrix stack is that I can use as an example? Or possibly just a good explanation for one?

  • 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-17T07:29:12+00:00Added an answer on June 17, 2026 at 7:29 am

    You can check this tutorial, is basically doing the same you want to achieve, but with cubes instead of squares. It uses a VBO as well:

    http://www.learnopengles.com/android-lesson-seven-an-introduction-to-vertex-buffer-objects-vbos/

    About the matrices, in OpenGL ES 2.0 you don’t have any matrix related functions anymore, but you can use the glmath library, which does the same (and much more):

    http://glm.g-truc.net/

    It’s a header library, so you just need to copy it somewhere and include it where you need it.

    I’m not sure if I completely understand your objective, but I guess you could copy the data of one square in the grapic card (using a VBO) and then repeatedly update the model matrix for every square.

    The concept of a matrix stack makes sense if your squares have some kind of hierarchy between them (for instance, if one of them moves, the one to its left has to move accordingly).

    You can imagine it as a skeleton made out of squares. If the shoulder moves, all the pieces in the arm will move as well (hands, fingers, and so on).
    You can emulate that by using a matrix stack. You can create some kind of tree with all your squares, so that every square has a list of “descendants”, which will apply the same transformation as the parent. then you can render recursively all the squares like that:

    1. Apply transform to the root square(s)
    2. Push the transform in a queue
    3. Call the same render function for every child
    4. Every child reads the matrix on the top of the queue, multiplies
      it by its own transformation, push the new matrix on the queue and
      calls the children
    5. After that every child pops out the matrix they pushed before

    Using the glmath is quite easy, you just need to create a queue (std:vector in this case) of matrices:

    std::vector<glm::mat4> matrixStack;
    

    And then for every child:

    glm::mat4 modelMatrix = matrixStack.back();
    glm::mat4 nodeTransform = /*apply your transform here*/
    glm::mat4 new = modelMatrix * nodeTransform;
    matrixStack.push_back(new);
    /*Pass in the new matrix to the shader and call to glDrawArrays or whatever to render your square*/
    
    for (every child) {
        render();
    }
    matrixStack.pop_back();
    

    For the drawing part, I guess you could bind the vertex array with the square vertices, and then update the model matrix in the shader for every child, before calling glDrawArrays.

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

Sidebar

Related Questions

I'm having some performance problems where a SQL query calculating the average of a
I am having some performance problems with IE 7, whereby the page pauses during
I'm having some problems with performance using the Bouncy Castle Provider when generating DH
Having some out-of-memory problems with a 32-bit process in Windows I begun using Performance
I am having some performance problems that have left me baffled. I am using
I am having some performance problems with my Delphi 2006 app. Can you Suggest
Currently having some problems- now = datetime.datetime.now() month = now.strftime(%B) site = wikipedia.getSite('en', 'wikiquote')
Im having some problems getting the Sticky Footer to work on my site. If
I'm trying to refactor some C++ code due to performance problems, and I'm wondering
C#, .NET4. We have some performance critical code that is causing some problems. It

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.