Program Object. More...
#include <program_object.h>
Public Member Functions | |
ProgramObject () | |
Construct a null instance. More... | |
ProgramObject (GraphicContext &gc) | |
Constructs a ProgramObject. More... | |
ProgramObject (GraphicContextProvider *gc_provider) | |
Constructs a ProgramObject. More... | |
ProgramObject (ProgramObjectProvider *provider) | |
Constructs a ProgramObject. More... | |
virtual | ~ProgramObject () |
void | attach (const ShaderObject &obj) |
Add shader to program object. More... | |
void | bind_attribute_location (int index, const std::string &name) |
Bind attribute to specific location. More... | |
void | bind_frag_data_location (int color_number, const std::string &name) |
Bind shader out variable a specific color buffer location. More... | |
void | detach (const ShaderObject &obj) |
Remove shader from program object. More... | |
int | get_attribute_location (const std::string &name) const |
Returns the location of a named active attribute. More... | |
unsigned int | get_handle () const |
Returns the OpenGL program object handle. More... | |
std::string | get_info_log () const |
Returns the current info log for the program object. More... | |
ProgramObjectProvider * | get_provider () const |
Retrieves the provider. More... | |
std::vector< ShaderObject > | get_shaders () const |
Returns the shaders attached to the program object. More... | |
int | get_storage_buffer_index (const std::string &name) const |
Get the storage buffer index. More... | |
int | get_uniform_buffer_index (const std::string &block_name) const |
Get the uniform block index. More... | |
int | get_uniform_buffer_size (const std::string &block_name) const |
Get the uniform block size. More... | |
int | get_uniform_buffer_size (int block_index) const |
Get the uniform block size. More... | |
int | get_uniform_location (const std::string &name) const |
Returns the location of a named uniform variable. More... | |
bool | is_null () const |
Returns true if this object is invalid. More... | |
bool | link () |
Link program. More... | |
operator bool () const | |
bool | operator== (const ProgramObject &other) const |
Equality operator. More... | |
void | set_storage_buffer_index (const std::string &block_name, int bind_index) |
Sets the UniformBuffer. More... | |
void | set_storage_buffer_index (int block_index, int bind_index) |
Sets the UniformBuffer. More... | |
void | set_uniform1f (int location, float value_a) |
void | set_uniform1f (const std::string &name, float value_a) |
void | set_uniform1i (int location, int value_a) |
void | set_uniform1i (const std::string &name, int value_a) |
void | set_uniform2b (int location, const Vec2b &vec) |
void | set_uniform2b (const std::string &name, const Vec2b &vec) |
void | set_uniform2f (int location, float value_a, float value_b) |
void | set_uniform2f (int location, const Vec2f &vec) |
void | set_uniform2f (const std::string &name, float value_a, float value_b) |
void | set_uniform2f (const std::string &name, const Vec2f &vec) |
void | set_uniform2i (int location, int value_a, int value_b) |
void | set_uniform2i (int location, const Vec2i &vec) |
void | set_uniform2i (const std::string &name, int value_a, int value_b) |
void | set_uniform2i (const std::string &name, const Vec2i &vec) |
void | set_uniform2s (int location, const Vec2s &vec) |
void | set_uniform2s (const std::string &name, const Vec2s &vec) |
void | set_uniform3b (int location, const Vec3b &vec) |
void | set_uniform3b (const std::string &name, const Vec3b &vec) |
void | set_uniform3f (int location, float value_a, float value_b, float value_c) |
void | set_uniform3f (int location, const Vec3f &vec) |
void | set_uniform3f (const std::string &name, float value_a, float value_b, float value_c) |
void | set_uniform3f (const std::string &name, const Vec3f &vec) |
void | set_uniform3i (int location, int value_a, int value_b, int value_c) |
void | set_uniform3i (int location, const Vec3i &vec) |
void | set_uniform3i (const std::string &name, int value_a, int value_b, int value_c) |
void | set_uniform3i (const std::string &name, const Vec3i &vec) |
void | set_uniform3s (int location, const Vec3s &vec) |
void | set_uniform3s (const std::string &name, const Vec3s &vec) |
void | set_uniform4b (int location, const Vec4b &vec) |
void | set_uniform4b (const std::string &name, const Vec4b &vec) |
void | set_uniform4f (int location, float value_a, float value_b, float value_c, float value_d) |
void | set_uniform4f (int location, const Vec4f &vec) |
void | set_uniform4f (const std::string &name, float value_a, float value_b, float value_c, float value_d) |
void | set_uniform4f (const std::string &name, const Vec4f &vec) |
void | set_uniform4i (int location, int value_a, int value_b, int value_c, int value_d) |
void | set_uniform4i (int location, const Vec4i &vec) |
void | set_uniform4i (const std::string &name, int value_a, int value_b, int value_c, int value_d) |
void | set_uniform4i (const std::string &name, const Vec4i &vec) |
void | set_uniform4s (int location, const Vec4s &vec) |
void | set_uniform4s (const std::string &name, const Vec4s &vec) |
void | set_uniform_buffer_index (const std::string &block_name, int bind_index) |
Sets the UniformBuffer. More... | |
void | set_uniform_buffer_index (int block_index, int bind_index) |
Sets the UniformBuffer. More... | |
void | set_uniform_matrix (int location, int size, int count, bool transpose, const float *data) |
void | set_uniform_matrix (int location, const Mat2f &matrix) |
void | set_uniform_matrix (int location, const Mat3f &matrix) |
void | set_uniform_matrix (int location, const Mat4f &matrix) |
void | set_uniform_matrix (int location, int count, const Mat2f *matrix) |
void | set_uniform_matrix (int location, int count, const Mat3f *matrix) |
void | set_uniform_matrix (int location, int count, const Mat4f *matrix) |
void | set_uniform_matrix (const std::string &name, int size, int count, bool transpose, const float *data) |
void | set_uniform_matrix (const std::string &name, const Mat2f &matrix) |
void | set_uniform_matrix (const std::string &name, const Mat3f &matrix) |
void | set_uniform_matrix (const std::string &name, const Mat4f &matrix) |
void | set_uniform_matrix (const std::string &name, int count, const Mat2f *matrix) |
void | set_uniform_matrix (const std::string &name, int count, const Mat3f *matrix) |
void | set_uniform_matrix (const std::string &name, int count, const Mat4f *matrix) |
void | set_uniformfv (int location, int size, int count, const float *data) |
void | set_uniformfv (int location, int count, const Vec2f *data) |
void | set_uniformfv (int location, int count, const Vec3f *data) |
void | set_uniformfv (int location, int count, const Vec4f *data) |
void | set_uniformfv (const std::string &name, int size, int count, const float *data) |
void | set_uniformfv (const std::string &name, int count, const Vec2f *data) |
void | set_uniformfv (const std::string &name, int count, const Vec3f *data) |
void | set_uniformfv (const std::string &name, int count, const Vec4f *data) |
void | set_uniformiv (int location, int size, int count, const int *data) |
void | set_uniformiv (int location, int count, const Vec2i *data) |
void | set_uniformiv (int location, int count, const Vec3i *data) |
void | set_uniformiv (int location, int count, const Vec4i *data) |
void | set_uniformiv (const std::string &name, int size, int count, const int *data) |
void | set_uniformiv (const std::string &name, int count, const Vec2i *data) |
void | set_uniformiv (const std::string &name, int count, const Vec3i *data) |
void | set_uniformiv (const std::string &name, int count, const Vec4i *data) |
void | throw_if_null () const |
Throw an exception if this object is invalid. More... | |
bool | validate () |
Validate program. More... | |
Static Public Member Functions | |
static ProgramObject | load (GraphicContext &gc, const std::string &resource_id, const XMLResourceDocument &resman) |
Load. More... | |
static ProgramObject | load (GraphicContext &gc, const std::string &vertex_fullname, const std::string &fragment_fullname) |
Load. More... | |
static ProgramObject | load (GraphicContext &gc, const std::string &vertex_fullname, const std::string &geometry_fullname, const std::string &fragment_fullname) |
Load. More... | |
static ProgramObject | load (GraphicContext &gc, const std::string &vertex_filename, const std::string &fragment_filename, const FileSystem &fs) |
Load. More... | |
static ProgramObject | load (GraphicContext &gc, const std::string &vertex_filename, const std::string &geometry_filename, const std::string &fragment_filename, const FileSystem &fs) |
Load. More... | |
static ProgramObject | load (GraphicContext &gc, IODevice &vertex_file, IODevice &fragment_file) |
Load. More... | |
static ProgramObject | load (GraphicContext &gc, IODevice &vertex_file, IODevice &geometry_file, IODevice &fragment_file) |
Load. More... | |
static ProgramObject | load_and_link (GraphicContext &gc, const std::string &vertex_fullname, const std::string &fragment_fullname) |
Load and link. More... | |
static ProgramObject | load_and_link (GraphicContext &gc, const std::string &vertex_fullname, const std::string &geometry_fullname, const std::string &fragment_fullname) |
Load and link. More... | |
static ProgramObject | load_and_link (GraphicContext &gc, const std::string &vertex_filename, const std::string &fragment_filename, const FileSystem &fs) |
Load and link. More... | |
static ProgramObject | load_and_link (GraphicContext &gc, const std::string &vertex_filename, const std::string &geometry_filename, const std::string &fragment_filename, const FileSystem &fs) |
Load and link. More... | |
static ProgramObject | load_and_link (GraphicContext &gc, IODevice &vertex_file, IODevice &fragment_file) |
Load and link. More... | |
static ProgramObject | load_and_link (GraphicContext &gc, IODevice &vertex_file, IODevice &geometry_file, IODevice &fragment_file) |
Load and link. More... | |
Program Object.
The shader objects that are to be used by programmable stages of OpenGL are collected together to form a program object. ProgramObject is ClanLib's C++ interface to OpenGL program objects.
To construct a program object programatically, the procedure is as follows:
ShaderObject vertex_shader(shadertype_vertex, vertex_glsl_sourcecode); ShaderObject fragment_shader(shadertype_fragment, fragment_glsl_sourcecode); ProgramObject program; program.attach(vertex_shader); program.attach(fragment_shader); program.link();
For more information about program objects, see the OpenGL 2.0 specification at www.opengl.org. Documentation about the OpenGL Shader Language (GLSL) is also available from www.opengl.org.
clan::ProgramObject::ProgramObject | ( | ) |
Construct a null instance.
clan::ProgramObject::ProgramObject | ( | GraphicContext & | gc | ) |
Constructs a ProgramObject.
gc | = Graphic Context |
clan::ProgramObject::ProgramObject | ( | GraphicContextProvider * | gc_provider | ) |
Constructs a ProgramObject.
gc_provider | = Graphic Context Provider |
clan::ProgramObject::ProgramObject | ( | ProgramObjectProvider * | provider | ) |
Constructs a ProgramObject.
provider | = Font Provider |
|
virtual |
void clan::ProgramObject::attach | ( | const ShaderObject & | obj | ) |
Add shader to program object.
void clan::ProgramObject::bind_attribute_location | ( | int | index, |
const std::string & | name | ||
) |
Bind attribute to specific location.
This function must be called before linking.
void clan::ProgramObject::bind_frag_data_location | ( | int | color_number, |
const std::string & | name | ||
) |
Bind shader out variable a specific color buffer location.
This function must be called before linking.
void clan::ProgramObject::detach | ( | const ShaderObject & | obj | ) |
Remove shader from program object.
int clan::ProgramObject::get_attribute_location | ( | const std::string & | name | ) | const |
Returns the location of a named active attribute.
Returns -1 when unknown
unsigned int clan::ProgramObject::get_handle | ( | ) | const |
Returns the OpenGL program object handle.
std::string clan::ProgramObject::get_info_log | ( | ) | const |
Returns the current info log for the program object.
ProgramObjectProvider* clan::ProgramObject::get_provider | ( | ) | const |
Retrieves the provider.
std::vector<ShaderObject> clan::ProgramObject::get_shaders | ( | ) | const |
Returns the shaders attached to the program object.
int clan::ProgramObject::get_storage_buffer_index | ( | const std::string & | name | ) | const |
Get the storage buffer index.
Returns -1 when the block index was not found
int clan::ProgramObject::get_uniform_buffer_index | ( | const std::string & | block_name | ) | const |
Get the uniform block index.
Returns -1 when the block index was not found
int clan::ProgramObject::get_uniform_buffer_size | ( | const std::string & | block_name | ) | const |
Get the uniform block size.
An exception is thrown of block_name was not found
Returns -1 when unknown
int clan::ProgramObject::get_uniform_buffer_size | ( | int | block_index | ) | const |
Get the uniform block size.
int clan::ProgramObject::get_uniform_location | ( | const std::string & | name | ) | const |
Returns the location of a named uniform variable.
Returns -1 when unknown
Referenced by set_uniform1f(), set_uniform1i(), set_uniform2b(), set_uniform2f(), set_uniform2i(), set_uniform2s(), set_uniform3b(), set_uniform3f(), set_uniform3i(), set_uniform3s(), set_uniform4b(), set_uniform4f(), set_uniform4i(), set_uniform4s(), set_uniform_matrix(), set_uniformfv(), and set_uniformiv().
|
inline |
Returns true if this object is invalid.
bool clan::ProgramObject::link | ( | ) |
Link program.
If the linking fails, get_info_log() will return the link log.
|
static |
Load.
gc | = Graphic Context |
resource_id | = String Ref |
resman | = Resource Manager |
|
static |
Load.
gc | = Graphic Context |
vertex_fullname | = String Ref |
fragment_fullname | = String Ref |
|
static |
Load.
gc | = Graphic Context |
vertex_fullname | = String Ref |
geometry_fullname | = String Ref |
fragment_fullname | = String Ref |
|
static |
Load.
gc | = Graphic Context |
vertex_filename | = String Ref |
fragment_filename | = String Ref |
directory | = Virtual Directory |
|
static |
Load.
gc | = Graphic Context |
vertex_filename | = String Ref |
geometry_filename | = String Ref |
fragment_filename | = String Ref |
directory | = Virtual Directory |
|
static |
|
static |
|
static |
Load and link.
gc | = Graphic Context |
vertex_fullname | = String Ref |
fragment_fullname | = String Ref |
|
static |
Load and link.
gc | = Graphic Context |
vertex_fullname | = String Ref |
geometry_fullname | = String Ref |
fragment_fullname | = String Ref |
|
static |
Load and link.
gc | = Graphic Context |
vertex_filename | = String Ref |
fragment_filename | = String Ref |
directory | = Virtual Directory |
|
static |
Load and link.
gc | = Graphic Context |
vertex_filename | = String Ref |
geometry_filename | = String Ref |
fragment_filename | = String Ref |
directory | = Virtual Directory |
|
static |
|
static |
|
inlineexplicit |
bool clan::ProgramObject::operator== | ( | const ProgramObject & | other | ) | const |
Equality operator.
void clan::ProgramObject::set_storage_buffer_index | ( | const std::string & | block_name, |
int | bind_index | ||
) |
Sets the UniformBuffer.
void clan::ProgramObject::set_storage_buffer_index | ( | int | block_index, |
int | bind_index | ||
) |
Sets the UniformBuffer.
void clan::ProgramObject::set_uniform1f | ( | int | location, |
float | value_a | ||
) |
|
inline |
References get_uniform_location(), and set_uniform1f().
Referenced by set_uniform1f().
void clan::ProgramObject::set_uniform1i | ( | int | location, |
int | value_a | ||
) |
|
inline |
References get_uniform_location(), and set_uniform1i().
Referenced by set_uniform1i().
|
inline |
References set_uniform2i(), clan::Vec2< Type >::x, and clan::Vec2< Type >::y.
|
inline |
References get_uniform_location(), and set_uniform2b().
Referenced by set_uniform2b().
void clan::ProgramObject::set_uniform2f | ( | int | location, |
float | value_a, | ||
float | value_b | ||
) |
|
inline |
References set_uniform2f(), clan::Vec2< Type >::x, and clan::Vec2< Type >::y.
Referenced by set_uniform2f().
|
inline |
References get_uniform_location(), and set_uniform2f().
Referenced by set_uniform2f().
|
inline |
References get_uniform_location(), and set_uniform2f().
Referenced by set_uniform2f().
void clan::ProgramObject::set_uniform2i | ( | int | location, |
int | value_a, | ||
int | value_b | ||
) |
Referenced by set_uniform2b(), and set_uniform2s().
|
inline |
References set_uniform2i(), clan::Vec2< Type >::x, and clan::Vec2< Type >::y.
Referenced by set_uniform2i().
|
inline |
References get_uniform_location(), and set_uniform2i().
Referenced by set_uniform2i().
|
inline |
References get_uniform_location(), and set_uniform2i().
Referenced by set_uniform2i().
|
inline |
References set_uniform2i(), clan::Vec2< Type >::x, and clan::Vec2< Type >::y.
|
inline |
References get_uniform_location(), and set_uniform2s().
Referenced by set_uniform2s().
|
inline |
References set_uniform3i(), clan::Vec3< Type >::x, clan::Vec3< Type >::y, and clan::Vec3< Type >::z.
|
inline |
References get_uniform_location(), and set_uniform3b().
Referenced by set_uniform3b().
void clan::ProgramObject::set_uniform3f | ( | int | location, |
float | value_a, | ||
float | value_b, | ||
float | value_c | ||
) |
|
inline |
References set_uniform3f(), clan::Vec3< Type >::x, clan::Vec3< Type >::y, and clan::Vec3< Type >::z.
Referenced by set_uniform3f().
|
inline |
References get_uniform_location(), and set_uniform3f().
Referenced by set_uniform3f().
|
inline |
References get_uniform_location(), and set_uniform3f().
Referenced by set_uniform3f().
void clan::ProgramObject::set_uniform3i | ( | int | location, |
int | value_a, | ||
int | value_b, | ||
int | value_c | ||
) |
Referenced by set_uniform3b(), and set_uniform3s().
|
inline |
References set_uniform3i(), clan::Vec3< Type >::x, clan::Vec3< Type >::y, and clan::Vec3< Type >::z.
Referenced by set_uniform3i().
|
inline |
References get_uniform_location(), and set_uniform3i().
Referenced by set_uniform3i().
|
inline |
References get_uniform_location(), and set_uniform3i().
Referenced by set_uniform3i().
|
inline |
References set_uniform3i(), clan::Vec3< Type >::x, clan::Vec3< Type >::y, and clan::Vec3< Type >::z.
|
inline |
References get_uniform_location(), and set_uniform3s().
Referenced by set_uniform3s().
|
inline |
|
inline |
References get_uniform_location(), and set_uniform4b().
Referenced by set_uniform4b().
void clan::ProgramObject::set_uniform4f | ( | int | location, |
float | value_a, | ||
float | value_b, | ||
float | value_c, | ||
float | value_d | ||
) |
|
inline |
References set_uniform4f(), clan::Vec4< Type >::w, clan::Vec4< Type >::x, clan::Vec4< Type >::y, and clan::Vec4< Type >::z.
Referenced by set_uniform4f().
|
inline |
References get_uniform_location(), and set_uniform4f().
Referenced by set_uniform4f().
|
inline |
References get_uniform_location(), and set_uniform4f().
Referenced by set_uniform4f().
void clan::ProgramObject::set_uniform4i | ( | int | location, |
int | value_a, | ||
int | value_b, | ||
int | value_c, | ||
int | value_d | ||
) |
Referenced by set_uniform4b(), and set_uniform4s().
|
inline |
References set_uniform4i(), clan::Vec4< Type >::w, clan::Vec4< Type >::x, clan::Vec4< Type >::y, and clan::Vec4< Type >::z.
Referenced by set_uniform4i().
|
inline |
References get_uniform_location(), and set_uniform4i().
Referenced by set_uniform4i().
|
inline |
References get_uniform_location(), and set_uniform4i().
Referenced by set_uniform4i().
|
inline |
|
inline |
References get_uniform_location(), and set_uniform4s().
Referenced by set_uniform4s().
void clan::ProgramObject::set_uniform_buffer_index | ( | const std::string & | block_name, |
int | bind_index | ||
) |
Sets the UniformBuffer.
void clan::ProgramObject::set_uniform_buffer_index | ( | int | block_index, |
int | bind_index | ||
) |
Sets the UniformBuffer.
void clan::ProgramObject::set_uniform_matrix | ( | int | location, |
int | size, | ||
int | count, | ||
bool | transpose, | ||
const float * | data | ||
) |
|
inline |
References clan::Mat2< Type >::matrix, and set_uniform_matrix().
Referenced by set_uniform_matrix().
|
inline |
References clan::Mat3< Type >::matrix, and set_uniform_matrix().
Referenced by set_uniform_matrix().
|
inline |
References clan::Mat4< Type >::matrix, and set_uniform_matrix().
Referenced by set_uniform_matrix().
|
inline |
References clan::Mat2< Type >::matrix, and set_uniform_matrix().
Referenced by set_uniform_matrix().
|
inline |
References clan::Mat3< Type >::matrix, and set_uniform_matrix().
Referenced by set_uniform_matrix().
|
inline |
References clan::Mat4< Type >::matrix, and set_uniform_matrix().
Referenced by set_uniform_matrix().
|
inline |
References get_uniform_location(), and set_uniform_matrix().
Referenced by set_uniform_matrix().
|
inline |
References get_uniform_location(), and set_uniform_matrix().
Referenced by set_uniform_matrix().
|
inline |
References get_uniform_location(), and set_uniform_matrix().
Referenced by set_uniform_matrix().
|
inline |
References get_uniform_location(), and set_uniform_matrix().
Referenced by set_uniform_matrix().
|
inline |
References get_uniform_location(), and set_uniform_matrix().
Referenced by set_uniform_matrix().
|
inline |
References get_uniform_location(), and set_uniform_matrix().
Referenced by set_uniform_matrix().
|
inline |
References get_uniform_location(), and set_uniform_matrix().
Referenced by set_uniform_matrix().
void clan::ProgramObject::set_uniformfv | ( | int | location, |
int | size, | ||
int | count, | ||
const float * | data | ||
) |
|
inline |
References set_uniformfv(), and clan::Vec2< Type >::x.
Referenced by set_uniformfv().
|
inline |
References set_uniformfv(), and clan::Vec3< Type >::x.
Referenced by set_uniformfv().
|
inline |
References set_uniformfv(), and clan::Vec4< Type >::x.
Referenced by set_uniformfv().
|
inline |
References get_uniform_location(), and set_uniformfv().
Referenced by set_uniformfv().
|
inline |
References get_uniform_location(), and set_uniformfv().
Referenced by set_uniformfv().
|
inline |
References get_uniform_location(), and set_uniformfv().
Referenced by set_uniformfv().
|
inline |
References get_uniform_location(), and set_uniformfv().
Referenced by set_uniformfv().
void clan::ProgramObject::set_uniformiv | ( | int | location, |
int | size, | ||
int | count, | ||
const int * | data | ||
) |
|
inline |
References set_uniformiv(), and clan::Vec2< Type >::x.
Referenced by set_uniformiv().
|
inline |
References set_uniformiv(), and clan::Vec3< Type >::x.
Referenced by set_uniformiv().
|
inline |
References set_uniformiv(), and clan::Vec4< Type >::x.
Referenced by set_uniformiv().
|
inline |
References get_uniform_location(), and set_uniformiv().
Referenced by set_uniformiv().
|
inline |
References get_uniform_location(), and set_uniformiv().
Referenced by set_uniformiv().
|
inline |
References get_uniform_location(), and set_uniformiv().
Referenced by set_uniformiv().
|
inline |
References get_uniform_location(), and set_uniformiv().
Referenced by set_uniformiv().
void clan::ProgramObject::throw_if_null | ( | ) | const |
Throw an exception if this object is invalid.
bool clan::ProgramObject::validate | ( | ) |
Validate program.
If the validation fails, get_info_log() will return the validation log.