79 std::cerr<<
"Warning binding attribute after link\n";
91 std::cerr<<
"Warning binding attribute after link\n";
109 GLint infologLength = 0;
113 if(infologLength > 0)
115 char *
infoLog =
new char[infologLength];
116 GLint charsWritten = 0;
120 std::cerr<<infoLog<<std::endl;
125 std::cerr<<
"Program link failed exiting \n";
144 std::cerr<<
"Uniform \""<<_name<<
"\" not found in Program \""<<
m_programName<<
"\"\n";
153 std::cerr<<
"_______________________________________________________________________________________________________________________\n";
163 std::cerr<<
"calling printActiveUniforms on unbound shader program\n";
169 for (
GLint i=0; i<nUniforms; ++i)
172 std::cerr <<
"Uniform: "<<name<<
"\n";
186 for (
GLint i=0; i < nAttribs; ++i)
189 std::cerr <<
"Attribute"<<i<<
":\""<<name<<
"\" Size:"<<size<<
" Type:";
192 case GL_FLOAT: std::cerr <<
"GL_FLOAT\n";
break;
205 default: std::cerr <<
"UNKNOWN\n";
511 std::cerr<<
"Enable attrib "<<
index->second<<
"\n";
549 for (
GLint i=0; i<nUniforms; ++i)
567 std::string baseName=uniform.substr(0, uniform.find(
"["));
569 for(
int i=0; i<
num; ++i)
584 const static std::unordered_map<GLenum,const char *>
types=
697 std::cout<<
"Registered Uniforms for shader "<<
m_programName<<
"\n";
701 auto value=types.find(d.second.type);
702 if(
value !=types.end())
710 std::cout<<
"Uniform "<<d.first<<
"-> "<<
" location "<<d.second.loc<<
" glsl type "<<type<<
"\n";
#define GL_IMAGE_2D_MULTISAMPLE_ARRAY
#define glGetActiveUniformName
void setRegisteredUniform1f(const std::string &_varname, float _v0) const noexcept
sets the registered uniform to a single float
void setUniform2i(const char *_varname, GLint _v0, GLint _v1) const noexcept
sets '_varname' as a int2
#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY
void setUniform2f(const char *_varname, float _v0, float _v1) const noexcept
sets '_varname' as a float2
void setUniformMatrix3x4fv(const char *_varname, size_t _count, bool _transpose, const float *_value) const noexcept
sets '_varname' as a 3x4 matrix array
void setUniformMatrix3fv(const char *_varname, size_t _count, bool _transpose, const float *_value) const noexcept
sets '_varname' as a 3D matrix array
void setUniform3f(const char *_varname, float _v0, float _v1, float _v2) const noexcept
sets '_varname' as a float3
std::vector< Shader * > m_shaders
a list of the shader objects attached to the program
#define GL_UNSIGNED_INT_SAMPLER_BUFFER
GLuint m_programID
the program id for this program object
#define glEnableVertexAttribArray
#define glUniformMatrix2x4fv
bool m_active
indicate if this program is the current active program
GLuint GLuint GLsizei GLenum type
#define GL_SAMPLER_1D_ARRAY_SHADOW
#define GL_SAMPLER_1D_SHADOW
#define GL_UNSIGNED_INT_IMAGE_3D
#define glUniformMatrix4x2fv
#define glUniformMatrix3x4fv
#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY
void setRegisteredUniform3i(const std::string &_varname, int _v0, int _v1, int _v2) const noexcept
sets the registered uniform to a single int
void setRegisteredUniform4f(const std::string &_varname, float _v0, float _v1, float _v2, float _v3) const noexcept
sets the registered uniform to a single float
#define GL_UNSIGNED_INT_IMAGE_2D_RECT
#define glUniformMatrix2x3fv
std::string format(CStringRef format_str, ArgList args)
#define GL_INT_IMAGE_1D_ARRAY
#define glUniformMatrix2fv
#define GL_INT_IMAGE_2D_MULTISAMPLE
#define glUniformMatrix4x3fv
void attachShader(Shader *_shader) noexcept
attach a shader to the ProgramObject
#define GL_ACTIVE_UNIFORMS
#define GL_INT_IMAGE_BUFFER
GLsizei const GLfloat * value
void setUniform3i(const char *_varname, GLint _v0, GLint _v1, GLint _v2) const noexcept
sets '_varname' as a int3
#define glGetActiveAttrib
#define GL_SAMPLER_2D_RECT
#define GL_UNSIGNED_INT_IMAGE_BUFFER
void printActiveAttributes() const noexcept
lists the available Attributes for the shader (this was a pain because the compiler quietly gets rid ...
GLint GLenum GLsizei GLint GLsizei const void * data
GLsizei GLsizei GLchar * infoLog
#define GL_INT_IMAGE_2D_ARRAY
#define GL_UNSIGNED_INT_SAMPLER_CUBE
implementation files for RibExport class
std::string m_programName
text name of the current program used in lookup and debugging
bool m_debugState
debug mode flag
#define glUniformMatrix3x2fv
void enableAttribArray(const char *_name) const noexcept
enables the specified varying array
#define GL_INT_SAMPLER_1D
void disableAttribArray(const char *_name) const noexcept
disables the specified varying array
#define GL_INT_SAMPLER_2D_MULTISAMPLE
#define glBindFragDataLocation
#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY
void unbind() noexcept
method to unbind the current Program Object this will set the shader to be the glUseProgram(0) defaul...
#define glGetUniformLocation
#define GL_UNSIGNED_INT_ATOMIC_COUNTER
void setRegisteredUniform2f(const std::string &_varname, float _v0, float _v1) const noexcept
sets the registered uniform to a single float
#define GL_SAMPLER_2D_MULTISAMPLE
void getUniformfv(const char *_name, float *o_values) const noexcept
gets the current value of the specified uniform var
#define GL_INT_SAMPLER_2D
ShaderProgram(std::string _name) noexcept
create an OpenGL shader program it is initially empty and just has a name for id
bool m_linked
flag to indicate if the current Program has been linked
void setUniformMatrix3x2fv(const char *_varname, size_t _count, bool _transpose, const float *_value) const noexcept
sets '_varname' as a 3x2 matrix array
#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE
std::unordered_map< std::string, GLuint > m_attribs
a list of attributes for this object, mapping name to ID number
void setRegisteredUniformMatrix4fv(const std::string &_varname, size_t _count, bool _transpose, const float *_value) const noexcept
sets '_varname' as a 4D matrix array
void link() noexcept
link our program object with the attatched shaders if shader are not attached the program will report...
#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY
#define GL_UNSIGNED_INT_VEC4
#define glGetActiveUniform
void setRegisteredUniform4i(const std::string &_varname, int _v0, int _v1, int _v2, int _v3) const noexcept
sets the registered uniform to a single int
#define GL_INT_IMAGE_CUBE
void autoRegisterUniforms() noexcept
scan the shader source and find any uniforms and register them
#define glGetUniformBlockIndex
void setUniform4iv(const char *_varname, size_t _count, const GLint *_value) const noexcept
sets '_varname' as a 4D int array
#define GL_SAMPLER_CUBE_SHADOW
void setRegisteredUniform3f(const std::string &_varname, float _v0, float _v1, float _v2) const noexcept
sets the registered uniform to a single float
void printRegisteredUniforms() const noexcept
debug print the registered uniforms
void setUniform1fv(const char *_varname, size_t _count, const float *_value) const noexcept
sets '_varname' as a 1D float array
#define GL_SAMPLER_2D_ARRAY
void bindFragDataLocation(GLuint index, const std::string &_attribName) noexcept
bind fragment output location in the Program object to _index using attribname
void setUniform4f(const char *_varname, float _v0, float _v1, float _v2, float _v3) const noexcept
sets '_varname' as a float4
void setUniform4i(const char *_varname, GLint _v0, GLint _v1, GLint _v2, GLint _v3) const noexcept
sets '_varname' as a float4
void setUniformMatrix2x4fv(const char *_varname, size_t _count, bool _transpose, const float *_value) const noexcept
sets '_varname' as a 2x4 matrix array
#define GL_IMAGE_2D_MULTISAMPLE
void setRegisteredUniform1i(const std::string &_varname, int _v0) const noexcept
sets the registered uniform to a single int
#define GL_INT_SAMPLER_2D_RECT
GLsizei GLenum GLenum * types
#define glUniformMatrix4fv
#define GL_INT_SAMPLER_2D_ARRAY
#define GL_UNSIGNED_INT_VEC2
#define GL_INT_SAMPLER_BUFFER
void setUniform2iv(const char *_varname, size_t _count, const GLint *_value) const noexcept
sets '_varname' as a 2D int array
#define GL_IMAGE_2D_ARRAY
#define glUniformMatrix3fv
void use() noexcept
use this Shader object as the current Active shader once this is set it is active until unbind us cal...
and encapsulation of an OpenGL Shader object with associations for source code, etc. Used in conjunction with the ShaderProgram class
void setUniform1i(const char *_varname, GLint _v0) const noexcept
#define GL_INT_SAMPLER_1D_ARRAY
#define GL_UNSIGNED_INT_IMAGE_2D
void setUniformMatrix4fv(const char *_varname, size_t _count, bool _transpose, const float *_value) const noexcept
sets '_varname' as a 4D matrix array
void setUniform4fv(const char *_varname, size_t _count, const float *_value) const noexcept
sets '_varname' as a 4D float array
void setUniformMatrix2x3fv(const char *_varname, size_t _count, bool _transpose, const float *_value) const noexcept
sets '_varname' as a 2x3 matrix array
void setUniform3fv(const char *_varname, size_t _count, const float *_value) const noexcept
sets '_varname' as a 3D float array
#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY
GLuint const GLchar * name
#define GL_SAMPLER_BUFFER
#define GL_IMAGE_1D_ARRAY
#define GL_ACTIVE_ATTRIBUTES
void setUniform1iv(const char *_varname, size_t _count, const GLint *_value) const noexcept
sets '_varname' as a 1D int array
#define GL_UNSIGNED_INT_SAMPLER_2D
GLuint getUniformBlockIndex(const std::string &_uniformBlockName) const noexcept
get the index of a uniform bloc
#define GL_UNSIGNED_INT_SAMPLER_2D_RECT
void setRegisteredUniform2i(const std::string &_varname, int _v0, int _v1) const noexcept
sets the registered uniform to a single int
#define GL_INT_SAMPLER_3D
void setUniformMatrix2fv(const char *_varname, size_t _count, bool _transpose, const float *_value) const noexcept
sets '_varname' as a 2D matrix array
#define GL_UNSIGNED_INT_VEC3
#define GL_UNSIGNED_INT_IMAGE_CUBE
void setUniformMatrix4x3fv(const char *_varname, size_t _count, bool _transpose, const float *_value) const noexcept
sets '_varname' as a 4x3 matrix array
void printActiveUniforms() const noexcept
lists the available uniforms for the shader (this was a pain because the compiler quietly gets rid of...
#define glBindAttribLocation
#define glGetProgramInfoLog
#define GL_SAMPLER_2D_ARRAY_SHADOW
#define GL_UNSIGNED_INT_IMAGE_1D
#define GL_INT_IMAGE_2D_RECT
void getUniformiv(const char *_name, int *o_values) const noexcept
gets the current value of the specified uniform var
std::unordered_map< std::string, uniformData > m_registeredUniforms
a list of uniforms for this object, mapping name to ID number must be added by the user using the reg...
#define GL_INFO_LOG_LENGTH
#define glDisableVertexAttribArray
void setUniform2fv(const char *_varname, size_t _count, const float *_value) const noexcept
sets '_varname' as a 2D float array
#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY
#define GL_UNSIGNED_INT_SAMPLER_1D
#define GL_INT_SAMPLER_CUBE
#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE
void printProperties() const noexcept
calls the printActiveUniforms followed by Attribs method written by Richard Southern.
void bindAttribute(GLuint index, const std::string &_attribName) noexcept
bind an attribute in the Program object to _index using attribname
#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY
#define GL_UNSIGNED_INT_SAMPLER_3D
void setUniform3iv(const char *_varname, size_t _count, const GLint *_value) const noexcept
sets '_varname' as a 3D int array
#define GL_SAMPLER_2D_RECT_SHADOW
GLint getUniformLocation(const char *_name) const noexcept
returns the ID of the uniform attribute called 'name'.
#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY
void setUniformMatrix4x2fv(const char *_varname, size_t _count, bool _transpose, const float *_value) const noexcept
sets '_varname' as a 4x2 matrix array
NGL_DLLEXPORT void NGLCheckGLError(const std::string &_file, const int _line) noexcept
check for openGL errors and print out.
GLsizei const GLchar *const * string
#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY
void setRegisteredUniformMatrix3fv(const std::string &_varname, size_t _count, bool _transpose, const float *_value) const noexcept
sets '_varname' as a 3D matrix array
#define GL_SAMPLER_2D_SHADOW
void setUniform1f(const char *_varname, float __v0) const noexcept
sets '_varname' as a float
#define GL_SAMPLER_1D_ARRAY