// Copyright (c) 2024 Dominic Masters // // This software is released under the MIT License. // https://opensource.org/licenses/MIT #include "ShaderData.hpp" #include "assert/assert.hpp" #include "assert/assertgl.hpp" using namespace Dawn; void ShaderData::beginStruct() { // Do nothing } void ShaderData::writeMat4(const glm::mat4 &mat) { char_t name[1024]; GLsizei length; GLint size; GLenum type; glGetActiveUniform(getShader()->id, i, sizeof(name), &length, &size, &type, name); assertNoGLError(); std::cout << "Uniform: " << name << std::endl; glUniformMatrix4fv(this->i, 1, GL_FALSE, glm::value_ptr(mat)); assertNoGLError(); this->i++; } void ShaderData::writeVec3(const glm::vec3 &vec) { assertUnreachable("Not implemented"); } void ShaderData::writeVec4(const glm::vec4 &vec) { assertUnreachable("Not implemented"); } void ShaderData::writeColor(const struct Color &color) { glUniform4fv(this->i, 1, &color.r); assertNoGLError(); this->i++; } void ShaderData::writeBoolean(const bool &value) { glUniform1i(this->i, value ? 1 : 0); assertNoGLError(); this->i++; } void ShaderData::writeTexture(std::shared_ptr &texture) { if(texture == nullptr) { this->i++; return; } texture->bind(0); glUniform1i(this->i, 0); assertNoGLError(); this->i++; } void ShaderData::endStruct() { // Do nothing }