3-D Programming with Python
Now that you have seen how to write simple OpenGL programs, you are probably wondering if Python can scale up to the demands of more advanced 3-D applications. While the performance of a PyOpenGL program generally lags behind that of its C or C++ counterpart, optimization techniques can narrow the gap considerably.
The main strategy in improving execution speed is to reduce the amount of time spent within the Python interpreter by moving expensive operations into native code. One means of accomplishing this is to rewrite sluggish parts of the program in a fast, natively compiled language like C or C++. Implementing these compiled portions of the program as Python extension modules allows the remaining interpreted Python code to access their functionality. While this approach certainly has potential for speeding things up, it lacks the simplicity of a pure Python solution. It also requires you understand how to write Python extension modules in a language that compiles to native code. Besides, if you wanted to do it in C, you wouldn't have started messing around with Python in the first place!
OpenGL display lists provide a way to move operations into native code without any of the headaches associated with the former approach of writing extension modules. Display lists allow OpenGL programs to cache a set of commands further down in the rendering pipeline. In some environments, OpenGL even can store display lists on the graphics card itself, far away from the bottleneck of the Python interpreter.
The glGenLists() command creates an array of empty display lists. It takes a single integer argument, the number of display lists, to generate. It returns the number of lists that were successfully created. Wrapping a set of OpenGL operations with the commands glNewList() and glEndList() fills a specified display list. Once stored, subsequent invocations of that set of operations requires only a single command, glCallList(). The syntax for using display lists in PyOpenGL is pretty much the same as in OpenGL with C.
We have just begun to scratch the surface of OpenGL programming techniques in Python. For more information, make sure to check out the documentation that comes with PyOpenGL or on-line at pyopengl.sourceforge.net/documentation/index.html.
|illusive networks' Deceptions Everywhere||Aug 29, 2016|
|Happy Birthday Linux||Aug 25, 2016|
|ContainerCon Vendors Offer Flexible Solutions for Managing All Your New Micro-VMs||Aug 24, 2016|
|Updates from LinuxCon and ContainerCon, Toronto, August 2016||Aug 23, 2016|
|NVMe over Fabrics Support Coming to the Linux 4.8 Kernel||Aug 22, 2016|
|What I Wish I’d Known When I Was an Embedded Linux Newbie||Aug 18, 2016|
- illusive networks' Deceptions Everywhere
- Happy Birthday Linux
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- What I Wish I’d Known When I Was an Embedded Linux Newbie
- New Version of GParted
- All about printf
- Updates from LinuxCon and ContainerCon, Toronto, August 2016
- Tech Tip: Really Simple HTTP Server with Python
- Blender for Visual Effects
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide