Changeset 5856 in orxonox.OLD for trunk/src/lib/graphics/importer
- Timestamp:
- Dec 1, 2005, 6:32:59 PM (19 years ago)
- Location:
- trunk/src/lib/graphics/importer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/importer/texture.cc
r5790 r5856 80 80 { 81 81 SDL_Surface* tmpSurf; 82 if (this->texture )82 if (this->texture != 0 && glIsTexture(this->texture)) 83 83 glDeleteTextures(1, &this->texture); 84 84 // load the new Image to memory … … 88 88 PRINTF(4)("loading Image %s\n", imageName); 89 89 if (this->prepareSurface(tmpSurf)) 90 loadTexToGL(); 90 this->texture = Texture::loadTexToGL(this->image); 91 91 92 SDL_FreeSurface(tmpSurf); 92 93 return true; … … 110 111 bool Texture::rebuild() 111 112 { 112 if (this->texture != 0 )113 if (this->texture != 0 && glIsTexture(this->texture)) 113 114 { 114 115 glDeleteTextures(1,&this->texture); … … 119 120 { 120 121 PRINTF(3)("Reloading Texture of %s '%s'\n", this->getClassName(), this->getName()); 121 this-> loadTexToGL();122 this->texture = loadTexToGL(this->image); 122 123 } 123 124 … … 199 200 * @returns The ID of the texture. 200 201 */ 201 GLuint Texture::loadTexToGL () 202 { 203 if (this->texture != 0 && glIsTexture(this->texture)) 204 glDeleteTextures(1, &this->texture); 205 this->texture = 0; 206 207 if (this->image == NULL) 202 GLuint Texture::loadTexToGL (const SDL_Surface* surface) 203 { 204 // if (this->texture != 0 && glIsTexture(this->texture)) 205 // glDeleteTextures(1, &this->texture); 206 // this->texture = 0; 207 208 GLuint texture; 209 210 if (surface == NULL) 208 211 return 0; 209 212 210 213 /* Create an OpenGL texture for the image */ 211 glGenTextures(1, &t his->texture);212 glBindTexture(GL_TEXTURE_2D, t his->texture);214 glGenTextures(1, &texture); 215 glBindTexture(GL_TEXTURE_2D, texture); 213 216 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 214 217 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); … … 217 220 0, 218 221 GL_RGBA, 219 this->image->w, this->image->h,222 surface->w, surface->h, 220 223 0, 221 224 GL_RGBA, 222 225 GL_UNSIGNED_BYTE, 223 this->image->pixels);226 surface->pixels); 224 227 // build the MipMaps 225 228 gluBuild2DMipmaps(GL_TEXTURE_2D, 226 229 GL_RGBA, 227 this->image->w,228 this->image->h,230 surface->w, 231 surface->h, 229 232 GL_RGBA, 230 233 GL_UNSIGNED_BYTE, 231 this->image->pixels);234 surface->pixels); 232 235 glBindTexture(GL_TEXTURE_2D, 0); 233 return t his->texture;234 } 236 return texture; 237 } -
trunk/src/lib/graphics/importer/texture.h
r5768 r5856 34 34 inline bool hasAlpha() const {return bAlpha;} 35 35 36 static GLuint loadTexToGL (const SDL_Surface* surface); 37 38 const SDL_Surface* const getStoredImage() { return this->image; }; 39 36 40 protected: 37 41 bool prepareSurface(SDL_Surface* input); 38 42 bool setSurface(SDL_Surface* newSurface); 43 bool setTexture(GLuint texture) { this->texture = texture; }; 39 44 40 GLuint loadTexToGL ();41 45 42 46 private:
Note: See TracChangeset
for help on using the changeset viewer.