PyOpenGL_LAB: A Small Lab for OpenGL Tests Without Compilation!

PyOpenGL_LAB: GeeXLab + Python + PyOpenGL
1,000,000 random lines

PyOpenGL_LAB is a small application directly derived from GeeXLab. It’s a ready to use PyOpenGL platform. What does it mean? Simply that you can code OpenGL instructions and very quickly see the result without the compilation step. PyOpenGL_LAB already includes the PyOpenGL package so you don’t have to worry about it. Like GeeXLab, PyOpenGL_LAB only requires a properPython 2.6.3 installation.

You can download PyOpenGL_LAB here (only a direct left-click allows the download):
Download PyOpenGL_LAB 0.1.0 Version 0.1.0

Unzip PyOpenGL_LAB somewhere and launch PyOpenGL_LAB.exe. You should see something like this:

PyOpenGL_LAB: GeeXLab + Python + PyOpenGL

In this image you can see 10,000 lines rendered with an OpenGL display list. I found the original OpenGL code here.

PyOpenGL_LAB has 2 important files: and is the initialization file. For example, this file contains the number of lines to be drawn. You can of course add OpenGL commands into this file. is executed only once. contains immediate mode commands and this script is executed every frame. Immediate mode means you talk directly with the renderer (or GPU) via two methods: OpenGL commands or HYP_Renderer library.
HYP_Renderer can be seen like a wrapper over OpenGL commands. Some functions of HYP_Renderer lib can be directly written in OpenGL like HYP_Renderer.SetPointSize() but others like HYP_Renderer.ApplyCurrentViewMatrix() are a bit more complex so they are really useful.

Here is the code of


Add your rendering code below:
glScalef(15.0, 15.0, 15.0)

if useDisplayList:
  i = 0.
  for i in range(gNumLines):
    t = random.uniform(0,3)
    x = math.sin(i+t*.14)
    y = math.sin(i*.2+t*.114)
    z = math.cos(i*.12+t*.114)**2
    glColor3f( x,y-x,z*.1 )
    glVertex3f( x,y,z )

HYP_Camera.ApplyToRenderer() applies camera transformation (projection and view matrices as well as viewport) to the renderer. This is cool: you’re not going to bother with camera settings if the purpose of your test is not camera management.

The rest of the code draws the random lines: either using a display list or with direct calls to glBegin(GL_LINES) and glVertex3f (very slow!).

The OpenGL rendering context and swap buffer are managed by GeeXLab engine so forget them!

Once you’ve finished your modifications, press CTRL+R in GeeXLab to reload PyOpenGL_LAB main file.

Just for fun, I did some benchmarks and here are the results:

System: Core2Duo E8400 / GeForce GTS 250 (fw191.07):

  • gNumLines = 100*100 = 10,000 lines – 2580 FPS
  • gNumLines = 200*200 = 40,000 lines – 1250 FPS
  • gNumLines = 200*500 = 100,000 lines – 520 FPS
  • gNumLines = 1000*500 = 500,000 lines – 188 FPS
  • gNumLines = 1000*1000 = 1,000,000 lines – 102 FPS

And you, what are your FPS at this LineMark?

I’d like to see the score with professional graphics cards like a NVIDIA Quadro or ATI FirePro.

Here are some screenshots:

PyOpenGL_LAB: GeeXLab + Python + PyOpenGL
40,000 lines

PyOpenGL_LAB: GeeXLab + Python + PyOpenGL
100,000 lines

PyOpenGL_LAB: GeeXLab + Python + PyOpenGL
500,000 lines

PyOpenGL_LAB: GeeXLab + Python + PyOpenGL
1,000,000 lines

PyOpenGL_LAB: GeeXLab + Python + PyOpenGL
1,000,000 lines

↑ Grab this Headline Animator