diff --git a/includes/font.h b/includes/font.h index 0feba85..0fe2417 100644 --- a/includes/font.h +++ b/includes/font.h @@ -20,7 +20,7 @@ int initFont(TTF_Font **, char *, int); * Renvoie 2 en cas de problème de surface avec la SDL * * Renvoie 0 en cas de succès */ -int writeText(GLuint *, TTF_Font *, const char *, SDL_Color, GLboolean); +int writeText(GLuint *, TTF_Font *, const char *, SDL_Color, GLuint *); // Libère une police de la mémoire void freeFont(TTF_Font *); diff --git a/src/credits.c b/src/credits.c index a5f579f..c8e5e8b 100644 --- a/src/credits.c +++ b/src/credits.c @@ -54,7 +54,7 @@ static void init(void) { "- Audio : beepbox\n" "- Talent : aucun\n" "- Librairies : GL4D, SDL2 et extensions", - (SDL_Color){255, 255, 255, 255}, GL_FALSE)) { + (SDL_Color){255, 255, 255, 255}, NULL)) { exit(errStatus); } diff --git a/src/font.c b/src/font.c index 2994ae7..9515d2a 100644 --- a/src/font.c +++ b/src/font.c @@ -15,7 +15,7 @@ int initFont(TTF_Font **font, char *filename, int size) { } int writeText(GLuint *_textTexId, TTF_Font *font, const char *text, - SDL_Color color, GLboolean keep_previous) { + SDL_Color color, GLuint *backgroundTextureId) { SDL_Surface *d, *s; // Create text if (!(d = TTF_RenderUTF8_Blended_Wrapped(font, text, color, 0))) { @@ -32,10 +32,10 @@ int writeText(GLuint *_textTexId, TTF_Font *font, const char *text, return 2; } - if (keep_previous) { + if (backgroundTextureId) { // On garde la texture déjà présente - assert(_textTexId); - glBindTexture(GL_TEXTURE_2D, *_textTexId); + assert(*backgroundTextureId); + glBindTexture(GL_TEXTURE_2D, *backgroundTextureId); GLint w, h; glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w); @@ -57,16 +57,17 @@ int writeText(GLuint *_textTexId, TTF_Font *font, const char *text, SDL_BlitScaled(old, NULL, s, NULL); SDL_FreeSurface(old); + } else { // Aucune texture existante, donc on la créée glGenTextures(1, _textTexId); assert(_textTexId); - glBindTexture(GL_TEXTURE_2D, *_textTexId); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); } + glBindTexture(GL_TEXTURE_2D, *_textTexId); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + // Copie le texte sur la surface finale SDL_BlitSurface(d, NULL, s, NULL); SDL_FreeSurface(d); diff --git a/src/tag.c b/src/tag.c index de5c686..784150d 100644 --- a/src/tag.c +++ b/src/tag.c @@ -44,7 +44,7 @@ static void init(void) { exit(3); } if (writeText(&_texId[1], font, "macron = loser", (SDL_Color){0, 0, 0, 255}, - GL_TRUE)) { + &_texId[0])) { exit(3); } freeFont(font);