Skip to content

Commit

Permalink
Matrices! Changed mat3, mat4 types to sized arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaimer9 committed Jan 23, 2023
1 parent 3fd8909 commit cc913d3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions include/core/matrix.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once

typedef float* mat3;
typedef float* mat4;
typedef float mat3[9];
typedef float mat4[16];
18 changes: 17 additions & 1 deletion src/Shaders.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ void upload_shader_vec4(shader_program program, const char* var, vec4 value)

void upload_shader_mat3(shader_program program, const char* var, mat3 value)
{
if (!value)
{
#ifdef MUZZLE_VERBOSE
log_status(STATUS_ERROR, "Failed to upload mat3 to shader");
#endif
return;
}

GLuint uniform_location = glGetUniformLocation(program, var);
glUseProgram(program);
glUniformMatrix3fv(uniform_location, 1, 0, value);
Expand All @@ -153,8 +161,16 @@ void upload_shader_mat3(shader_program program, const char* var, mat3 value)
#endif
}

void upload_shader_mat4(shader_program program, const char* var, mat value)
void upload_shader_mat4(shader_program program, const char* var, mat4 value)
{
if (!value)
{
#ifdef MUZZLE_VERBOSE
log_status(STATUS_ERROR, "Failed to upload mat4 to shader");
#endif
return;
}

GLuint uniform_location = glGetUniformLocation(program, var);
glUseProgram(program);
glUniformMatrix3fv(uniform_location, 1, 0, value);
Expand Down

0 comments on commit cc913d3

Please sign in to comment.