From 1a721b98caf7559f4a18baa8d3b92269e8f1f6ce Mon Sep 17 00:00:00 2001 From: Aaditya Dhruv Date: Fri, 30 Jan 2026 19:12:03 -0600 Subject: Add basic block textures - Remove the code that sent colors through uniform variables, instead send texture data - Each vertex now has a texture coordinate - struct texture is a easy way to represent textures, can be extended later - Shaders updated to use textures --- src/shader.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/shader.c') diff --git a/src/shader.c b/src/shader.c index 9c36791..c32b12f 100644 --- a/src/shader.c +++ b/src/shader.c @@ -82,3 +82,13 @@ int set_uniform_mat4(char* var, struct shader* shader, mat4 matrix) { glUniformMatrix4fv(loc, 1, GL_FALSE, (void*)matrix); return 0; } +int set_uniform_sampler2d(char* var, struct shader* shader, mat4 matrix) { + GLuint loc = glGetUniformLocation(shader->program, var); + if (loc == -1) { + fprintf(stderr, "Invalid var %s for get_uniform_mat4: Does not exist\n", var); + exit(1); + return -1; + } + glUniformMatrix4fv(loc, 1, GL_FALSE, (void*)matrix); + return 0; +} -- cgit