Perl OpenGL

{{Short description|Bindings and Infrastructure for Perl Language}}

{{Orphan|date=December 2015}}

{{Infobox software

| name = Perl OpenGL

| logo =

| screenshot = Perl OpenGL fob2.jpg

| screenshot size = 200px

| caption = A screenshot illustrating FBO and Vertex/Fragment program extensions via POGL

| developer = Stan Melax, Kenneth Albanowski, Ilya Zakharevich, Jean-Louis Morel, Bob Free, Chris Marshall

| latest_release_version = 0.66

| latest_release_date = {{start date and age|2011|07|29}}

| operating_system = Cross-platform

| genre = 3D computer graphics software (library/API)

| license = GNU General Public License, Artistic License

| website = {{URL|sourceforge.net/projects/pogl}}

}}

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 operating system specific proc handlers, and supports OpenGL Utility Toolkit (GLUT), a simple cross-platform windowing interface.

POGL provides additional Perl-friendly application programming interfaces (API) for passing and returning strings and arrays.

The primary maintainer of Perl OpenGL is Chris Marshall.[https://metacpan.org/author/CHM Chris Marshall]

As of July 3, 2011, the [http://sourceforge.net/projects/pogl/ Perl OpenGL Project] on [http://sourceforge.net/projects/pogl/ SourceForge.net] was started and all development and module support going forward has moved there.

Platform support

{{More citations needed|section|date=November 2023}}

Confirmed with:{{Cite web |title=Language bindings - OpenGL Wiki |url=https://www.khronos.org/opengl/wiki/Language_bindings |access-date=2023-07-20 |website=www.khronos.org}}

Interoperability

= Perl Data Language =

POGL is used as the OpenGL binding for the 3D graphics in the Perl Data Language (PDL).

= ImageMagick: image loading, modifying, 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 and saving textures and GPGPU data transfer.{{Citation needed|date=August 2009}}

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 with POGL and the above File::Magick APIs to map video to OpenGL textures.

Performance

= Perl vs C =

General Purpose graphics processing unit (GPU, GPGPU) processing is one area in which Perl can be compared with compiled languages in 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.{{cite web

| url=http://graphcomp.com/opengl/bench.html

| title=GPU benchmarks

| publisher=graphcomp.com

| accessdate=4 August 2009}}

They analyze their results by remarking that GPGPU vertex shaders can execute complex C-like code on large arrays of data, rarely touching the CPU.{{cite web

| url=http://www.perl.com/pub/a/2007/04/12/lightning-four.html?page=2

| title=Perl Outperforms C with OpenGL

| date=19 July 2008

| first=Bob| last=Free

| quote=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 GPU performance.

| publisher=perl.com

| accessdate=4 August 2009}}

= Perl vs Python =

Perl OpenGL developers claim that POGL performs over 20% faster than Python.{{cite web

| url=http://graphcomp.com/pogl.cgi?v=0111s3B2

| title=POGL Benchmarks - Perl vs Python

| publisher=graphcomp.com

| accessdate=4 August 2009}}

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.

= 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 performance improvement in transferring images/data between the GPU and IM.

= 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);

  1. Draw here

$shdr->Disable();

Sample renderings

File:Pogl blacklight.jpg|Snap shot of a realtime animated blacklight shader.

Status

The latest CPAN release of the following POGL modules are

  • OpenGL v0.66
  • OpenGL-Image v1.03
  • OpenGL-Shader v1.01

POGL provides access to most of the OpenGL APIs up to 1.2, and OpenGL extensions,{{cite web

| url=http://graphcomp.com/opengl/index.cgi?v=0111s3m2&r=s3m4

| title=Features

| publisher=graphcomp.com

| accessdate=28 December 2009}} such as Framebuffer Objects (FBO) and Vertex Buffer Objects (VBO).{{cite web|url=http://cpansearch.perl.org/src/CHM/OpenGL-0.62/README |title=Perl OpenGL: POGL |publisher=graphcomp.com |date=28 December 2009 |accessdate=28 December 2009 |url-status=dead |archiveurl=https://web.archive.org/web/20100217092042/http://cpansearch.perl.org/src/CHM/OpenGL-0.62/README |archivedate=February 17, 2010 }}

References

{{Reflist|2}}