class ffw::GLShader
Class List > ffw :: GLShader
An OpenGL shader. More...
Public Functions
Type | Name |
---|---|
GLShader () | |
GLShader (GLenum type, const std::string & code) | |
GLShader (const GLShader & other) = delete | |
GLShader (GLShader && other) | |
virtual | ~GLShader () |
GLShader & | operator= (const GLShader & other) = delete |
GLShader & | operator= (GLShader && other) |
void | swap (GLShader & other) |
void | destroy () |
GLint | getHandle () const |
bool | isCreated () const |
GLenum | getType () const |
Detailed Description
An example code below:
// Somewhere in your chode
ffw::GLProgram program;
ffw::GLShader vertShader;
ffw::GLShader fragShader;
// Initialization (run this only once)
try {
// Compiles the shaders
vertShader = ffw::GLShader(GL_VERTEX_SHADER, ...shader code here as string...);
fragShader = ffw::GLShader(GL_FRAGMENT_SHADER, ...shader code here as string...);
// Links the two shaders into one program
program = ffw::GLProgram({ &vertShader, &fragShader });
} catch (ffw::GLException& e) {
std::cerr << "Something went wrong: " << e.what() << std::endl;
}
// Rendering
while(true) {
// Begin our shader program
program.bind();
// Bind VBOs, VAos, etc...
// Bind uniforms, attributes...
program.setUniformMatrix4fv(
boxProgram.getUniformLocation("model"), &matrix[0], 1);
// Draw the vertices using VBO
program.drawArrays(GL_TRIANGLES, 0, 24);
// Stops the shader program
program.unbind();
}
Public Functions Documentation
function GLShader (1/4)
ffw::GLShader::GLShader ()
function GLShader (2/4)
ffw::GLShader::GLShader (
GLenum type,
const std::string & code
)
function GLShader (3/4)
ffw::GLShader::GLShader (
const GLShader & other
) = delete
function GLShader (4/4)
ffw::GLShader::GLShader (
GLShader && other
)
function ~GLShader
virtual ffw::GLShader::~GLShader ()
function operator= (1/2)
GLShader & ffw::GLShader::operator= (
const GLShader & other
) = delete
function operator= (2/2)
GLShader & ffw::GLShader::operator= (
GLShader && other
)
function swap
void ffw::GLShader::swap (
GLShader & other
)
function destroy
void ffw::GLShader::destroy ()
function getHandle
GLint ffw::GLShader::getHandle () const
function isCreated
bool ffw::GLShader::isCreated () const
function getType
GLenum ffw::GLShader::getType () const
The documentation for this class was generated from the following file: include/ffw/graphics/glshader.h