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

10 thoughts on “PyOpenGL_LAB: A Small Lab for OpenGL Tests Without Compilation!”

  1. Dr. Goulu

    Very Cool !

    GTX 260 / AMD Athlon 64 X2 6000+ / Windows 7 64 bits :
    -10’000 lines : 3400 FPS
    -1’000’000 lines : 150 FPS

    Now I want to add particles that follow the lines, to make a spiral galaxy !
    Do you know a tut on how to do this ?

  2. JeGX Post Author

    Thanks for your scores!

    I haven’t tested yet the vertex pool to make a custom particle system but it’s a way to do. But now that OpenGL code is allowed, another solution is to code the rendering of a particle directly with a billboarded quad or a point sprite. But the Python layer will certainly slow down particles rendering…

  3. tibo


    I tried pyopengl_lab and geexlab’s pyopengl sample and I can’t make it work…(though I see nothing bad in file geexlab_0001.log)

    Other geexlab samples are working ok and I think pyopengl works (I tried with nehe sample).

    Could you help me please :)

    Congratulation for your work guys, it’s very interesting and useful.

  4. JeGX Post Author

    I tested PyOpenGL_LAB.xml by loading with GeeXLab 0.1.4 and it works fine. What kind of problem do you have?

  5. tibo

    I have nothing at screen but the grid (no lines).

    But no errors nor warnings.

    Here’s what I get in the console:

    #>GeeXLab startup in progress…
    #>Python Manager: Python version: 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)]
    #>Python Manager: Plateform: win32
    #>Python Manager: Compiler: [MSC v.1500 32 bit (Intel)]
    #>Python Manager: Build info: r264:75708, Oct 26 2009, 08:23:19
    #>Python installation detected. Happy coding!
    #>Python Manager startup ok.
    #>GeeXLab 0.1.10 started up ok.
    #>GeeXLab Xml Parser – Libxml version 2.7.2
    #>LUA Manager startup ok – Amount of memory used by LUA: 37888 bytes

  6. JeGX Post Author

    You have Python 2.6.4. Maybe the problem comes from this version (GeeXLab 0.1.4 is compiled with Python 2.6.3 SDK…). I have to update GeeXLab with this last version. Will be done in the next few days.

  7. tibo

    Ok thank you.

    I’ll try other python releases too.

    In fact I think I use x86 python release but I have an intel 64 processor. Maybe this is the problem….

  8. tibo

    I tried with python 2.6.3 (32 bits )and still nothing at screen.

    I tried with python AMD64 release and it crashes…

    Maybe problem comes from the fact that your engine is compiled in 32 bits and my computer is 64 bits…

  9. Pingback: Real-Time Rendering · 7 Things for February 10

Comments are closed.