diff options
Diffstat (limited to 'src/texture.c')
| -rw-r--r-- | src/texture.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/texture.c b/src/texture.c new file mode 100644 index 0000000..8f2a2a7 --- /dev/null +++ b/src/texture.c @@ -0,0 +1,26 @@ +#include "texture.h" +#include "cglm/io.h" +#include "util.h" +#define STB_IMAGE_IMPLEMENTATION +#include "stb/stb_image.h" +#include <stdlib.h> +#include <string.h> +void texture_init(struct texture** texture) { + *texture = malloc(sizeof(struct texture)); + memset(*texture, 0, sizeof(struct texture)); +} + +void texture_load(struct texture* texture, char* path) { + int width, height, nr_channels; + unsigned char *data = stbi_load(path, &width, &height, &nr_channels, 0); + vec2 size = { width, height }; + glm_vec2_print(size, stderr); + create_texture(&texture->_tbo, data, size); + stbi_image_free(data); + fprintf(stderr, "Loaded texture\n"); +} + +void texture_draw(struct texture* texture) { + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, texture->_tbo); +} |
