Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6465 in orxonox.OLD for trunk/src/lib/graphics/importer


Ignore:
Timestamp:
Jan 10, 2006, 11:53:19 PM (19 years ago)
Author:
bensch
Message:

trunk: texture prepared for others than GL_TETURE_2D

Location:
trunk/src/lib/graphics/importer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/importer/texture.cc

    r6165 r6465  
    3232 *  Constructor for a Texture
    3333*/
    34 Texture::Texture(const char* imageName)
     34Texture::Texture(const char* imageName, GLenum target)
    3535{
    3636  this->setClassID(CL_TEXTURE, "Texture");
     
    4444  {
    4545    this->setName(imageName);
    46     this->loadImage(imageName);
     46    this->loadImage(imageName, target);
    4747  }
    4848}
     
    6767 * @param imageName The image to load
    6868*/
    69 bool Texture::loadImage(const char* imageName)
     69bool Texture::loadImage(const char* imageName, GLenum target)
    7070{
    7171  if (Texture::texturesEnabled)
     
    9797              this->setSurface(newSurf);
    9898              this->setAlpha(hasAlpha);
    99               this->setTexture(Texture::loadTexToGL(newSurf));
     99              this->setTexture(Texture::loadTexToGL(newSurf, target));
    100100            }
    101101
     
    240240 * @returns The ID of the texture.
    241241 */
    242 GLuint Texture::loadTexToGL (const SDL_Surface* surface) const
     242GLuint Texture::loadTexToGL (const SDL_Surface* surface, GLenum target) const
    243243{
    244244//   if (this->texture != 0 && glIsTexture(this->texture))
     
    258258  /* Create an OpenGL texture for the image */
    259259  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);
    268268
    269269  /* control the mipmap levels */
     
    273273
    274274  /* build the Texture  OpenGL V >= 1.1 */
    275   glTexImage2D(GL_TEXTURE_2D,
     275  glTexImage2D(target,
    276276               0,
    277277               GL_RGBA,
     
    283283
    284284  // build the MipMaps automaticaly
    285   errorCode = gluBuild2DMipmaps(GL_TEXTURE_2D,
     285  errorCode = gluBuild2DMipmaps(target,
    286286                                GL_RGBA,
    287287                                surface->w,
     
    294294    PRINTF(1)("Error while loading texture (mipmap generation), gluBuild2DMipmaps returned %i\n", errorCode);
    295295
    296   glBindTexture(GL_TEXTURE_2D, 0);
     296  glBindTexture(target, 0);
    297297  return texture;
    298298}
  • trunk/src/lib/graphics/importer/texture.h

    r6139 r6465  
    1818  {
    1919    public:
    20       Texture(const char* imageName = NULL);
     20      Texture(const char* imageName = NULL, GLenum target = GL_TEXTURE_2D);
    2121  //  Texture(TEXTURE_TYPE type, int resolution);
    2222      ~Texture();
    2323
    24       bool loadImage(const char* imageName);
     24      bool loadImage(const char* imageName, GLenum target = GL_TEXTURE_2D);
    2525      virtual bool rebuild();
    2626
     
    4040      // Utility functionality:
    4141      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;
    4343
    4444    protected:
Note: See TracChangeset for help on using the changeset viewer.