mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-29 07:19:28 -05:00
Cleanup GPUData and remove confusing UniformLocation class
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user