Exponent/src/Quad.cc

30 lines
668 B
C++

#include "Quad.hh"
#include <glad/gl.h>
#include <GLFW/glfw3.h>
Quad::Quad(std::span<glm::vec2> verts, const Uniform &uniform_data)
: m_mesh(verts) {
m_uniform_data.rotation = uniform_data.rotation;
m_uniform_data.world_pos = uniform_data.world_pos;
}
glm::vec2 Quad::get_position_vector() {
return glm::vec2(m_pos_x, m_pos_y);
}
void Quad::draw(){
float time = glfwGetTime();
m_rotation = 2*sin(time);
m_pos_x = 0.25*sin(time);
m_pos_y = 0.5*cos(time);
glUniform2f(m_uniform_data.world_pos, m_pos_x, m_pos_y);
glUniform1f(m_uniform_data.rotation, m_rotation);
m_mesh.bindVAO();
glDrawArrays(GL_TRIANGLES, 0, 6);
}