| 29 #include "ascension/context.h" |
29 #include "ascension/context.h" |
| 30 #include "ascension/texture.h" |
30 #include "ascension/texture.h" |
| 31 #include "ascension/filesystem.h" |
31 #include "ascension/filesystem.h" |
| 32 |
32 |
| 33 #include <assert.h> |
33 #include <assert.h> |
| 34 #include <GL/glew.h> |
34 #include "glad.h" |
| 35 #include <SDL3_image/SDL_image.h> |
35 #include <SDL3_image/SDL_image.h> |
| 36 |
36 |
| 37 void asc_texture_bind(const AscTexture *tex, int uniform_location, int unit) { |
37 void asc_texture_bind(const AscTexture *tex, int uniform_location, int unit) { |
| 38 glActiveTexture(GL_TEXTURE0 + unit); |
38 glActiveTexture(GL_TEXTURE0 + unit); |
| 39 GLenum error = glGetError(); |
39 GLenum error = glGetError(); |
| 89 surface->w, surface->h, |
89 surface->w, surface->h, |
| 90 0, format, |
90 0, format, |
| 91 GL_UNSIGNED_BYTE, surface->pixels); |
91 GL_UNSIGNED_BYTE, surface->pixels); |
| 92 asc_error_catch_gl("Writing texture data"); |
92 asc_error_catch_gl("Writing texture data"); |
| 93 if (tex->use_mipmaps) { |
93 if (tex->use_mipmaps) { |
| 94 glGenerateTextureMipmap(tex->tex_id); |
94 glGenerateMipmap(tex->target); |
| 95 asc_error_catch_gl("Generating texture mipmaps"); |
95 asc_error_catch_gl("Generating texture mipmaps"); |
| 96 } |
96 } |
| 97 } |
97 } |
| 98 |
98 |
| 99 void asc_texture_from_file(AscTexture *tex, const char *name) { |
99 void asc_texture_from_file(AscTexture *tex, const char *name) { |