NAME
OpenGL::Shader - abstraction for managing OpenGL shaders
SYNOPSIS
########### Load and manage a shaderuse OpenGL(':all');use OpenGL::Shader;# Note: these APIs/methods requires a current GL context/windowglutInit();glutInitDisplayMode(GLUT_RGBA);glutInitWindowSize($w,$h);my $Window_ID = glutCreateWindow( "OpenGL::Shader test" );
DESCRIPTION
This module provides an extensible abstraction for managing OpenGL shaders. As of 1.02 it is included with the OpenGL distribution.
Example usage:
# Get a hashref of shader typesmy $shaders = $OpenGL::Shader::GetTypes();# Test for shader supportmy $ok = OpenGL::Shader::HasType('Cg');# Instantiate a shader - list acceptable shaders by prioritymy $shdr = new OpenGL::Shader('GLSL','ARB');# Get shader type and versionmy $type = $shdr->GetType();my $ver = $shdr->GetVersion();# Load shader by stringsmy $stat = $shdr->Load($fragment,$vertex);# Load shader by filemy $stat = $shdr->LoadFiles($fragment_file,$vertex_file);# Enable$shdr->Enable();# Get vertex attribute ID# returns undef if not supported or not foundmy $attr_id = $self->MapAttr($attr_name);glVertexAttrib4fARB($attr_id,$x,$y,$z,$w);# Get Global Variable ID (uniform/local)my $var_id = $self->Map($var_name);# Set float4 vector variable$stat = $self->SetVector($var_name,$x,$y,$z,$w);# Set float4x4 matrix via OGA$stat = $self->SetMatrix($var_name,$oga);# Do GL rendering# Disable$shdr->Disable();# DoneglutDestroyWindow($Window_ID);
AUTHOR
Bob "grafman" Free - [email protected]. Copyright 2007 Graphcomp - ALL RIGHTS RESERVED.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.