diff options
| author | Aaditya Dhruv <[email protected]> | 2026-01-30 19:12:03 -0600 |
|---|---|---|
| committer | Aaditya Dhruv <[email protected]> | 2026-01-30 19:12:03 -0600 |
| commit | 1a721b98caf7559f4a18baa8d3b92269e8f1f6ce (patch) | |
| tree | 32be8966361f8f8ae74c6c0af226e39fe9feb375 /src/shader.c | |
| parent | 4992ce0098cac8caef6c9315816b688d96259bce (diff) | |
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
Diffstat (limited to 'src/shader.c')
| -rw-r--r-- | src/shader.c | 10 |
1 files changed, 10 insertions, 0 deletions
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; +} |
