From a0afc9a192016b2bb4c185895a4082cc965e1179 Mon Sep 17 00:00:00 2001 From: drumsetmonkey Date: Thu, 11 Feb 2016 08:25:57 -0500 Subject: Worlds can be themed --- src/Texture.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/Texture.cpp') diff --git a/src/Texture.cpp b/src/Texture.cpp index e715b1e..1487dcd 100644 --- a/src/Texture.cpp +++ b/src/Texture.cpp @@ -4,6 +4,7 @@ struct texture_t { char *name; GLuint tex; + dim2 dim; } __attribute__ ((packed)); struct index_t{ @@ -59,17 +60,28 @@ namespace Texture{ GL_UNSIGNED_BYTE, image->pixels ); - - SDL_FreeSurface(image); // Free the surface LoadedTexture[LoadedTextureCounter] = new struct texture_t; //(struct texture_t *)malloc(sizeof(struct texture_t)); LoadedTexture[LoadedTextureCounter]->name = new char[strlen(fileName)+1]; //(char *)malloc(safe_strlen(fileName)); LoadedTexture[LoadedTextureCounter]->tex = object; strcpy(LoadedTexture[LoadedTextureCounter]->name,fileName); + LoadedTexture[LoadedTextureCounter]->dim.x = image->w; + LoadedTexture[LoadedTextureCounter]->dim.y = image->h; LoadedTextureCounter++; + SDL_FreeSurface(image); // Free the surface + return object; } + + dim2 imageDim(const char *fileName){ + for(unsigned int i=0;iname,fileName)){ + return LoadedTexture[i]->dim; + } + } + return {0,0}; + } void freeTextures(void){ for(unsigned int i=0;iv){ + texState = 0; + image = new GLuint[v.size()]; + for(unsigned int i = 0; i < v.size(); i++){ + image[i] = Texture::loadTexture(v[i].c_str()); + } +} + Texturec::Texturec(uint amt,const char **paths){ texState = 0; image = new GLuint[amt]; -- cgit v1.2.3