14 #ifndef SRC_SHADERPROGRAM_H_
15 #define SRC_SHADERPROGRAM_H_
229 GLuint vertexShader_;
230 GLuint fragmentShader_;
232 std::map<std::string, int> texBindings_;
Represents a 4-component (R,G,B,A) color, stored internally in a float array to be compatable with Op...
A 4x4 transformation matrix stored internally as an array of floats in column-major order so as to be...
A 2D Point with floating point coordinates, used for storing 2D texture coordinates,...
A 3D Point with floating point coordinates, used for storing vertices and all sorts of other 3D graph...
A wrapper around GLSL shader programs.
void SetUniform(const std::string &name, const Vector3 &v)
Passes the x,y,z,0 values of vector v to the shader program and stores the result in the shader varia...
ShaderProgram()
Creates an empty ShaderProgram object.
void SetUniformArray4(const std::string &name, unsigned int *ui, int count)
Passes an array of count 4D unsigned int arrays to the shader program and stores the result in the sh...
void StopProgram()
Call this after rendering geometry to deactivate the shader.
bool initialized()
Returns true if the shader program has been successfully compiled and linked.
void SetUniform(const std::string &name, const Point2 &p)
Passes the x,y values of point p to the shader program and stores the result in the shader variable n...
void BindTexture(const std::string &name, const Texture2D &tex)
Binds a Texture2D to a sampler2D in the shader program. This version automatically selects an availab...
void SetUniformArray1(const std::string &name, int *i, int count)
Passes an array of count ints to the shader program and stores the result in the shader variable name...
void SetUniformArray1(const std::string &name, float *f, int count)
Passes an array of count floats to the shader program and stores the result in the shader variable na...
bool AddVertexShaderFromFile(const std::string &file)
Call during initialization but after the OpenGL context has been created (e.g., inside InitOpenGL())....
void SetUniform(const std::string &name, float f)
Passes the float to the shader program and stores the result in the shader variable named name,...
void SetUniformArray2(const std::string &name, unsigned int *ui, int count)
Passes an array of count 2D unsigned int arrays to the shader program and stores the result in the sh...
void SetUniform(const std::string &name, unsigned int ui)
Passes the unsigned int to the shader program and stores the result in the shader variable named name...
void SetUniform(const std::string &name, const Matrix4 &m)
Passes the column-major 16 float values of matrix m to the shader program and stores the result in th...
bool AddFragmentShaderFromSource(const std::string &code)
This loads and compiles a shader from a string. An error will be printed to stderr if there are any c...
void SetUniformArray3(const std::string &name, unsigned int *ui, int count)
Passes an array of count 3D unsigned int arrays to the shader program and stores the result in the sh...
void SetUniformArray2(const std::string &name, float *f, int count)
Passes an array of count 2D float arrays to the shader program and stores the result in the shader va...
void SetUniformArray4(const std::string &name, float *f, int count)
Passes an array of count 4D float arrays to the shader program and stores the result in the shader va...
void SetUniformArray2(const std::string &name, int *i, int count)
Passes an array of count 2D int arrays to the shader program and stores the result in the shader vari...
void SetUniform(const std::string &name, const Color &c)
Passes the r,g,b,a values of color c to the shader program and stores the result in the shader variab...
void SetUniformArray4(const std::string &name, int *i, int count)
Passes an array of count 4D int arrays to the shader program and stores the result in the shader vari...
void SetUniform(const std::string &name, int i)
Passes the int to the shader program and stores the result in the shader variable named name,...
bool AddVertexShaderFromSource(const std::string &code)
This loads and compiles a shader from a string. An error will be printed to stderr if there are any c...
void SetUniformArray1(const std::string &name, unsigned int *ui, int count)
Passes an array of count unsigned ints to the shader program and stores the result in the shader vari...
void SetUniformArray3(const std::string &name, int *i, int count)
Passes an array of count 3D int arrays to the shader program and stores the result in the shader vari...
void SetUniform(const std::string &name, const Point3 &p)
Passes the x,y,z,1 values of point p to the shader program and stores the result in the shader variab...
bool AddFragmentShaderFromFile(const std::string &file)
Call during initialization but after the OpenGL context has been created (e.g., inside InitOpenGL())....
bool LinkProgram()
Call this after adding vertex and fragment shaders in order to link them together to create the full ...
void SetUniform(const std::string &name, const Vector2 &v)
Passes the x,y values of vector v to the shader program and stores the result in the shader variable ...
void UseProgram()
Call this first to make the shader program active, then call SetUniform() to pass data from your C++ ...
void BindTexture(const std::string &name, const Texture2D &tex, int texUnit)
Binds a Texture2D to a sampler2D in the shader program. This version allows you to specify the textur...
void SetUniformArray3(const std::string &name, float *f, int count)
Passes an array of count 3D float arrays to the shader program and stores the result in the shader va...
A wrapper around a 2D texture that supports loading images from files or setting texture color data d...
A 2D Vector with floating point coordinates, used for storing 2D translations, mouse movements,...
A 3D Vector with floating point coordinates, used for storing normals and all sorts of other 3D graph...
Namespace for the MinGfx Toolkit.