Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6859 in orxonox.OLD


Ignore:
Timestamp:
Jan 30, 2006, 5:24:12 AM (18 years ago)
Author:
bensch
Message:

trunk: error-correction

Location:
trunk/src
Files:
3 edited

Legend:

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

    r6634 r6859  
    7070{
    7171  if (Texture::texturesEnabled)
     72  {
     73    if (this->image != NULL)
    7274    {
    73       if (this->image != NULL)
     75      SDL_FreeSurface(this->image);
     76      this->image = NULL;
     77    }
     78    if (this->texture != 0)
     79    {
     80      glDeleteTextures(1, &this->texture);
     81      this->texture = 0;
     82    }
     83    if (imageName != NULL)
     84    {
     85      SDL_Surface* tmpSurf;
     86      if (this->texture != 0 && glIsTexture(this->texture))
     87        glDeleteTextures(1, &this->texture);
     88      // load the new Image to memory
     89      tmpSurf = IMG_Load(imageName);
     90      if(tmpSurf != NULL)
     91      {
     92        PRINTF(4)("loading Image %s\n", imageName);
     93        bool hasAlpha;
     94        SDL_Surface* newSurf = this->prepareSurface(tmpSurf, hasAlpha);
     95        if (newSurf != NULL)
    7496        {
    75           SDL_FreeSurface(this->image);
    76           this->image = NULL;
     97          this->setSurface(newSurf);
     98          this->setAlpha(hasAlpha);
     99          this->setTexture(Texture::loadTexToGL(newSurf, target));
    77100        }
    78       if (this->texture != 0)
    79         {
    80           glDeleteTextures(1, &this->texture);
    81           this->texture = 0;
    82         }
    83       if (imageName != NULL)
    84         {
    85           SDL_Surface* tmpSurf;
    86           if (this->texture != 0 && glIsTexture(this->texture))
    87             glDeleteTextures(1, &this->texture);
    88           // load the new Image to memory
    89           tmpSurf = IMG_Load(imageName);
    90           if(tmpSurf != NULL)
    91           {
    92             PRINTF(4)("loading Image %s\n", imageName);
    93             bool hasAlpha;
    94             SDL_Surface* newSurf = this->prepareSurface(tmpSurf, hasAlpha);
    95             if (newSurf != NULL)
    96             {
    97               this->setSurface(newSurf);
    98               this->setAlpha(hasAlpha);
    99               this->setTexture(Texture::loadTexToGL(newSurf, target));
    100             }
    101 
    102             SDL_FreeSurface(tmpSurf);
    103             return true;
    104           }
    105           else
    106             {
    107               PRINTF(1)("IMG_Load: %s\n", IMG_GetError());
    108               this->texture = 0;
    109               return false;
    110             }
    111         }
     101
     102        SDL_FreeSurface(tmpSurf);
     103        return true;
     104      }
    112105      else
    113         {
    114           PRINTF(2)("Image-Name not specified\n");
    115           return false;
    116         }
     106      {
     107        PRINTF(1)("IMG_Load: %s\n", IMG_GetError());
     108        this->texture = 0;
     109        return false;
     110      }
    117111    }
     112    else
     113    {
     114      PRINTF(2)("Image-Name not specified\n");
     115      return false;
     116    }
     117  }
    118118  return false;
    119119}
     
    127127{
    128128  if (this->texture != 0)
    129     {
    130       if (glIsTexture(this->texture))
    131         glDeleteTextures(1,&this->texture);
    132       this->setTexture(0);
    133     }
     129  {
     130    if (glIsTexture(this->texture))
     131      glDeleteTextures(1,&this->texture);
     132    this->setTexture(0);
     133  }
    134134
    135135  if (this->image != NULL)
    136     {
    137       PRINTF(3)("Reloading Texture of %s '%s'\n", this->getClassName(), this->getName());
    138       this->setTexture(loadTexToGL(this->image));
    139     }
     136  {
     137    PRINTF(3)("Reloading Texture of %s '%s'\n", this->getClassName(), this->getName());
     138    this->setTexture(loadTexToGL(this->image));
     139  }
    140140}
    141141
     
    194194                                    32,
    195195#if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */
    196                                0x000000FF,
    197                                0x0000FF00,
    198                                0x00FF0000,
    199                                0xFF000000
     196                                    0x000000FF,
     197                                    0x0000FF00,
     198                                    0x00FF0000,
     199                                    0xFF000000
    200200#else
    201                                0xFF000000,
    202                                0x00FF0000,
    203                                0x0000FF00,
    204                                0x000000FF
     201                                    0xFF000000,
     202                                    0x00FF0000,
     203                                    0x0000FF00,
     204                                    0x000000FF
    205205#endif
    206206                                   );
     
    213213  saved_flags = surface->flags&(SDL_SRCALPHA|SDL_RLEACCELOK);
    214214  saved_alpha = surface->format->alpha;
    215   if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
     215  if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA )
     216  {
    216217    SDL_SetAlpha(surface, 0, 0);
    217218  }
     
    242243GLuint Texture::loadTexToGL (const SDL_Surface* surface, GLenum target) const
    243244{
    244 //   if (this->texture != 0 && glIsTexture(this->texture))
    245 //     glDeleteTextures(1, &this->texture);
    246 //   this->texture = 0;
     245  //   if (this->texture != 0 && glIsTexture(this->texture))
     246  //     glDeleteTextures(1, &this->texture);
     247  //   this->texture = 0;
    247248
    248249  int      errorCode = 0;           //!< the error code for the texture loading functions
     
    283284               GL_UNSIGNED_BYTE,
    284285               surface->pixels);
     286  printf("%s, w:%d h:%d, 0x%x\n", this->getName(), surface->w, surface->h, target);
    285287
    286288  // build the MipMaps automaticaly
     
    296298    PRINTF(1)("Error while loading texture (mipmap generation), gluBuild2DMipmaps returned %i\n", errorCode);
    297299
    298   // Deselect newly built texture, as we do not want to display with this texture.
    299   if (target == GL_TEXTURE_2D)
    300     glBindTexture(target, 0);
    301 
    302300  return texture;
    303301}
  • trunk/src/lib/util/multi_type.cc

    r6645 r6859  
    9090{
    9191  this->init();
    92   printf("test2");
    9392  *this = multiType;
    9493}
  • trunk/src/util/loading/resource_manager.cc

    r6664 r6859  
    488488      {
    489489        PRINTF(4)("Image %s resides to %s\n", fileName, fullName);
    490         tmpResource->pointer = new Texture(fullName);
     490        tmpResource->pointer = new Texture(fullName, tmpResource->param[0].getInt());
    491491      }
    492492      else
     
    742742          else if ((*resource)->param[0] == ((MultiType)param0).getString())
    743743            match = true;
     744          break;
    744745#endif /* NO_SHADERS */
    745746#ifndef NO_TEXTURES
     
    752753          else if ((*resource)->param[0] ==  param0.getInt())
    753754            match = true;
     755          break;
    754756#endif /* NO_TEXTURES */
    755757        default:
Note: See TracChangeset for help on using the changeset viewer.