diff options
Diffstat (limited to 'sources/TZR_DirectResourceLoad.c')
-rw-r--r-- | sources/TZR_DirectResourceLoad.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/sources/TZR_DirectResourceLoad.c b/sources/TZR_DirectResourceLoad.c index 16f0f64..4b010e1 100644 --- a/sources/TZR_DirectResourceLoad.c +++ b/sources/TZR_DirectResourceLoad.c @@ -1,6 +1,7 @@ #include "TZR_resource.h" #include "TZR_globals.h" #include "sdl_error.h" +#include <SDL2/SDL_opengl.h> #include <SDL2/SDL_mixer.h> #include <SDL2/SDL_render.h> #include <SDL2/SDL_rwops.h> @@ -79,12 +80,24 @@ TZR_DirectResourceLoad(TZR_Resource *res, const void *data, int size) SDL_Surface *const surf = SDL_LoadBMP_RW(rw, 1); if (surf == NULL) return sdl_error(-1); -#endif +#endif /* TZR_STB_IMAGE */ SDL_Texture *const tex = SDL_CreateTextureFromSurface(___tzr_renderer, surf); SDL_FreeSurface(surf); if (tex == NULL) return sdl_error(-1); +#ifdef TZR_OPENGL + if (___tzr_config.mipmaps) { + TZR_Log("generating mipmaps"); + SDL_GL_BindTexture(tex, NULL, NULL); + glGenerateMipmap(GL_TEXTURE_2D); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + GL_LINEAR_MIPMAP_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, + -.5f); + SDL_GL_UnbindTexture(tex); + } +#endif /* TZR_OPENGL */ if (SDL_SetTextureBlendMode(tex, SDL_BLENDMODE_BLEND) < 0) { SDL_DestroyTexture(tex); return sdl_error(-1); @@ -113,7 +126,7 @@ TZR_DirectResourceLoad(TZR_Resource *res, const void *data, int size) return -1; } res->sound.ptr = wav; -#else +#else /* TZR_SOLOUD */ SDL_RWops *const rw = SDL_RWFromConstMem(data, size); if (rw == NULL) return sdl_error(-1); |