mirror of
https://github.com/TomHarte/CLK.git
synced 2024-07-17 13:29:02 +00:00
Standardised indentation and added one extra piece of documentation.
This commit is contained in:
parent
20aa9e291d
commit
88e237b8de
@ -12,52 +12,59 @@
|
|||||||
#include "OpenGL.hpp"
|
#include "OpenGL.hpp"
|
||||||
|
|
||||||
namespace OpenGL {
|
namespace OpenGL {
|
||||||
class Shader {
|
|
||||||
public:
|
|
||||||
enum {
|
|
||||||
VertexShaderCompilationError,
|
|
||||||
FragmentShaderCompilationError,
|
|
||||||
ProgramLinkageError
|
|
||||||
};
|
|
||||||
|
|
||||||
struct AttributeBinding {
|
/*!
|
||||||
const GLchar *name;
|
A @c Shader compiles and holds a shader object, based on a single
|
||||||
GLuint index;
|
vertex program and a single fragment program. Attribute bindings
|
||||||
};
|
may be supplied if desired.
|
||||||
|
*/
|
||||||
|
class Shader {
|
||||||
|
public:
|
||||||
|
enum {
|
||||||
|
VertexShaderCompilationError,
|
||||||
|
FragmentShaderCompilationError,
|
||||||
|
ProgramLinkageError
|
||||||
|
};
|
||||||
|
|
||||||
/*!
|
struct AttributeBinding {
|
||||||
Attempts to compile a shader, throwing @c VertexShaderCompilationError, @c FragmentShaderCompilationError or @c ProgramLinkageError upon failure.
|
const GLchar *name;
|
||||||
@param vertex_shader The vertex shader source code.
|
GLuint index;
|
||||||
@param fragment_shader The fragment shader source code.
|
};
|
||||||
@param attribute_bindings Either @c nullptr or an array terminated by an entry with a @c nullptr-name of attribute bindings.
|
|
||||||
*/
|
|
||||||
Shader(const char *vertex_shader, const char *fragment_shader, const AttributeBinding *attribute_bindings);
|
|
||||||
~Shader();
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Performs an @c glUseProgram to make this the active shader.
|
Attempts to compile a shader, throwing @c VertexShaderCompilationError, @c FragmentShaderCompilationError or @c ProgramLinkageError upon failure.
|
||||||
*/
|
@param vertex_shader The vertex shader source code.
|
||||||
void bind();
|
@param fragment_shader The fragment shader source code.
|
||||||
|
@param attribute_bindings Either @c nullptr or an array terminated by an entry with a @c nullptr-name of attribute bindings.
|
||||||
|
*/
|
||||||
|
Shader(const char *vertex_shader, const char *fragment_shader, const AttributeBinding *attribute_bindings);
|
||||||
|
~Shader();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Performs a @c glGetAttribLocation call.
|
Performs an @c glUseProgram to make this the active shader.
|
||||||
@param name The name of the attribute to locate.
|
*/
|
||||||
@returns The location of the requested attribute.
|
void bind();
|
||||||
*/
|
|
||||||
GLint get_attrib_location(const GLchar *name);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Performs a @c glGetUniformLocation call.
|
Performs a @c glGetAttribLocation call.
|
||||||
@param name The name of the uniform to locate.
|
@param name The name of the attribute to locate.
|
||||||
@returns The location of the requested uniform.
|
@returns The location of the requested attribute.
|
||||||
*/
|
*/
|
||||||
GLint get_uniform_location(const GLchar *name);
|
GLint get_attrib_location(const GLchar *name);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Performs a @c glGetUniformLocation call.
|
||||||
|
@param name The name of the uniform to locate.
|
||||||
|
@returns The location of the requested uniform.
|
||||||
|
*/
|
||||||
|
GLint get_uniform_location(const GLchar *name);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GLuint compile_shader(const char *source, GLenum type);
|
GLuint compile_shader(const char *source, GLenum type);
|
||||||
GLuint _shader_program;
|
GLuint _shader_program;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Shader_hpp */
|
#endif /* Shader_hpp */
|
||||||
|
Loading…
Reference in New Issue
Block a user