aboutsummaryrefslogtreecommitdiff
path: root/include/RenderBackend/OpenGL/PixelShader.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/RenderBackend/OpenGL/PixelShader.hpp')
-rw-r--r--include/RenderBackend/OpenGL/PixelShader.hpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/include/RenderBackend/OpenGL/PixelShader.hpp b/include/RenderBackend/OpenGL/PixelShader.hpp
index b869a8f..e025c6f 100644
--- a/include/RenderBackend/OpenGL/PixelShader.hpp
+++ b/include/RenderBackend/OpenGL/PixelShader.hpp
@@ -1,6 +1,9 @@
#pragma once
#include "../../DataView.hpp"
+#include "../../utils.hpp"
+#include "../../Result.hpp"
+#include "CommonShader.hpp"
#include "ShaderVec.hpp"
#include <string>
#include <unordered_map>
@@ -40,20 +43,38 @@ namespace amalgine
* Using the same PixelShader instance in multiple threads to define data is not thread safe.
* All get*** functions are thread safe.
*/
+ class CompiledPixelShader;
+
class PixelShader
{
+ DISABLE_COPY(PixelShader)
+ friend class ShaderProgram;
public:
PixelShader();
+ const std::string& getOutputAttributeName(i32 attributeIndex);
+ ShaderOutputVec4 defineOutputVec4(const std::string &name);
+
void defineMain(PixelShaderMainFunc mainFunc);
void assign(const ShaderOutputVec4 &lhsVariable, const ShaderVec4 &rhsVariable);
- std::string build() const;
+ 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;
bool mainFuncDefined;
};
}