Cleanup GPUData and remove confusing UniformLocation class

This commit is contained in:
Alexander Bock
2017-12-31 17:31:41 -05:00
parent 47233b8e6f
commit 53cfc7dd91
3 changed files with 22 additions and 57 deletions
+22 -20
View File
@@ -34,39 +34,32 @@
namespace openspace {
/**
* Very simple class maintaining a uniform location.
*/
class UniformLocation {
public:
/**
* Updates the uniform location of the uniform variable named <name>
* in the provided shader program.
*/
void bind(ghoul::opengl::ProgramObject* program, const std::string& name);
protected:
GLint _uniformLocation = -1;
};
/**
* Manages a GPU representation of the templated data type T.
* This class provides a simple interface setting the value of
* the binded GLSL variable.
*/
template<typename T>
class GPUData : public UniformLocation{
class GPUData {
public:
/**
* Updates the uniform location of the uniform variable named <name>
* in the provided shader program.
*/
void bind(ghoul::opengl::ProgramObject* program, const std::string& name) {
_uniformLocation = program->uniformLocation(name);
}
/**
* Sets the value of T to its corresponding GPU value.
* OBS! Users must ensure bind has been called before using this method
*/
void setValue(ghoul::opengl::ProgramObject* program, T val){
void setValue(ghoul::opengl::ProgramObject* program, T val) {
program->setUniform(_uniformLocation, val);
}
protected:
GLint _uniformLocation = -1;
};
/**
@@ -74,8 +67,16 @@ public:
* This class provides a simple interface binding texture to the
* named uniform.
*/
class GPUTexture : public UniformLocation{
class GPUTexture {
public:
/**
* Updates the uniform location of the uniform variable named <name>
* in the provided shader program.
*/
void bind(ghoul::opengl::ProgramObject* program, const std::string& name) {
_uniformLocation = program->uniformLocation(name);
}
/**
* Sets and assignes a texture unit within the provided shader
* program.
@@ -96,6 +97,7 @@ public:
private:
std::unique_ptr<ghoul::opengl::TextureUnit> _texUnit;
GLint _uniformLocation = -1;
};
} // namespace openspace