diff options
Diffstat (limited to 'include/RenderBackend/OpenGL/VertexShader.hpp')
-rw-r--r-- | include/RenderBackend/OpenGL/VertexShader.hpp | 71 |
1 files changed, 6 insertions, 65 deletions
diff --git a/include/RenderBackend/OpenGL/VertexShader.hpp b/include/RenderBackend/OpenGL/VertexShader.hpp index aaf8b24..6fdd6a4 100644 --- a/include/RenderBackend/OpenGL/VertexShader.hpp +++ b/include/RenderBackend/OpenGL/VertexShader.hpp @@ -1,79 +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 VertexShaderTooManyAttributes : public std::runtime_error - { - public: - VertexShaderTooManyAttributes(i32 maxVertexAttributes); - }; - - class VertexShaderAttributeAlreadyDefined : public std::runtime_error - { - public: - VertexShaderAttributeAlreadyDefined(const std::string &attributeName); - }; - - class VertexShaderInvalidAttributeName : public std::runtime_error - { - public: - VertexShaderInvalidAttributeName(const std::string &attributeName); - }; - - class VertexShaderFunctionAlreadyDefined : public std::runtime_error - { - public: - VertexShaderFunctionAlreadyDefined(const std::string &funcName); - }; - - using VertexShaderMainFunc = std::function<ShaderVec4()>; - - /* - * Using the same VertexShader instance in multiple threads to define data is not thread safe. - * All get*** functions are thread safe. - */ +namespace amalgine { class CompiledVertexShader; + + using VertexShaderMainFunc = std::function<ShaderVec4()>; - class VertexShader + class VertexShader : public Shader { DISABLE_COPY(VertexShader) friend class ShaderProgram; public: VertexShader(); - - const std::string& getInputAttributeName(i32 attributeIndex) const; - AttributeType getInputAttributeType(i32 attributeIndex) const; - ShaderInputVec2 defineInputVec2(const std::string &name); + void defineMain(VertexShaderMainFunc mainFunc); Result<CompiledVertexShader*> compile(); - private: - void writeHeader(const std::string &code); - void writeBody(const std::string &code); - std::string build() const; - - /* - * Throws VertexShaderTooManyInputAttributes if too many vertex attributes are defined for the platform. - * Throws VertexShaderAttributeAlreadyDefined if a vertex attribute with the same name has already been defined. - */ - i32 defineInputVariable(const std::string &variableName, const char *typeName); - private: - std::string header; - std::string body; - int locationCounter; - i32 maxVertexAttribs; // Could make this static - std::unordered_map<std::string, i32> vertexAttributes; - std::vector<ShaderAttribute> vertexAttributeNames; - bool mainFuncDefined; }; } |