OpenGL::Sandbox::Program - Wrapper object for OpenGL shader program pipeline
version 0.120
OpenGL shaders get combined into a pipeline. In older versions of OpenGL, there was only one program composed of a vertex shader and fragment shader, and attaching one of those shaders was a global change. In newer OpenGL, you may assemble multiple program pipelines and switch between them.
This class tries to support both APIs, by holding a set of shaders which you can then "bind". On newer OpenGL, this calls glUseProgram. On older OpenGL, this changes the global vertex and fragment shaders to the ones referenced by this object.
glUseProgram
Human-readable name of this program (not GL's integer "name")
Boolean; whether the program is ready to run. This is always 'true' for older global-program OpenGL.
A hashref of shaders, each of which will be attached to the program when it is activated. The keys of the hashref are up to you, and simply to help diagnostics or merging shader configurations together with defaults.
A convenient accessor for listing out the values of the "shader" hash.
The OpenGL integer 'name' of this program. On older OpenGL with the global program, this will always be undef. On newer OpenGL, this should always return a value because accessing it will call glCreateProgram.
undef
glCreateProgram
True if the id attribute has been lazy-loaded already.
Lazy-built hashref listing all uniforms of the compiled program.
Whether this has been lazy-built yet
Remove the cache, to be rebuilt on next use
$program->bind;
Begin using this program as the active GL pipeline.
Returns $self for convenient chaining.
$self
For relevant implementations, this attaches the shaders and links the program. If it fails, this throws an exception. For OpenGL 4 implementation, this only happens once, and any changes to "shaders" afterward are ignored. Use "unprepare" to remove the compiled state and be able to rearrange the shaders.
Release resources allocated by "prepare".
Return the attribute ID of the given name, for the prepared program.
Return the uniform ID of the given name, for the prepared program.
$prog->set_uniform( $name, \@values ); $prog->set_uniform( $name, $opengl_array );
Set the value of a uniform. This attempts to guess at the size/geometry of the uniform based on the number or type of values given.
Alias for set_uniform.
set_uniform
Michael Conrad <mike@nrdvana.net>
This software is copyright (c) 2019 by Michael Conrad.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install OpenGL::Sandbox, copy and paste the appropriate command in to your terminal.
cpanm
cpanm OpenGL::Sandbox
CPAN shell
perl -MCPAN -e shell install OpenGL::Sandbox
For more information on module installation, please visit the detailed CPAN module installation guide.