aboutsummaryrefslogtreecommitdiff
path: root/include/RenderBackend/OpenGL/PixelShader.hpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-10-27 01:30:34 +0200
committerdec05eba <dec05eba@protonmail.com>2021-11-18 15:21:48 +0100
commitfbd2e5d9a802db4fb5e056705ec599ac423e09be (patch)
treeebe71975909a0767b5de045c28fc28d09292bca3 /include/RenderBackend/OpenGL/PixelShader.hpp
parent24934c7823457767855bd0abb249a55b8a8c077d (diff)
Create Shader class as a base for vertex and pixel shader
Diffstat (limited to 'include/RenderBackend/OpenGL/PixelShader.hpp')
-rw-r--r--include/RenderBackend/OpenGL/PixelShader.hpp74
1 files changed, 6 insertions, 68 deletions
diff --git a/include/RenderBackend/OpenGL/PixelShader.hpp b/include/RenderBackend/OpenGL/PixelShader.hpp
index 6794fb1..ebe5a12 100644
--- a/include/RenderBackend/OpenGL/PixelShader.hpp
+++ b/include/RenderBackend/OpenGL/PixelShader.hpp
@@ -1,82 +1,20 @@
#pragma once
-#include "../../DataView.hpp"
-#include "../../utils.hpp"
-#include "../../Result.hpp"
-#include "CommonShader.hpp"
-#include "ShaderVec.hpp"
-#include <string>
-#include <unordered_map>
-#include <vector>
-#include <stdexcept>
-#include <functional>
+#include "Shader.hpp"
-namespace amalgine
-{
- class PixelShaderTooManyAttributes : public std::runtime_error
- {
- public:
- PixelShaderTooManyAttributes(i32 maxPixelAttributes);
- };
-
- class PixelShaderAttributeAlreadyDefined : public std::runtime_error
- {
- public:
- PixelShaderAttributeAlreadyDefined(const std::string &attributeName);
- };
-
- class PixelShaderInvalidAttributeName : public std::runtime_error
- {
- public:
- PixelShaderInvalidAttributeName(const std::string &attributeName);
- };
-
- class PixelShaderFunctionAlreadyDefined : public std::runtime_error
- {
- public:
- PixelShaderFunctionAlreadyDefined(const std::string &funcName);
- };
-
- using PixelShaderMainFunc = std::function<void()>;
-
- /*
- * Using the same PixelShader instance in multiple threads to define data is not thread safe.
- * All get*** functions are thread safe.
- */
+namespace amalgine {
class CompiledPixelShader;
+
+ using PixelShaderMainFunc = std::function<void()>;
- class PixelShader
+ class PixelShader : public Shader
{
DISABLE_COPY(PixelShader)
friend class ShaderProgram;
public:
PixelShader();
-
- const std::string& getOutputAttributeName(i32 attributeIndex);
- ShaderOutputVec4 defineOutputVec4(const std::string &name);
- ShaderGlobalVec3 defineGlobalVec3(const std::string &name);
-
+
void defineMain(PixelShaderMainFunc mainFunc);
- void assign(const ShaderOutputVec4 &lhsVariable, const ShaderVec4 &rhsVariable);
Result<CompiledPixelShader*> compile();
- private:
- void writeHeader(const std::string &code);
- void writeBody(const std::string &code);
- std::string build() const;
-
- /*
- * Throws PixelShaderTooManyAttributes if too many pixel attributes are defined for the platform.
- * Throws PixelShaderAttributeAlreadyDefined if a pixel attribute with the same name has already been defined.
- */
- i32 defineOutputVariable(const std::string &variableName, const char *typeName);
- private:
- std::string header;
- std::string body;
- int locationCounter;
- i32 maxPixelAttribs; // Could make this static
- std::unordered_map<std::string, i32> pixelAttributes;
- std::vector<ShaderAttribute> pixelAttributeNames;
- std::unordered_map<std::string, ShaderGlobalVec> globalAttributes;
- bool mainFuncDefined;
};
}