Perl OpenGL
![]() A screenshot illustrating FBO and Vertex/Fragment program extensions via POGL | |
Developer(s) | Stan Melax, Kenneth Albanowski, Ilya Zakharevich, Jean-Louis Morel, Bob Free |
---|---|
Stable release | 0.57
/ September 27, 2008 |
Operating system | Cross-platform |
Type | 3D computer graphics software (library/API) |
License | GNU General Public License, Artistic License |
Website | graphcomp.com/opengl |
Perl OpenGL (POGL) is a portable, compiled wrapper library that allows OpenGL to be used in the Perl programming language.
POGL provides support for most OpenGL 2.0 extensions, abstracts OS-specific proc handlers, and supports GLUT, a simple cross-platform windowing interface.
POGL provides additional Perl-friendly APIs for passing/returning strings and arrays.
The primary maintainer of Perl OpenGL is Bob Free of Graphcomp. Bob Free was made primary owner of CPAN's Perl OpenGL module on April 13, 2007.
Platform Support
- Microsoft Windows: NT/XP/Vista
- Mac OS X: version 10.5 (Leopard) only
- Linux: Fedora 6, Debian Etch, Ubuntu Dapper, Gentoo
- FreeBSD
- Solaris
Confirmed with:
- nVidia (Quadro-110M,6600,6800,7300,7800,7950,8800)
- ATI (Radeon 9000/9200, FireGL)
- Cygwin/X Window System (Mesa)
Interoperability
ImageMagick - Image Loading/Modification/Saving
The POGL team has collaborated with the ImageMagick team to add PerlMagick APIs that allow GPUs and ImageMagick to share cache buffers via C pointers - optimizing performance for FBOs and VBOs - for use with loading/saving textures and GPGPU data transfer[citation needed].
These APIs have been added to ImageMagick 6.3.5:
- Get('Scene') - returns the number of scenes in an IM image.
- Get('Quantum') - returns IM's cache depth.
- GetImagePixels() - returns a C pointer to IM's image cache.
- SyncImagePixels() - sync's IM's image cache after a write (for large/paged images).
FFmpeg - Video Frame Textures
CPAN's FFmpeg module may be used in conjunction with POGL and the above Image::Magick APIs to map video to OpenGL textures.
Performance
Perl vs C
General Purpose GPU (GPGPU) processing is one area in which Perl can be compared with compiled languages in terms of performance.
Based on their own benchmarks, Perl OpenGL developers claim that there are no significant performance differences between C and Perl (via POGL), when rendering a realtime 3D animated object with dynamically generated texturemaps[1].
They analyze their results by remaking that GPGPU vertex shaders can execute complex c-like code on large arrays of data, rarely touching the CPU.[2].
Perl vs Python
As of this writing, Python OpenGL bindings do not support Framebuffers and other advanced GPGPU extensions.[citation needed]
Perl OpenGL developers claim that POGL performs over 20% faster than Python[3].
OpenGL Objects
POGL provides specialized objects that enhance Perl performance. POGL objects store data as typed C arrays, and pass data between APIs using C pointers - eliminating the need to copy/convert/cast when passing data between interfaces.
OpenGL::Array (OGA)
OGAs store OpenGL data as typed C arrays. OGAs may be populated by C pointer, Perl packed arrays (strings) or Perl arrays.
OGAs may be bound/mapped to VBOs to share data between the GPU and Perl.
Accessor methods provide a means to get/set array elements by C pointer, packed arrays or Perl arrays.
Documentation can be found on POGL's Developer Site
OpenGL::Image (OGI)
POGL is a compiled module, and may be used in conjunction with compiled imaging modules (such as ImageMagick) for loading/saving data arrays (textures).
OGIs use OGAs to wrap image buffers from various imaging libraries. OGI simplifies loading/modifying/saving OpenGL textures, FBOs and VBOs.
OGI provides an extensible plug-in architecture to support new imaging libraries: OGI supports ImageMagick (v6.3.5 or newer), and by default Targa (uncompressed RGBA files).
OGI provides direct C pointer access to ImageMagick's image cache, resulting in dramatic performance in transferring images/data between the GPU and IM.
Documentation can be found on POGL's Developer Site
OGI is available on CPAN as a separate OpenGL-Image module [1].
OpenGL::Shader (OGS)
The OSG module abstracts OpenGL APIs for ARB (assembly), Cg and GLSL shading languages.
$shdr = new OpenGL::Shader();
my $ext = lc($shdr->GetType());
my $stat = $shdr->LoadFiles("fragment.$ext","vertex.$ext");
$shdr->Enable();
$Shader->SetVector('surfacecolor',1.0,0.5,0.0,1.0);
$Shader->SetMatrix('xform',$xform);
# Draw here
$shdr->Disable();
Documentation can be found on POGL's Developer Site
OGS is available on CPAN as a separate OpenGL-Shader module [2].
Sample Renderings
-
Snap shot of a realtime animated blacklight shader.
Status
The latest CPAN release of the following POGL modules are
- OpenGL v0.56
- OpenGL-Image v1.02
- OpenGL-Shader v1.00
POGL support a part of OpenGL_2.0 shaders extensions (as ARB for example)[4].
References
- ^ "GPU benchmarks". graphcomp.com. Retrieved 2009-08-04.
- ^ Bob Free (2008-07-19). "Perl Outperforms C with OpenGL". perl.com. Retrieved 2009-08-04.
GPUs are increasingly taking the load off of CPUs for number-crunching. Modern GPGPU processing leverages C-like programs and loads large data arrays onto the GPU, where processing executes independent of the CPU. As a result, the overall contribution of CPU-bound programs diminish, while Perl and C differences become statistically insignificant in terms of GPU performance.
{{cite web}}
: Check date values in:|date=
(help) - ^ "POGL Benchmarks - Perl vs Python". graphcomp.com. Retrieved 2009-08-04.
- ^ "Features". graphcomp.com. Retrieved 2009-08-04.
External links
- CPAN OpenGL (POGL)
- CPAN OpenGL-Image
- CPAN OpenGL-Shader
- The Official POGL Website - documentation, examples, benchmarks, latest updates
- POGL Video Gallery
- POGL Sample Test App
- OpenGL::Array (OGA) Documentation
- OpenGL::Image (OGI) Documentation
- OpenGL::Shader (OGS) Documentation
- POGL Currents: POGL Developer's Blog
- SIGGRAPH 2007: POGL live reporting from San Diego