aboutsummaryrefslogtreecommitdiffstats
path: root/src/common.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common.cpp')
-rw-r--r--src/common.cpp31
1 files changed, 14 insertions, 17 deletions
diff --git a/src/common.cpp b/src/common.cpp
index 7a51b4e..80488eb 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -4,32 +4,29 @@ GLuint loadTexture(const char *fileName){
SDL_Surface *image = IMG_Load(fileName);
if(!image)return 0;
+ #ifdef DEBUG
+ DEBUG_printf("Loaded image file: %s\n", fileName);
+ #endif // DEBUG
+ unsigned object = 0; //creates a new unsigned variable for the texture
- //SDL_DisplayFormatAlpha(image);
+ glGenTextures(1, &object); //turns "object" into a texture
+ glBindTexture(GL_TEXTURE_2D, object); //binds "object" to the top of the stack
- unsigned object(0);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); //sets the "min" filter
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); //the the "max" filter of the stack
- glGenTextures(1, &object);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); //Wrap the texture to the matrix
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); //Wrap the texutre to the matrix
- 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);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image->w, image->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels); //sets the texture to the image file loaded above
+ SDL_FreeSurface(image); //Free surface
return object;
}
-void DEBUG_printf(const char *s,...){
+void DEBUG_prints(const char* file, int line, const char *s,...){
va_list args;
- printf("%s:%u: ",__FILE__,__LINE__);
+ printf("%s:%d: ",file,line);
va_start(args,s);
vprintf(s,args);
va_end(args);