aboutsummaryrefslogtreecommitdiff
path: root/include/RenderBackend/OpenGL/ShaderVec.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/RenderBackend/OpenGL/ShaderVec.hpp')
-rw-r--r--include/RenderBackend/OpenGL/ShaderVec.hpp56
1 files changed, 55 insertions, 1 deletions
diff --git a/include/RenderBackend/OpenGL/ShaderVec.hpp b/include/RenderBackend/OpenGL/ShaderVec.hpp
index a5163ba..7c14af1 100644
--- a/include/RenderBackend/OpenGL/ShaderVec.hpp
+++ b/include/RenderBackend/OpenGL/ShaderVec.hpp
@@ -8,15 +8,60 @@ namespace amalgine
{
class VertexShader;
class PixelShader;
+ class ShaderProgram;
enum class AttributeType
{
NONE,
- VEC2
+ VEC2,
+ VEC3,
+ VEC4
};
AttributeType getAttributeTypeByName(const char *attributeName);
+ class ShaderGlobalVec
+ {
+ friend class VertexShader;
+ friend class PixelShader;
+ friend class ShaderGlobalVec3;
+ public:
+ ShaderGlobalVec() : attributeType(AttributeType::NONE) {}
+ const std::string& getName() const { return name; }
+ AttributeType getAttributeType() const { return attributeType; }
+ protected:
+ ShaderGlobalVec(const std::string &_name, AttributeType _attributeType) : name(_name), attributeType(_attributeType) {}
+ private:
+ std::string name;
+ AttributeType attributeType;
+ };
+
+ class ShaderGlobalVec3
+ {
+ friend class VertexShader;
+ friend class PixelShader;
+ public:
+ const std::string& getName() const { return globalVec.getName(); }
+ AttributeType getAttributeType() const { return globalVec.getAttributeType(); }
+ ShaderGlobalVec getVecObject() const { return globalVec; }
+ private:
+ ShaderGlobalVec3(const std::string &_name) : globalVec(_name, AttributeType::VEC3) {}
+ private:
+ ShaderGlobalVec globalVec;
+ };
+
+ class ShaderProgramGlobalVec3
+ {
+ friend class ShaderProgram;
+ public:
+ void set(f32 x = 0.0f, f32 y = 0.0f, f32 z = 0.0f);
+ private:
+ ShaderProgramGlobalVec3(ShaderProgram *_shaderProgram, i32 _uniformId) : shaderProgram(_shaderProgram), uniformId(_uniformId){}
+ private:
+ ShaderProgram *shaderProgram;
+ i32 uniformId;
+ };
+
class ShaderInputVec2
{
friend class VertexShader;
@@ -62,6 +107,15 @@ namespace amalgine
result += ")";
}
+ ShaderVec4(const ShaderGlobalVec3 &vec3, f32 w = 0.0f)
+ {
+ result = "vec4(";
+ result += vec3.getName();
+ result += ", ";
+ result += std::to_string(w);
+ result += ")";
+ }
+
const std::string& getOutput() const
{
return result;