aboutsummaryrefslogtreecommitdiff
path: root/include/RenderBackend/OpenGL/ShaderProgram.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/RenderBackend/OpenGL/ShaderProgram.hpp')
-rw-r--r--include/RenderBackend/OpenGL/ShaderProgram.hpp40
1 files changed, 22 insertions, 18 deletions
diff --git a/include/RenderBackend/OpenGL/ShaderProgram.hpp b/include/RenderBackend/OpenGL/ShaderProgram.hpp
index efeae5b..a3e8a0f 100644
--- a/include/RenderBackend/OpenGL/ShaderProgram.hpp
+++ b/include/RenderBackend/OpenGL/ShaderProgram.hpp
@@ -1,34 +1,38 @@
#pragma once
-#include "VertexShader.hpp"
-#include "PixelShader.hpp"
#include "../../Result.hpp"
#include "../../types.hpp"
+#include "../../utils.hpp"
#include <vector>
+#include <stdexcept>
namespace amalgine
{
+ class CompiledVertexShader;
+ class CompiledPixelShader;
+
+ class ShaderProgramUsedBeforeBuilt : public std::runtime_error
+ {
+ public:
+ // TODO: Add name to ShaderProgram so we know which shader has issue when
+ // an exception is thrown?
+ ShaderProgramUsedBeforeBuilt();
+ };
+
class ShaderProgram
{
+ DISABLE_COPY(ShaderProgram)
public:
ShaderProgram();
+ ~ShaderProgram();
- const std::string& getOutputAttributeName(i32 attributeIndex);
- ShaderOutputVec4 defineOutputVec4(const std::string &name);
- //Result<std::string> addVertexShader(const VertexShader &vertexShader);
- //Result<std::string> addPixelShader(const PixelShader &pixelShader);
- //void build();
- private:
- /*
- * 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);
+ bool addVertexShader(CompiledVertexShader *vertexShader);
+ bool addPixelShader(CompiledPixelShader *pixelShader);
+
+ Result<bool> build();
+ void use();
private:
- int locationCounter;
- i32 maxPixelAttribs; // Could make this static
- std::unordered_map<std::string, i32> pixelAttributes;
- std::vector<std::string> pixelAttributeNames;
- std::vector<u32> shaderIds;
+ u32 shaderProgramId;
+ bool built;
};
}