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/util.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/util.c') diff --git a/src/util.c b/src/util.c index 0a5d983..b296b56 100644 --- a/src/util.c +++ b/src/util.c @@ -22,3 +22,12 @@ void create_ebo(GLuint *ebo, void* buf, int size) { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); } +void create_texture(GLuint* tbo, void* buf, vec2 size) { + glGenTextures(1, tbo); + glBindTexture(GL_TEXTURE_2D, *tbo); + float borderColor[] = { 1.0f, 1.0f, 1.0f, 1.0f }; + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, size[0], size[1], 0, GL_RGB, GL_UNSIGNED_BYTE, buf); + glGenerateMipmap(GL_TEXTURE_2D); + // glBindTexture(GL_TEXTURE_2D, 0); +} -- cgit