diff options
author | pryazha <pryadeiniv@mail.ru> | 2025-06-15 16:07:54 +0500 |
---|---|---|
committer | pryazha <pryadeiniv@mail.ru> | 2025-06-15 16:07:54 +0500 |
commit | f30a4eba44c77d5c743fe9308dc697a3225e8dd8 (patch) | |
tree | c171da2e8d1127409e2ffe9e56e2e027bac48e28 /prge_texture.c | |
parent | 92a8eb610f40c9770569ca63ca1bd705a6d3497d (diff) |
i don't even know
Diffstat (limited to 'prge_texture.c')
-rw-r--r-- | prge_texture.c | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/prge_texture.c b/prge_texture.c deleted file mode 100644 index e6c0820..0000000 --- a/prge_texture.c +++ /dev/null @@ -1,59 +0,0 @@ -Texture load_texture(Arena *arena, const char *fname, B32 gamma) -{ - Texture texture; - U8 *data; - S32 nchannels; - GLenum internal_format; - GLenum data_format; - S32 size; - - MEM0STRUCT(&texture); - - stbi_set_flip_vertically_on_load(1); - data = stbi_load(fname, &texture.w, &texture.h, &nchannels, 0); - - if (!data) { - sys_printf("[ERROR] : Texture : %s : Failed to load\n", fname); - goto end; - } - - switch (nchannels) { - case 1: - texture.type = TextureType_R; - internal_format = data_format = GL_RED; - break; - case 3: - texture.type = TextureType_RGB; - internal_format = (gamma) ? GL_SRGB : GL_RGB; - data_format = GL_RGB; - break; - case 4: - texture.type = TextureType_RGBA; - internal_format = (gamma) ? GL_SRGB_ALPHA : GL_RGBA; - data_format = GL_RGBA; - break; - default: - sys_printf("[ERROR] : Texture : %s : Unsupported type\n", fname); - goto end; - } - - size = texture.type*texture.w*texture.h; - texture.data = push_arena(arena, size); - MEMCPY(texture.data, data, size); - - glGenTextures(1, &texture.id); - glBindTexture(GL_TEXTURE_2D, texture.id); - glTexImage2D(GL_TEXTURE_2D, 0, internal_format, texture.w, texture.h, - 0, data_format, GL_UNSIGNED_BYTE, texture.data); - glGenerateMipmap(GL_TEXTURE_2D); - 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_MIPMAP_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glBindTexture(GL_TEXTURE_2D, 0); - - sys_printf("[INFO] : Texture : %s : Loaded successfully\n", fname); -end: - stbi_image_free(data); - return texture; -} |