Original Post
Hi. I'm currently implementing a small OpenGL 3D engine in Python. Since I have a small mesh based mostly static world, I think that it will be fast enough after some optimizations. At this stage I'm getting 20-30 fps on a 200k triangle scene in 1280x1024 with 9 per pixel spot-lights on an ATI x1300 Pro/Athlon XP 3000+ which is more than I expected given the video card. The app is very CPU bound since the frame-rate remains the same when using a small window and it goes to 50-60 fps on an Intel Core 2 Duo E6600 with same video-card (recent modifications brought it down to 5 fps because of the very inneficient light position uniform updating code). I already got a huge speed increase by moving the matrix multiplication code from Python to C++. Now I am thinking of doing this: instead of walking the scene graph each frame and rendering each node from Python I will do this only once in the beginning and build for each object a table which will describe the OpenGL calls required to draw the object. Something like this: 1, glActiveTexture, 0 2, glBindTexture, GL_TEXTURE_2D, texture 1, glUseProgram, program 4, glUniformMatrix4fv, wvpLocation, 1, GL_FALSE, wvpMatrix 1, glEnableVertexAttribArray, 0 6, glVertexAttribPointer, 0, 3, GL_FLOAT, GL_FALSE, 0, NULL The first number is the function parameter count, followed by the actual pointer to the OpenGL function followed by 32 bit parameters. Then I invoke a C++ method which walks the table and executes it. The only problem is computing stuff that varies from frame to frame, like wvpMatrix. I see two possibilities: either adding a special marker to the table which would make the C++ code call back into Python to do the computation or computing these values in a preprocessing step in Python code and storing the results in a temporary structure for them to be available when executing the table. What I want to ask is this: does this kind of optimization has a name? Any papers on it? What are your thoughts?