aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2015-10-22 09:23:35 -0400
committerdrumsetmonkey <abelleisle@roadrunner.com>2015-10-22 09:23:35 -0400
commitd15062f7f2563761660e665d0940d9c0d1a7883c (patch)
tree2478bdb3122263b6b917eef15443ddb9b28e96b4 /src
parentc6739a753e31e8d239b662fbfc7d9ac7e7c0621e (diff)
Commented more of entities, added new texture namespace and class
Diffstat (limited to 'src')
-rw-r--r--src/Texture.cpp40
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