diff --git a/src/utils.c b/src/utils.c index 3be289b..2f117d8 100644 --- a/src/utils.c +++ b/src/utils.c @@ -31,18 +31,22 @@ void load_img(const char *filename, GLuint texture) { glBindTexture(GL_TEXTURE_2D, texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); SDL_Surface *s = NULL; if (!(s = IMG_Load(filename))) { - fprintf(stderr, "Erreur de chargement de l'image (IMG_Load)\n"); + fprintf(stderr, "Erreur de chargement de l'image (IMG_Load)\n" + "Using red color instead\n"); + GLuint p = 0xFF0000FF; + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, + &p); + } else { + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, s->w, s->h, 0, GL_RGBA, + GL_UNSIGNED_BYTE, s->pixels); + SDL_FreeSurface(s); } - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, s->w, s->h, 0, GL_RGBA, - GL_UNSIGNED_BYTE, s->pixels); - SDL_FreeSurface(s); - glBindTexture(GL_TEXTURE_2D, 0); }