aboutsummaryrefslogtreecommitdiff
path: root/include/RenderBackend/OpenGL/ShaderVec.hpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2017-12-20 20:55:05 +0100
committerdec05eba <dec05eba@protonmail.com>2021-11-18 15:21:46 +0100
commitca92d8c90f7103db6d7cae4cef49b278d804b474 (patch)
treebaf44e42fcc1cf7e871a7b2f1d3d92f680f3a845 /include/RenderBackend/OpenGL/ShaderVec.hpp
parent3d7f123c0fc0af4b8df3ad791b264d22268bd423 (diff)
Create shader using c++ code
Diffstat (limited to 'include/RenderBackend/OpenGL/ShaderVec.hpp')
-rw-r--r--include/RenderBackend/OpenGL/ShaderVec.hpp81
1 files changed, 81 insertions, 0 deletions
diff --git a/include/RenderBackend/OpenGL/ShaderVec.hpp b/include/RenderBackend/OpenGL/ShaderVec.hpp
new file mode 100644
index 0000000..10e628c
--- /dev/null
+++ b/include/RenderBackend/OpenGL/ShaderVec.hpp
@@ -0,0 +1,81 @@
+#pragma once
+
+#include "../../types.hpp"
+#include <string>
+
+namespace amalgine
+{
+ class VertexShader;
+ class PixelShader;
+
+ class ShaderInputVec2
+ {
+ friend class VertexShader;
+ public:
+ const std::string& getName() const;
+ private:
+ ShaderInputVec2(VertexShader *_vertexShader, i32 _attributeIndex) :
+ vertexShader(_vertexShader),
+ attributeIndex(_attributeIndex)
+ {
+
+ }
+ private:
+ VertexShader *vertexShader;
+ i32 attributeIndex;
+ };
+
+ class ShaderVec4
+ {
+ public:
+ ShaderVec4(f32 x = 0.0f, f32 y = 0.0f, f32 z = 0.0f, f32 w = 0.0f)
+ {
+ result = "vec4(";
+ result += std::to_string(x);
+ result += ", ";
+ result += std::to_string(y);
+ result += ", ";
+ result += std::to_string(z);
+ result += ", ";
+ result += std::to_string(w);
+ result += ")";
+ }
+
+ ShaderVec4(const ShaderInputVec2 &vec2, f32 z = 0.0f, f32 w = 0.0f)
+ {
+ result = "vec4(";
+ result += vec2.getName();
+ result += ", ";
+ result += std::to_string(z);
+ result += ", ";
+ result += std::to_string(w);
+ result += ")";
+ }
+
+ const std::string& getOutput() const
+ {
+ return result;
+ }
+ private:
+ std::string result;
+ };
+
+ class ShaderOutputVec4
+ {
+ friend class PixelShader;
+ public:
+ const std::string& getName() const;
+
+ void operator=(const ShaderVec4 &shaderVec4);
+ private:
+ ShaderOutputVec4(PixelShader *_pixelShader, i32 _attributeIndex) :
+ pixelShader(_pixelShader),
+ attributeIndex(_attributeIndex)
+ {
+
+ }
+ private:
+ PixelShader *pixelShader;
+ i32 attributeIndex;
+ };
+}