diff options
author | drumsetmonkey <abelleisle@roadrunner.com> | 2015-10-22 09:23:35 -0400 |
---|---|---|
committer | drumsetmonkey <abelleisle@roadrunner.com> | 2015-10-22 09:23:35 -0400 |
commit | d15062f7f2563761660e665d0940d9c0d1a7883c (patch) | |
tree | 2478bdb3122263b6b917eef15443ddb9b28e96b4 /src | |
parent | c6739a753e31e8d239b662fbfc7d9ac7e7c0621e (diff) |
Commented more of entities, added new texture namespace and class
Diffstat (limited to 'src')
-rw-r--r-- | src/Texture.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/Texture.cpp b/src/Texture.cpp new file mode 100644 index 0000000..93a3792 --- /dev/null +++ b/src/Texture.cpp @@ -0,0 +1,40 @@ +#include <Texture.h> + +namespace Texture{ + GLuint loadTexture(const char *fileName){ + SDL_Surface *image = IMG_Load(fileName); + + if(!image)return 0; + DEBUG_printf("Loaded image file: %s\n", fileName); + unsigned object = 0; //creates a new unsigned variable for the texture + + glGenTextures(1, &object); //turns "object" into a texture + glBindTexture(GL_TEXTURE_2D, object); //binds "object" to the top of the stack + + 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 + + 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 + + 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; + } +} + +Texturec::Texturec(uint amt, ...){ + image = new GLuint(amt); + va_list fNames; + va_start(fNames, amt); + for(int i = 0; i < amt; i++){ + char* f = va_arg(fNames, char*); + image[i] = Texture::loadTexture(f); + } + va_end(fNames); +} + +void Texturec::bindNext(){ + //glBindTexture(GL_TEXTURE_2D); +}
\ No newline at end of file |