Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5856 in orxonox.OLD


Ignore:
Timestamp:
Dec 1, 2005, 6:32:59 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: TextureToGL is now more modular

Location:
trunk/src/lib
Files:
4 edited

Legend:

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

    r5790 r5856  
    8080        {
    8181          SDL_Surface* tmpSurf;
    82           if (this->texture)
     82          if (this->texture != 0 && glIsTexture(this->texture))
    8383            glDeleteTextures(1, &this->texture);
    8484          // load the new Image to memory
     
    8888            PRINTF(4)("loading Image %s\n", imageName);
    8989            if (this->prepareSurface(tmpSurf))
    90               loadTexToGL();
     90              this->texture = Texture::loadTexToGL(this->image);
     91
    9192            SDL_FreeSurface(tmpSurf);
    9293            return true;
     
    110111bool Texture::rebuild()
    111112{
    112   if (this->texture != 0)
     113  if (this->texture != 0 && glIsTexture(this->texture))
    113114    {
    114115      glDeleteTextures(1,&this->texture);
     
    119120    {
    120121      PRINTF(3)("Reloading Texture of %s '%s'\n", this->getClassName(), this->getName());
    121       this->loadTexToGL();
     122      this->texture = loadTexToGL(this->image);
    122123    }
    123124
     
    199200 * @returns The ID of the texture.
    200201 */
    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)
     202GLuint 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)
    208211    return 0;
    209212
    210213  /* Create an OpenGL texture for the image */
    211   glGenTextures(1, &this->texture);
    212   glBindTexture(GL_TEXTURE_2D, this->texture);
     214  glGenTextures(1, &texture);
     215  glBindTexture(GL_TEXTURE_2D, texture);
    213216  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    214217  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
     
    217220               0,
    218221               GL_RGBA,
    219                this->image->w, this->image->h,
     222               surface->w, surface->h,
    220223               0,
    221224               GL_RGBA,
    222225               GL_UNSIGNED_BYTE,
    223                this->image->pixels);
     226               surface->pixels);
    224227  // build the MipMaps
    225228  gluBuild2DMipmaps(GL_TEXTURE_2D,
    226229                    GL_RGBA,
    227                     this->image->w,
    228                     this->image->h,
     230                    surface->w,
     231                    surface->h,
    229232                    GL_RGBA,
    230233                    GL_UNSIGNED_BYTE,
    231                     this->image->pixels);
     234                    surface->pixels);
    232235  glBindTexture(GL_TEXTURE_2D, 0);
    233   return this->texture;
    234 }
     236  return texture;
     237}
  • trunk/src/lib/graphics/importer/texture.h

    r5768 r5856  
    3434      inline bool hasAlpha() const {return bAlpha;}
    3535
     36      static GLuint loadTexToGL (const SDL_Surface* surface);
     37
     38      const SDL_Surface* const getStoredImage() { return this->image; };
     39
    3640    protected:
    3741      bool prepareSurface(SDL_Surface* input);
    3842      bool setSurface(SDL_Surface* newSurface);
     43      bool setTexture(GLuint texture) { this->texture = texture; };
    3944
    40       GLuint loadTexToGL ();
    4145
    4246    private:
  • trunk/src/lib/graphics/text_engine/font.cc

    r5768 r5856  
    182182  }
    183183  if (this->prepareSurface(surface))
    184     this->loadTexToGL( );
     184  {
     185    this->setTexture(Texture::loadTexToGL(this->getStoredImage()));
     186  }
    185187
    186188  // initializing the Glyphs.
     
    491493
    492494  if (this->setSurface(tmpSurf))
    493     loadTexToGL();
     495    (this->setTexture(Texture::loadTexToGL(tmpSurf)));
    494496}
    495497
  • trunk/src/lib/sound/sound_engine.cc

    r5834 r5856  
    281281
    282282  // INITIALIZING THE DEVICE:
    283   ALchar deviceName[] =
     283  ALubyte deviceName[] =
    284284#ifdef __WIN32__
    285285      "native";
Note: See TracChangeset for help on using the changeset viewer.