diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2015-10-08 09:10:08 -0400 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2015-10-08 09:10:08 -0400 |
commit | 3120be4f673c3e106c47ee250ca02179bacec52f (patch) | |
tree | e3f8fdcf70e40fdf3320b3f3bad5d392e4149160 /src/common.cpp | |
parent | 281da1f81b1eef9e05e881e12d986b6b45ce8696 (diff) |
improved inventory, debug flags
Diffstat (limited to 'src/common.cpp')
-rw-r--r-- | src/common.cpp | 54 |
1 files changed, 32 insertions, 22 deletions
diff --git a/src/common.cpp b/src/common.cpp index 1152be7..7a51b4e 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -1,26 +1,36 @@ #include <common.h> GLuint loadTexture(const char *fileName){ - SDL_Surface *image = IMG_Load(fileName); - - //SDL_DisplayFormatAlpha(image); - - unsigned object(0); - - glGenTextures(1, &object); - - glBindTexture(GL_TEXTURE_2D, object); - - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image->w, image->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels); - - //Free surface - SDL_FreeSurface(image); - - return object; + SDL_Surface *image = IMG_Load(fileName); + + if(!image)return 0; + + //SDL_DisplayFormatAlpha(image); + + unsigned object(0); + + glGenTextures(1, &object); + + glBindTexture(GL_TEXTURE_2D, object); + + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image->w, image->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels); + + //Free surface + SDL_FreeSurface(image); + + return object; +} + +void DEBUG_printf(const char *s,...){ + va_list args; + printf("%s:%u: ",__FILE__,__LINE__); + va_start(args,s); + vprintf(s,args); + va_end(args); } |