Changeset 6465 in orxonox.OLD for trunk/src/lib/graphics/importer
- Timestamp:
- Jan 10, 2006, 11:53:19 PM (19 years ago)
- Location:
- trunk/src/lib/graphics/importer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/importer/texture.cc
r6165 r6465 32 32 * Constructor for a Texture 33 33 */ 34 Texture::Texture(const char* imageName )34 Texture::Texture(const char* imageName, GLenum target) 35 35 { 36 36 this->setClassID(CL_TEXTURE, "Texture"); … … 44 44 { 45 45 this->setName(imageName); 46 this->loadImage(imageName );46 this->loadImage(imageName, target); 47 47 } 48 48 } … … 67 67 * @param imageName The image to load 68 68 */ 69 bool Texture::loadImage(const char* imageName )69 bool Texture::loadImage(const char* imageName, GLenum target) 70 70 { 71 71 if (Texture::texturesEnabled) … … 97 97 this->setSurface(newSurf); 98 98 this->setAlpha(hasAlpha); 99 this->setTexture(Texture::loadTexToGL(newSurf ));99 this->setTexture(Texture::loadTexToGL(newSurf, target)); 100 100 } 101 101 … … 240 240 * @returns The ID of the texture. 241 241 */ 242 GLuint Texture::loadTexToGL (const SDL_Surface* surface ) const242 GLuint Texture::loadTexToGL (const SDL_Surface* surface, GLenum target) const 243 243 { 244 244 // if (this->texture != 0 && glIsTexture(this->texture)) … … 258 258 /* Create an OpenGL texture for the image */ 259 259 glGenTextures(1, &texture); 260 glBindTexture( GL_TEXTURE_2D, texture);261 262 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);263 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);264 265 266 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);267 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);260 glBindTexture(target, texture); 261 262 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); 263 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 264 265 266 glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_REPEAT); 267 glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_REPEAT); 268 268 269 269 /* control the mipmap levels */ … … 273 273 274 274 /* build the Texture OpenGL V >= 1.1 */ 275 glTexImage2D( GL_TEXTURE_2D,275 glTexImage2D(target, 276 276 0, 277 277 GL_RGBA, … … 283 283 284 284 // build the MipMaps automaticaly 285 errorCode = gluBuild2DMipmaps( GL_TEXTURE_2D,285 errorCode = gluBuild2DMipmaps(target, 286 286 GL_RGBA, 287 287 surface->w, … … 294 294 PRINTF(1)("Error while loading texture (mipmap generation), gluBuild2DMipmaps returned %i\n", errorCode); 295 295 296 glBindTexture( GL_TEXTURE_2D, 0);296 glBindTexture(target, 0); 297 297 return texture; 298 298 } -
trunk/src/lib/graphics/importer/texture.h
r6139 r6465 18 18 { 19 19 public: 20 Texture(const char* imageName = NULL );20 Texture(const char* imageName = NULL, GLenum target = GL_TEXTURE_2D); 21 21 // Texture(TEXTURE_TYPE type, int resolution); 22 22 ~Texture(); 23 23 24 bool loadImage(const char* imageName );24 bool loadImage(const char* imageName, GLenum target = GL_TEXTURE_2D); 25 25 virtual bool rebuild(); 26 26 … … 40 40 // Utility functionality: 41 41 SDL_Surface* prepareSurface(SDL_Surface* input, bool& hasAlpha) const; 42 GLuint loadTexToGL (const SDL_Surface* surface ) const;42 GLuint loadTexToGL (const SDL_Surface* surface, GLenum target = GL_TEXTURE_2D) const; 43 43 44 44 protected:
Note: See TracChangeset
for help on using the changeset viewer.