From 225167461d754b476b4fcc7726c492cc972ca654 Mon Sep 17 00:00:00 2001 From: sanine-a Date: Sun, 18 Oct 2020 12:10:48 -0500 Subject: clear out old files, add basic scripting --- src/texture.c | 45 --------------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 src/texture.c (limited to 'src/texture.c') diff --git a/src/texture.c b/src/texture.c deleted file mode 100644 index dfdbdd2..0000000 --- a/src/texture.c +++ /dev/null @@ -1,45 +0,0 @@ -#include "include/texture.h" - -enum honey_texture_result honey_texture_new(honey_texture* texture, - char* texture_path, - bool alpha_channel) { - unsigned int texture_id; - glGenTextures(1, &texture_id); - glBindTexture(GL_TEXTURE_2D, texture_id); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - int width, height, channels; - unsigned char* image_data = stbi_load(texture_path, &width, &height, &channels, 0); - if (image_data == NULL) { - fprintf(stderr, "ERROR: failed to load '%s'\n", texture_path); - return TEXTURE_FAILED; - } - - if (alpha_channel) { - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_data); - } - else { - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image_data); - } - - glGenerateMipmap(GL_TEXTURE_2D); - stbi_image_free(image_data); - - (*texture).texture_id = texture_id; - (*texture).width = width; - (*texture).height = height; - (*texture).channels = channels; - - return TEXTURE_OK; -} - -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -void honey_texture_use(honey_texture texture, int texture_unit) { - glActiveTexture(GL_TEXTURE0 + texture_unit); - glBindTexture(GL_TEXTURE_2D, texture.texture_id); -} -- cgit v1.2.1