feat: add model matrix transformation hierarchy and delta time tracking
This commit is contained in:
@@ -64,9 +64,9 @@ Shader shader_create(const char *vertexFile, const char *fragmentFile) {
|
||||
char *vertexSource = get_file_contents(vertexFile);
|
||||
char *fragmentSource = get_file_contents(fragmentFile);
|
||||
|
||||
if (!vertexSource || !fragmentSource) {
|
||||
if (vertexSource == NULL || fragmentSource == NULL) {
|
||||
log_error("Failed to load shader files. Returning empty shader\n");
|
||||
Shader emptyShader = { .ID = 0};
|
||||
Shader emptyShader = { .ID = 0, .camMatrixLocation = -1};
|
||||
if (vertexSource)
|
||||
free(vertexSource);
|
||||
if (fragmentSource)
|
||||
@@ -101,7 +101,19 @@ Shader shader_create(const char *vertexFile, const char *fragmentFile) {
|
||||
glDeleteShader(vertexShader);
|
||||
glDeleteShader(fragmentShader);
|
||||
|
||||
Shader newShader = { .ID = programID };
|
||||
GLint camMatrixLocation = glGetUniformLocation(programID, "camMatrix");
|
||||
if (camMatrixLocation == -1) {
|
||||
log_error("Uniform 'camMatrix' not found after linking shader program %u. Is it used in default.vert?", programID);
|
||||
}
|
||||
|
||||
GLint modelMatrixLocation = glGetUniformLocation(programID, "modelMatrix");
|
||||
if (modelMatrixLocation == -1) {
|
||||
log_warn("Uniform 'modelMatrix' not found in shader program %u. Is it used in default.vert?", programID);
|
||||
}
|
||||
|
||||
Shader newShader = { .ID = programID,
|
||||
.camMatrixLocation = camMatrixLocation,
|
||||
.modelMatrixLocation = modelMatrixLocation };
|
||||
return newShader;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
typedef struct {
|
||||
// Reference ID of the shader program
|
||||
GLuint ID;
|
||||
// Location of the camera matrix uniform, set at creation
|
||||
GLint camMatrixLocation;
|
||||
GLint modelMatrixLocation;
|
||||
} Shader;
|
||||
|
||||
char *get_file_contents(const char *filename);
|
||||
|
||||
Reference in New Issue
Block a user