- Timestamp:
- Dec 16, 2005, 6:06:32 PM (19 years ago)
- Location:
- branches/network/src/lib/graphics/importer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/graphics/importer/texture.cc
r6129 r6136 19 19 20 20 #include "debug.h" 21 #include "compiler.h" 22 #include <math.h> 21 23 22 24 // INCLUDING SDL_Image … … 178 180 * @returns a !!new!! Surface, that is loadable by openGL. 179 181 */ 180 SDL_Surface* Texture::prepareSurface(SDL_Surface* surface, bool& hasAlpha) 182 SDL_Surface* Texture::prepareSurface(SDL_Surface* surface, bool& hasAlpha) const 181 183 { 182 184 PRINTF(4)("Loading texture to OpenGL-Environment.\n"); … … 238 240 * @returns The ID of the texture. 239 241 */ 240 GLuint Texture::loadTexToGL (const SDL_Surface* surface) 242 GLuint Texture::loadTexToGL (const SDL_Surface* surface) const 241 243 { 242 244 // if (this->texture != 0 && glIsTexture(this->texture)) … … 244 246 // this->texture = 0; 245 247 246 GLuint texture; 248 int errorCode = 0; //!< the error code for the texture loading functions 249 GLuint texture; //!< the OpenGL texture handle 250 int mipmapLevel = 0; //!< the maximum mipmap level for this texture 251 int mipmapWidth = 0; //!< the width of the mipmap 252 int mipmapHight = 0; //!< the height of the mipmap 253 247 254 248 255 if (surface == NULL) … … 260 267 glTexParameterf(GL_TEXTURE_ENV, GL_TEXTURE_PRIORITY, this->priority); 261 268 262 / / build the Texture269 /* build the Texture OpenGL V >= 1.1 */ 263 270 glTexImage2D(GL_TEXTURE_2D, 264 271 0, … … 271 278 272 279 // build the MipMaps automaticaly 273 gluBuild2DMipmaps(GL_TEXTURE_2D, 274 GL_RGBA, 275 surface->w, 276 surface->h, 277 GL_RGBA, 278 GL_UNSIGNED_BYTE, 279 surface->pixels); 280 errorCode = gluBuild2DMipmaps(GL_TEXTURE_2D, 281 GL_RGBA, 282 surface->w, 283 surface->h, 284 GL_RGBA, 285 GL_UNSIGNED_BYTE, 286 surface->pixels 287 ); 288 if(unlikely(errorCode != 0)) 289 PRINTF(1)("Error while loading texture, gluBuild2DMipmaps returned %i\n", errorCode); 290 291 #define max(a,b) (a>b)?a:b 292 mipmapLevel = (int)(log2f(max(surface->w, surface->h))); 293 #undef max 294 PRINTF(5)("Built the texture mipmpaps, got: %i levels of detail\n", mipmapLevel); 295 296 /* now actualy load the mipmaps into the graphics memory */ 297 glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 1, GL_TEXTURE_WIDTH, &mipmapWidth); 298 glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 1, GL_TEXTURE_WIDTH, &mipmapHight); 299 PRINTF(5)(" Mipmap at level %i has a %ix%i resolution\n", 1, mipmapWidth, mipmapHeight); 300 glTexImage2D(GL_PROXY_TEXTURE_2D, 301 1, 302 GL_RGBA, 303 mipmapWidth, mipmapHeight, 304 0, 305 GL_RGBA, 306 GL_UNSIGNED_BYTE, 307 NULL 308 ); 309 280 310 glBindTexture(GL_TEXTURE_2D, 0); 281 311 return texture; -
branches/network/src/lib/graphics/importer/texture.h
r6129 r6136 39 39 40 40 // Utility functionality: 41 SDL_Surface* prepareSurface(SDL_Surface* input, bool& hasAlpha) ;42 GLuint loadTexToGL (const SDL_Surface* surface) ;41 SDL_Surface* prepareSurface(SDL_Surface* input, bool& hasAlpha) const; 42 GLuint loadTexToGL (const SDL_Surface* surface) const; 43 43 44 44 protected:
Note: See TracChangeset
for help on using the changeset viewer.