src/texture.c

changeset 149
560772519ff9
parent 135
062703d3f5cc
equal deleted inserted replaced
148:9f030f402699 149:560772519ff9
32 32
33 #include <assert.h> 33 #include <assert.h>
34 #include <GL/glew.h> 34 #include <GL/glew.h>
35 #include <SDL2/SDL_image.h> 35 #include <SDL2/SDL_image.h>
36 36
37 void asc_texture_bind(AscTexture const *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();
40 if (error == GL_INVALID_ENUM) { 40 if (error == GL_INVALID_ENUM) {
41 GLint max_units; 41 GLint max_units;
42 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &max_units); 42 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &max_units);
45 glBindTexture(tex->target, tex->tex_id); 45 glBindTexture(tex->target, tex->tex_id);
46 glUniform1i(uniform_location, unit); 46 glUniform1i(uniform_location, unit);
47 asc_error_catch_all_gl(); 47 asc_error_catch_all_gl();
48 } 48 }
49 49
50 void asc_texture_from_surface(AscTexture *tex, SDL_Surface const *surface) { 50 void asc_texture_from_surface(AscTexture *tex, const SDL_Surface *surface) {
51 if (tex->tex_id == 0) { 51 if (tex->tex_id == 0) {
52 asc_error("Tried to use uninitialized texture (%"PRIxPTR ").", (uintptr_t) tex); 52 asc_error("Tried to use uninitialized texture (%"PRIxPTR ").", (uintptr_t) tex);
53 return; 53 return;
54 } 54 }
55 tex->width = surface->w; 55 tex->width = surface->w;

mercurial