Changeset 5859 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Dec 1, 2005, 8:19:26 PM (19 years ago)
- Location:
- trunk/src/lib/graphics
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/importer/multi_frame_texture.h
r5858 r5859 27 27 28 28 /** @returns The textureID of this texture. */ 29 inline GLuint getFrameTexture(unsigned int frameNumber) ;// const { return this->textures; };29 inline GLuint getFrameTexture(unsigned int frameNumber) const { return this->textures[frameNumber]; }; 30 30 31 const SDL_Surface* const getFrameImage( ) const {};31 const SDL_Surface* const getFrameImage(unsigned int frameNumber) const { return this->images[frameNumber]; }; 32 32 33 33 private: -
trunk/src/lib/graphics/importer/texture.cc
r5858 r5859 86 86 { 87 87 PRINTF(4)("loading Image %s\n", imageName); 88 if (this->prepareSurface(tmpSurf)) 89 this->texture = Texture::loadTexToGL(this->image); 88 bool hasAlpha; 89 SDL_Surface* newSurf = this->prepareSurface(tmpSurf, hasAlpha); 90 if (newSurf != NULL) 91 { 92 this->setSurface(newSurf); 93 this->setAlpha(hasAlpha); 94 this->setTexture(Texture::loadTexToGL(newSurf)); 95 } 90 96 91 97 SDL_FreeSurface(tmpSurf); … … 113 119 { 114 120 glDeleteTextures(1,&this->texture); 115 this-> texture = 0;121 this->setTexture(0); 116 122 } 117 123 … … 119 125 { 120 126 PRINTF(3)("Reloading Texture of %s '%s'\n", this->getClassName(), this->getName()); 121 this-> texture = loadTexToGL(this->image);127 this->setTexture(loadTexToGL(this->image)); 122 128 } 123 129 … … 127 133 * converts surface to a new SDL_Surface, that is loadable by openGL 128 134 * @param surface the Surface to convert 135 * @param hasAlpha if the newly created Surface has an alpha channel, true is returned otherwise false. 129 136 * @returns a !!new!! Surface, that is loadable by openGL. 130 137 */ 131 bool Texture::prepareSurface(SDL_Surface* surface)138 SDL_Surface* Texture::prepareSurface(SDL_Surface* surface, bool& hasAlpha) 132 139 { 133 140 PRINTF(4)("Loading texture to OpenGL-Environment.\n"); 134 141 135 SDL_Surface* putSurface;142 SDL_Surface* retSurface; 136 143 SDL_Rect area; 137 144 Uint32 saved_flags; 138 145 Uint8 saved_alpha; 139 146 140 putSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, 147 hasAlpha = false; 148 retSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, 141 149 surface->w, surface->h, 142 150 32, … … 153 161 #endif 154 162 ); 155 if ( putSurface == NULL )163 if ( retSurface == NULL ) 156 164 { 157 this->setSurface(NULL); 158 return false; 165 return NULL; 159 166 } 160 167 … … 171 178 area.w = surface->w; 172 179 area.h = surface->h; 173 SDL_BlitSurface(surface, &area, putSurface, &area);180 SDL_BlitSurface(surface, &area, retSurface, &area); 174 181 175 182 /* Restore the alpha blending attributes */ … … 177 184 { 178 185 SDL_SetAlpha(surface, saved_flags | SDL_OPENGL, saved_alpha); 179 this->bAlpha = true; 180 } 181 182 return (this->setSurface(putSurface)); 183 } 184 186 hasAlpha = true; 187 } 188 189 return (retSurface); 190 } 191 192 /** 193 * set the surface this Texture handles 194 * @param newSurface the new Surface to set as the image for this Texture. 195 * 196 * This deletes the old version of the stored Texture, 197 * and sets the newly given Surface as current. 198 */ 185 199 bool Texture::setSurface(SDL_Surface* newSurface) 186 200 { -
trunk/src/lib/graphics/importer/texture.h
r5858 r5859 39 39 40 40 // Utility functionality: 41 static SDL_Surface* prepareSurface(SDL_Surface* input, bool& hasAlpha); 41 42 static GLuint loadTexToGL (const SDL_Surface* surface); 42 43 43 44 protected: 44 bool prepareSurface(SDL_Surface* input); 45 45 46 bool setSurface(SDL_Surface* newSurface); 47 bool setAlpha(bool hasAlpha) { this->bAlpha = hasAlpha; }; 46 48 bool setTexture(GLuint texture) { this->texture = texture; }; 47 49 -
trunk/src/lib/graphics/text_engine/font.cc
r5856 r5859 181 181 this->fontTTF = NULL; 182 182 } 183 if (this->prepareSurface(surface)) 184 { 185 this->setTexture(Texture::loadTexToGL(this->getStoredImage())); 183 bool hasAlpha; 184 SDL_Surface* newSurf = this->prepareSurface(surface, hasAlpha); 185 if (newSurf != NULL) 186 { 187 this->setSurface(newSurf); 188 this->setAlpha(hasAlpha); 189 this->setTexture(Texture::loadTexToGL(newSurf)); 186 190 } 187 191
Note: See TracChangeset
for help on using the changeset viewer.