Add basic transformation matrix

This commit is contained in:
Abdelrahman Said 2024-11-30 23:05:14 +00:00
parent 921324585f
commit efa4b7a6a8
2 changed files with 9 additions and 1 deletions

View File

@ -4,11 +4,13 @@ layout(location=0) in vec3 position;
layout(location=1) in vec3 color; layout(location=1) in vec3 color;
layout(location=2) in vec2 uv; layout(location=2) in vec2 uv;
uniform mat4 matrix;
out vec3 vert_color; out vec3 vert_color;
out vec2 tex_coords; out vec2 tex_coords;
void main() { void main() {
tex_coords = uv; tex_coords = uv;
vert_color = color; vert_color = color;
gl_Position = vec4(position, 1.0); gl_Position = matrix * vec4(position, 1.0);
}; };

View File

@ -175,6 +175,12 @@ int main() {
float texture_mix_factor = 0.2f; float texture_mix_factor = 0.2f;
glm::mat4 mat = glm::mat4(1.0f);
mat = glm::rotate(mat, glm::radians(90.0f), glm::vec3(0.0f, 0.0f, 1.0f));
mat = glm::scale(mat, glm::vec3(0.5f, 0.5f, 0.5f));
glUniformMatrix4fv(glGetUniformLocation(main_shader.program, "matrix"), 1, GL_FALSE, glm::value_ptr(mat));
bool running = true; bool running = true;
SDL_Event event = {}; SDL_Event event = {};
while (running) { while (running) {