Perl OpenGL
From Wikipedia, the free encyclopedia
| Perl OpenGL | |
|---|---|
A screenshot illustrating FBO and Vertex/Fragment program extensions via POGL |
|
| Developed by | Stan Melax, Kenneth Albanowski, Ilya Zakharevich, Jean-Louis Morel, Bob Free |
| Latest release | 0.56_01 / September 11, 2007 |
| OS | Cross-platform |
| Genre | 3D computer graphics software (library/API) |
| License | Perl Artistic and GPL licenses |
| 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.
Contents |
[edit] Platform Support
- Windows: NT/XP/Vista
- Mac OS X: v10.4/10.5
- Linux: Fedora 6, Debian/Ubuntu (Etch/Dapper), Gentoo
- FreeBSD
- Solaris
Confirmed with
- nVidia (Quadro-110M,6600,6800,7300,7800,7950,8800)
- ATI (Radeon 9000/9200, FireGL)
- Cygwin/X (Mesa)
[edit] Interoperability
[edit] 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.
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).
Benchmarks demonstrate GetImagePixels is 188x faster than ImageToBlob or GetPixels.
[edit] 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.
[edit] Performance
| The neutrality of this section is disputed. Please see the discussion on the talk page.(May 2008) Please do not remove this message until the dispute is resolved. |
| This section may contain original research or unverified claims. Please help Wikipedia by adding references. See the talk page for details.(May 2008) |
POGL provides OpenGL performance comparable to that of C, and consistently outperforms other Perl Bindings like SDL::OpenGL and other language bindings like Python.
- Benchmarks with source are available on the POGL Developer's Site
[edit] Comparison With Other Language Bindings
| The neutrality of this section is disputed. Please see the discussion on the talk page.(May 2008) Please do not remove this message until the dispute is resolved. |
| This section may contain original research or unverified claims. Please help Wikipedia by adding references. See the talk page for details.(May 2008) |
[edit] Perl vs C
General Purpose GPU (GPGPU) processing is one area in which Perl compares with compiled languages in terms of performance.
GPU benchmarks show no significant performance differences between C and Perl (via POGL), when rendering a realtime 3D animated object with dynamically generated texturemaps.
GPGPU vertex shaders can execute complex c-like code on large arrays of data, rarely touching the CPU. The CPU is left doing event handling, system calls, disk I/O and UI - which contributes a minor portion of the overall processing time. The performance difference between C and Perl becomes statistically insignificant.
Since GPU performance depends on tight integration with an OS' windowing system (WGL/X11/etc), OpenGL APIs (particularly GPGPU extensions) are OS-dependent. POGL abstracts these dependencies, allowing portable code.
- Portable benchmark source (in C and Perl) are available on the POGL Developer's Site.
[edit] Perl vs Java
Perl tends to rely on more binary modules than Java, providing additional performance benefits[citation needed]. POGL is a compiled module, and may be used in conjunction with compiled imaging modules (such as ImageMagick) for loading/saving data arrays (textures).
As of this writing, the Java OpenGL (JOGL) binding does not support Framebuffers and other advanced GPGPU extensions[citation needed].
[edit] Perl vs Python
As of this writing, Python OpenGL bindings do not support Framebuffers and other advanced GPGPU extensions.[citation needed]
- Benchmarks demonstrate that POGL performs over 20% faster than Python [1]. This includes a blog posting by PyOpenGL's author explaining why Python's OpenGL implementation is likely to be slower than POGL. These benchmarks are based on Trislam, an independent OpenGL benchmark; these results were independently reproduced by Trislam's author.
[edit] OpenGL Objects
POGL provides specialized objects that dramatically 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.
The result is maximized performance, with the added flexibility/portability of Perl.
[edit] 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
[edit] OpenGL::Image (OGI)
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 [2].
[edit] 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 [3].
[edit] Sample Renderings
[edit] Status and Standardization
The latest CPAN release of the following POGL modules are
- OpenGL v0.56
- OpenGL-Image v1.02
- OpenGL-Shader v1.00
Updates and binary distributions are available on Graphcomp's Perl OpenGL (POGL) site.
POGL supports the following OpenGL extensions:
- GL_ARB_color_buffer_float
- GL_ARB_depth_texture
- GL_ARB_draw_buffers
- GL_ARB_fragment_program
- GL_ARB_fragment_program_shadow
- GL_ARB_fragment_shader
- GL_ARB_half_float_pixel
- GL_ARB_multisample
- GL_ARB_multitexture
- GL_ARB_pixel_buffer_object
- GL_ARB_point_parameters
- GL_ARB_point_sprite
- GL_ARB_shader_objects
- GL_ARB_shading_language_100
- GL_ARB_shadow
- GL_ARB_texture_border_clamp
- GL_ARB_texture_cube_map
- GL_ARB_texture_env_add
- GL_ARB_texture_env_combine
- GL_ARB_texture_env_dot3
- GL_ARB_texture_float
- GL_ARB_texture_mirrored_repeat
- GL_ARB_texture_non_power_of_two
- GL_ARB_texture_rectangle
- GL_ARB_vertex_buffer_object
- GL_ARB_vertex_program
- GL_ARB_vertex_shader
- GL_ATI_texture_float
- GL_ATI_texture_mirror_once
- GL_EXT_Cg_shader
- GL_EXT_abgr
- GL_EXT_bgra
- GL_EXT_blend_color
- GL_EXT_blend_subtract
- GL_EXT_framebuffer_object
- GL_EXT_packed_pixels
- GL_EXT_pixel_buffer_object
- GL_EXT_rescale_normal
- GL_EXT_separate_specular_color
- GL_EXT_shadow_funcs
- GL_EXT_stencil_wrap
- GL_EXT_texture3D
- GL_EXT_texture_cube_map
- GL_EXT_texture_env_combine
- GL_EXT_texture_env_dot3
- GL_EXT_texture_filter_anisotropic
- GL_EXT_texture_lod_bias
- GL_EXT_texture_mirror_clamp
- GL_EXT_vertex_array
- GL_HP_occlusion_test
- GL_IBM_rasterpos_clip
- GL_NV_blend_square
- GL_NV_copy_depth_to_color
- GL_NV_depth_clamp
- GL_NV_fog_distance
- GL_NV_fragment_program2
- GL_NV_fragment_program_option
- GL_NV_light_max_exponent
- GL_NV_packed_depth_stencil
- GL_NV_texgen_reflection
- GL_NV_texture_expand_normal
- GL_NV_texture_rectangle
- GL_NV_texture_shader
- GL_NV_texture_shader2
- GL_NV_texture_shader3
- GL_NV_vertex_program2_option
- GL_NV_vertex_program3
- GL_S3_s3tc
- GL_SGIS_generate_mipmap
- GL_SGIS_texture_lod
- GL_SGIX_depth_texture
- GL_SGIX_shadow
- GL_SUN_slice_accum
The primary author of this release is Bob Free of Graphcomp.
Bob Free was made primary owner of CPAN's Perl OpenGL module on April 13, 2007.
[edit] 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 Benchmarks - C vs Perl, Perl vs Python
- OpenGL::Array (OGA) Documentation
- OpenGL::Image (OGI) Documentation
- OpenGL::Shader (OGS) Documentation
- O'Reilly Lightning article: Perl Outperforms C with OpenGL
- POGL Currents: POGL Developer's Blog
- POGL News: Signup for Graphcomp's Monthly Newsletter
- SIGGRAPH 2007: POGL live reporting from San Diego

