FastUIDraw
|
Simple Shader utility class providing a simple interface to build GL shader objects using a glsl::ShaderSouce as its source code. More...
#include <gl_program.hpp>
Public Member Functions | |
Shader (const glsl::ShaderSource &src, GLenum pshader_type) | |
c_string | compile_log (void) |
bool | compile_success (void) |
GLuint | name (void) |
bool | shader_ready (void) |
GLenum | shader_type (void) |
c_string | source_code (void) |
Public Member Functions inherited from fastuidraw::reference_counted_base< T, Counter > | |
reference_counted_base (void) | |
Static Public Member Functions | |
static c_string | default_shader_version (void) |
static c_string | gl_shader_type_label (GLenum ptype) |
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) |
Simple Shader utility class providing a simple interface to build GL shader objects using a glsl::ShaderSouce as its source code.
The actual GL object creation is defferred to later, in doing so, one can create Shader objects from outside the main GL thread. Each of the following commands
triggers the GL commands to compile the shader if the shader has not been yet attempeted to be compiled. Hence one may only call these from outside the rendering thread if shader_ready() returns true. Moreover, a Shader may only be deleted from the GL rendering thread.
Definition at line 58 of file gl_program.hpp.
fastuidraw::gl::Shader::Shader | ( | const glsl::ShaderSource & | src, |
GLenum | pshader_type | ||
) |
Ctor. Construct a Shader.
src | GLSL source code of the shader |
pshader_type | type of shader, i.e. GL_VERTEX_SHADER for a vertex shader, etc. |
c_string fastuidraw::gl::Shader::compile_log | ( | void | ) |
Returns the GLSL compile log of the GLSL source code. If the shader source has not yet been sent to GL for compiling, will trigger those commands. Hence, should only be called from the GL rendering thread or if shader_ready() returns true.
bool fastuidraw::gl::Shader::compile_success | ( | void | ) |
Returns true if and only if GL successfully compiled the shader. If the shader source has not yet been sent to GL for compiling, will trigger those commands. Hence, should only be called from the GL rendering thread or if shader_ready() returns true.
|
static |
Returns the default shader version to feed to glsl::ShaderSource::specify_version() to match with the GL API. If GL backend, then gives "330". If GLES backend, then gives "300 es".
|
static |
Provided as a conveniance to return a string from a GL enumeration naming a shader type. For example GL_VERTEX_SHADER will return the string "GL_VERTEX_SHADER". Unreconized shader types will return the label "UNKNOWN_SHADER_STAGE".
GLuint fastuidraw::gl::Shader::name | ( | void | ) |
Returns the GL name (i.e. ID assigned by GL) of this Shader. If the shader source has not yet been sent to GL for compiling, will trigger those commands. Hence, should only be called from the GL rendering thread or if shader_ready() returns true.
bool fastuidraw::gl::Shader::shader_ready | ( | void | ) |
The actual GL shader is NOT built at constructor, rather it is built if any of
are called. This way, one can construct Shader objects from outside the GL thread. The functions return true if and only if the shader has been built.
GLenum fastuidraw::gl::Shader::shader_type | ( | void | ) |
Returns the shader type of this Shader as set by it's constructor.
c_string fastuidraw::gl::Shader::source_code | ( | void | ) |
Returns the GLSL source string fed to GL to create the GLSL shader.