FastUIDraw
|
Class for creating and using GLSL programs. More...
#include <gl_program.hpp>
Classes | |
class | atomic_buffer_info |
An atomic_buffer_info represents an object from which one can query the data of an atomic buffer. More... | |
class | block_info |
A block_info represents an object from which one can query the members of a uniform or shader storage block. More... | |
class | shader_variable_info |
A shader_variable_info holds the type, size and name of a uniform or an attribute of a GL program. More... | |
Public Types | |
enum | shader_variable_src_t { src_default_uniform_block, src_abo, src_uniform_block, src_shader_storage_block, src_shader_input, src_shader_output, src_shader_transform_feedback, src_null } |
Enumeration to describe the backing of a shader variable's value. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from fastuidraw::reference_counted_base< T, Counter > | |
static void | add_reference (const reference_counted_base< T, Counter > *p) |
static void | remove_reference (const reference_counted_base< T, Counter > *p) |
Class for creating and using GLSL programs.
A Program delays the GL commands to create the actual GL program until the first time it is bound with use_program(). In addition to proving the GL code to create the GLSL code, Program also provides queries GL for all active uniforms and attributes (see active_attributes(), active_uniforms(), find_uniform() and find_attribute()). Also, provides an interface so that a sequence of GL commands are executed the first time it is bound and also an interface so a sequence of actions is executed every time it is bound. Program's are considered a resource, as such have a resource manager.
Definition at line 559 of file gl_program.hpp.
Enumeration to describe the backing of a shader variable's value.
Definition at line 568 of file gl_program.hpp.
fastuidraw::gl::Program::Program | ( | c_array< const reference_counted_ptr< Shader > > | pshaders, |
const PreLinkActionArray & | action = PreLinkActionArray() , |
||
const ProgramInitializerArray & | initers = ProgramInitializerArray() |
||
) |
fastuidraw::gl::Program::Program | ( | reference_counted_ptr< Shader > | vert_shader, |
reference_counted_ptr< Shader > | frag_shader, | ||
const PreLinkActionArray & | action = PreLinkActionArray() , |
||
const ProgramInitializerArray & | initers = ProgramInitializerArray() |
||
) |
fastuidraw::gl::Program::Program | ( | const glsl::ShaderSource & | vert_shader, |
const glsl::ShaderSource & | frag_shader, | ||
const PreLinkActionArray & | action = PreLinkActionArray() , |
||
const ProgramInitializerArray & | initers = ProgramInitializerArray() |
||
) |
fastuidraw::gl::Program::Program | ( | GLuint | pname, |
bool | take_ownership | ||
) |
Ctor. Create a Program from a previously linked GL shader.
pname | GL ID of previously linked shader |
take_ownership | if true when dtor is called glDeleteProgram is called as well |
shader_variable_info fastuidraw::gl::Program::active_attribute | ( | unsigned int | I | ) |
Returns the indexed attribute. This function should only be called either after use_program() has been called or only when the GL context is current. The values are sorted in alphabetical order of shader_variable_info::name().
I | -ID- (not location) of attribute, if I is not less than number_active_attributes(), returns a shader_variable_info indicating no attribute (i.e. shader_variable_info::name() is an empty string and shader_variable_info::index() is -1). |
atomic_buffer_info fastuidraw::gl::Program::atomic_buffer | ( | unsigned int | I | ) |
Returns the indexed atomic buffer. the index passed is the index as used by the GL API to query the uniform block (and thus the same as shader_variable_info::abo_index()). This function should only be called either after use_program() has been called or only when the GL context is current.
I | which one to fetch, if I is not less than number_active_atomic_buffers(), then returns a null atomic_buffer_info |
unsigned int fastuidraw::gl::Program::atomic_buffer_id | ( | unsigned int | binding_point | ) |
Returns the index to feed to atomic_buffer(unsigned int) to fetch the atomic buffer with the value of atomic_buffer_info::buffer_binding().
binding_point | value for atomic_buffer_info::buffer_binding() to search for. |
GLint fastuidraw::gl::Program::attribute_location | ( | c_string | attribute_name | ) |
Searches active_attribute() to find the named attribute, including named elements of an array. This function should only be called either after use_program() has been called or only when the GL context is current. Returns value -1 indicated that the attribute could not be found.
attribute_name | name of attribute to find |
block_info fastuidraw::gl::Program::default_uniform_block | ( | void | ) |
Returns a block_info of the default uniform block, the default uniform block does NOT include shader variables coming from atomic buffer counters.
shader_variable_info fastuidraw::gl::Program::find_shader_variable | ( | c_string | name, |
unsigned int * | out_array_index = nullptr , |
||
unsigned int * | out_leading_array_index = nullptr |
||
) |
Searches the default uniform block, all uniform blocks and all shader storage blocks for a shader variable.
c_string fastuidraw::gl::Program::link_log | ( | void | ) |
Returns the link log of this Program, essentially the value returned by glGetProgramInfoLog. This function should only be called either after use_program() has been called or only when the GL context is current.
bool fastuidraw::gl::Program::link_success | ( | void | ) |
Returns true if and only if this Program successfully linked. This function should only be called either after use_program() has been called or only when the GL context is current.
c_string fastuidraw::gl::Program::log | ( | void | ) |
Returns the full log (including shader source code and link_log()) of this Program. This function should only be called either after use_program() has been called or only when the GL context is current.
GLuint fastuidraw::gl::Program::name | ( | void | ) |
Returns the GL name (i.e. ID assigned by GL, for use in glUseProgram) of this Program. This function should only be called either after use_program() has been called or only when the GL context is current.
unsigned int fastuidraw::gl::Program::num_shaders | ( | GLenum | tp | ) | const |
Returns the number of shaders of a given type attached to the Program.
tp | GL enumeration of the shader type, see Shader::shader_type() |
unsigned int fastuidraw::gl::Program::number_active_atomic_buffers | ( | void | ) |
Returns the number of active atomic buffers. This function should only be called either after use_program() has been called or only when the GL context is current.
unsigned int fastuidraw::gl::Program::number_active_attributes | ( | void | ) |
Returns the number of active attributes. Note that an array of uniforms is classified as a single uniform. This function should only be called either after use_program() has been called or only when the GL context is current.
unsigned int fastuidraw::gl::Program::number_active_shader_storage_blocks | ( | void | ) |
Returns the number of active shader storage blocks. This function should only be called either after use_program() has been called or only when the GL context is current.
unsigned int fastuidraw::gl::Program::number_active_uniform_blocks | ( | void | ) |
Returns the number of active uniform blocks (not including the default uniform block). This function should only be called either after use_program() has been called or only when the GL context is current.
unsigned int fastuidraw::gl::Program::number_transform_feedback_buffers | ( | void | ) |
Returns the number of transform feedback buffers.
unsigned int fastuidraw::gl::Program::number_transform_feedbacks | ( | void | ) |
Returns the number of active transform feedbacks. Note that an array of transform feedback is classified as a single element. This will also include padding in the form of gl_SkipComponents1, gl_SkipComponents2, gl_SkipComponents3 and gl_SkipComponents4. In addition it will also include gl_NextBuffer to indicated advancing to the next buffer. This function should only be called either after use_program() has been called or only when the GL context is current.
float fastuidraw::gl::Program::program_build_time | ( | void | ) |
Returns how many seconds it took for the program to be assembled and linked.
c_string fastuidraw::gl::Program::shader_compile_log | ( | GLenum | tp, |
unsigned int | i | ||
) | const |
Returns the compile log for a shader attached to the Program.
tp | GL enumeration of the shader type, see Shader::shader_type() |
i | which shader with 0 <= i < num_shaders(tp) |
bool fastuidraw::gl::Program::shader_compile_success | ( | GLenum | tp, |
unsigned int | i | ||
) | const |
Returns true if the source code string for a shader attached to the Program compiled successfully.
tp | GL enumeration of the shader type, see Shader::shader_type() |
i | which shader with 0 <= i < num_shaders(tp) |
c_string fastuidraw::gl::Program::shader_src_code | ( | GLenum | tp, |
unsigned int | i | ||
) | const |
Returns the source code string for a shader attached to the Program.
tp | GL enumeration of the shader type, see Shader::shader_type() |
i | which shader with 0 <= i < num_shaders(tp) |
block_info fastuidraw::gl::Program::shader_storage_block | ( | unsigned int | I | ) |
Returns the indexed shader_storage block; the index passed is the index as used by the GL API to query the uniform block (and thus the same as shader_variable_info::shader_storage_buffer_index()). This function should only be called either after use_program()
I | which one to fetch, if I is not less than number_active_shader_storage_blocks(), then returns a nullptr block_info |
|
inline |
Seaches shader_storage_block(unsigned int) to find the named uniform block. If no such uniform block has that name returns a null block_info object. Provided as a conveniance, equivalent to
This function should only be called either after use_program() has been called or only when the GL context is current.
shader_storage_block_name | name of shader storage to find |
Definition at line 1299 of file gl_program.hpp.
unsigned int fastuidraw::gl::Program::shader_storage_block_id | ( | c_string | shader_storage_block_name | ) |
Searches shader_storage_block(unsigned int) to find the named shader_storage block. Return value ~0u indicates that the shader_storage block could not be found. This function should only be called either after use_program() has been called or only when the GL context is current.
shader_storage_block_name | name of shader storage to find |
shader_variable_info fastuidraw::gl::Program::transform_feedback | ( | unsigned int | I | ) |
Returns the indexed transform-feedback. This function should only be called either after use_program() has been called or only when the GL context is current. The values are sorted in alphabetical order of shader_variable_info::name().
I | -ID- (not location or index) of transform feedbach, if I is not less than number_transform_feedbacks(), returns a shader_variable_info indicating null (i.e. shader_variable_info::name() is an empty string and shader_variable_info::index() is -1). |
unsigned int fastuidraw::gl::Program::transform_feedback_buffer_stride | ( | unsigned int | B | ) |
Returns the stride in bytes between each element in the named transform feedback buffer.
B | which transform feedback buffer |
block_info fastuidraw::gl::Program::uniform_block | ( | unsigned int | I | ) |
Returns the indexed uniform block; the index passed is the index as used by the GL API to query the uniform block (and thus the same as shader_variable_info::ubo_index()). This function should only be called either after use_program() has been called or only when the GL context is current.
I | which one to fetch, if I is not less than number_active_uniform_blocks(), then returns a null block_info object. |
|
inline |
Seaches uniform_block(unsigned int) to find the named uniform block. If no such uniform block has that name returns a null block_info object. Provided as a conveniance, equivalent to
This function should only be called either after use_program() has been called or only when the GL context is current.
uniform_block_name | name of uniform block to find |
Definition at line 1238 of file gl_program.hpp.
unsigned int fastuidraw::gl::Program::uniform_block_id | ( | c_string | uniform_block_name | ) |
Searches uniform_block(unsigned int) to find the named uniform block. Return value ~0u indicates that the uniform block could not be found, otherwise returns the value to feed to uniform_block(unsigned int). This function should only be called either after use_program() has been called or only when the GL context is current.
uniform_block_name | name of uniform block to find |
GLint fastuidraw::gl::Program::uniform_location | ( | c_string | name | ) |
Returns the location of a uniform and also correctly handles fetching the uniform of an element of a uniform array. Returns -1 if there is no uniform on the default block with that name.
void fastuidraw::gl::Program::use_program | ( | void | ) |
Call to set GL to use the GLSLProgram of this Program. The GL context must be current.