#include "../../../include/RenderBackend/OpenGL/ShaderVec.hpp" #include "../../../include/RenderBackend/OpenGL/VertexShader.hpp" #include "../../../include/RenderBackend/OpenGL/PixelShader.hpp" #include "../../../include/RenderBackend/OpenGL/ShaderProgram.hpp" #include "../../../include/RenderBackend/OpenGL/opengl.hpp" #include #include using namespace std; namespace amalgine { AttributeType getAttributeTypeByName(const char *attributeName) { if(strncmp(attributeName, "vec2", 4) == 0) { return AttributeType::VEC2; } return AttributeType::NONE; } const string& ShaderInputVec2::getName() const { return vertexShader->getInputAttributeName(attributeIndex); } void ShaderInputVec2::setData(const DeviceMemory &data) { data.use(); AttributeType attributeType = vertexShader->getInputAttributeType(attributeIndex); switch(attributeType) { case AttributeType::VEC2: { glVertexAttribPointer(attributeIndex, 2, GL_FLOAT, GL_FALSE, 0, 0); break; } default: assert(false); break; } glEnableVertexAttribArray(attributeIndex); } const string& ShaderOutputVec4::getName() const { return pixelShader->getOutputAttributeName(attributeIndex); } void ShaderOutputVec4::operator=(const ShaderVec4 &shaderVec4) { pixelShader->assign(*this, shaderVec4); } }