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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:41:56+00:00 2026-05-27T10:41:56+00:00

I have been teaching myself OpenGL programming using the Python wrapper PyOpenGL, and am

  • 0

I have been teaching myself OpenGL programming using the Python wrapper PyOpenGL, and am now working on my first project with it. This project is a music visualizer (not dissimilar to whitecap) using many independently moving and independently colored cubes.

My current method is to have a display list for one cube and call it repeatedly changing color and location with glColor and glTranslatef like so (pseudocode):

glPushMatrix()
glPushMatrix() #Why do I need to call this twice?
for x in xrange(...):
    for z in xrange(...):
        y = height[x,z] #numpy array
        glTranslatef(x,y,z)
        glColor((r,g,b))
        glCallList(cube)
        glTranslatef(-x,-y,-z)
glPopMatrix()
glPopMatrix()

In this manner I can render about 10,000 cubes before I start to notice the framerate, this is OK but I would like it to be faster so my program is portable to less able computers, so my question is:

What would be the most efficient way to render many identical but
independent objects, and will I get much better performance than I am
now using display lists?

Should I be using C or learning vertex
buffering?

Note: I found disabling the error checking gave a sizable performance boost.

  • 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-27T10:41:57+00:00Added an answer on May 27, 2026 at 10:41 am

    It is like the common sense was wrong. You manually restore the transformation (glTranslatef(-x,-y,-z)) after drawing the cube, this way glPopMatrix is not only called twice for no reason, but it is also useless because you did all the work for it.
    Correct code would like like so:

    for x in xrange(...):
        for z in xrange(...):
            y = height[x,z] #numpy array
            glPushMatrix() #Remember the matrix
            glTranslatef(x,y,z) #change the matrix
            glColor((r,g,b))
            glCallList(cube)
            glPopMatrix() #Restore tha matrix as it was before glTranslate changed it
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to programming in general and have been teaching myself using Android
I've been teaching myself F# for a while now. I've read Programming F# by
I'm a novice at programming although I've been teaching myself Python for about a
I have been teaching myself programming for couple of years, and I was sure
I've taught myself Obj-C, and have been self-teaching Cocoa, but adding Core Data to
I have been working on a web services related project for about the last
I have been working with Visual Studio (WinForm and ASP.NET applications using mostly C#)
I have been teaching myself JS and Jquery primarily for GM scripts (im not
I'm pretty good at Haskell and have been teaching myself J . I've read
I have recently been teaching myself Haskell, and one of my exercises was 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.