Python OpenGL Optimization
Lately, we have been working on an article for a well-known Linux Magazine for which we are developing a custom Vector Field renderer. Technologies being leveraged to undertake this task involve Python, for fast-paced development, and OpenGL, for powerful and portableÂ 3D graphics.
The renderer should be able to display different sized Vector Fields, with dimensions ranging from 16×16, 32×32, 64×64, 96×96, or even more elements, depending on the user’s configuration.
Each Field element is represented by a quad (denoting a tile) and an arrow (denoting a direction). Each quad consists of two triangles and each arrow of consists of three. For a Vector Field as small as 16×16 elements, this amounts to rendering a total of 1.280 triangles, whereas for a 64×64 element-field this number increases up to 20.480 triangles, all of which have to be rendered at once and in real time!
The huge number of triangles to be rendered easily shows the limitations of the Python binding for the OpenGL library when careful design and optimization is not taken into account for developing a rendering application.
By carefully selecting and leveraging the fastest performing features in the OpenGL library specification, we were able to dramatically speed up the normal rendering process, being able to push triangle data through the rendering pipeline of the video card at incredible speeds for the fastest throughput. The result is the development of a realtime rendering application, capable of drawing thousands of triangles hundreds of times every second, providing very smooth visualization of the data provided.
At Algorithmia we are focused on working in the fields of Visualization, Acceleration and cross-platform development. This project stands as a beacon, proving how the combination of all three areas of expertise can produce highly optimized visualization solutions capable of displaying and manipulating large volumes of data in real time and on any platform.