Browse Source

Shader: strongly typed State enum.

vectorfields
Vladimír Vondruš 14 years ago
parent
commit
707cbfd992
  1. 6
      src/Shader.cpp
  2. 12
      src/Shader.h

6
src/Shader.cpp

@ -71,7 +71,7 @@ bool Shader::addFile(const std::string& filename) {
GLuint Shader::compile() {
/* Already compiled, return */
if(_state != Initialized) return shader;
if(_state != State::Initialized) return shader;
/* Array of sources */
const GLchar** _sources = new const GLchar*[sources.size()];
@ -118,10 +118,10 @@ GLuint Shader::compile() {
}
if(status == GL_FALSE) {
_state = Failed;
_state = State::Failed;
return 0;
} else {
_state = Compiled;
_state = State::Compiled;
return shader;
}
}

12
src/Shader.h

@ -67,10 +67,10 @@ class MAGNUM_EXPORT Shader {
};
/** @brief %Shader state */
enum State {
Initialized, /**< @brief %Shader is loaded */
Compiled, /**< @brief %Shader is compiled */
Failed /**< @brief Compilation failed */
enum class State {
Initialized, /**< %Shader is loaded */
Compiled, /**< %Shader is compiled */
Failed /**< Compilation failed */
};
/**
@ -120,7 +120,7 @@ class MAGNUM_EXPORT Shader {
* or addFile().
* @see fromData(), fromFile()
*/
inline Shader(Type type): _type(type), _state(Initialized), shader(0) {
inline Shader(Type type): _type(type), _state(State::Initialized), shader(0) {
shader = glCreateShader(static_cast<GLenum>(_type));
}
@ -161,7 +161,7 @@ class MAGNUM_EXPORT Shader {
* @see addFile()
*/
inline void addSource(const std::string& source) {
if(_state == Initialized) sources.push_back(source);
if(_state == State::Initialized) sources.push_back(source);
}
/**

Loading…
Cancel
Save