- Timestamp:
- May 19, 2006, 2:25:15 PM (19 years ago)
- Location:
- trunk/src/lib/graphics
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/graphics_engine.cc
r7661 r7727 210 210 211 211 // setting the Video Flags. 212 this->videoFlags = SDL_OPENGL | SDL_HWPALETTE | SDL_RESIZABLE | SDL_DOUBLEBUF | SDL_GL_DOUBLEBUFFER;212 this->videoFlags = SDL_OPENGL | SDL_HWPALETTE | SDL_RESIZABLE ; 213 213 214 214 /* query SDL for information about our video hardware */ … … 281 281 SDL_GL_SetAttribute( SDL_GL_ACCUM_BLUE_SIZE, 0); 282 282 SDL_GL_SetAttribute( SDL_GL_ACCUM_ALPHA_SIZE, 0); 283 284 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); //Use at least 5 bits of Red 285 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); //Use at least 5 bits of Green 286 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); //Use at least 5 bits of Blue 287 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); //Use at least 16 bits for the depth buffer 288 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); //Enable double buffering 283 289 } 284 290 -
trunk/src/lib/graphics/importer/texture.cc
r7676 r7727 30 30 31 31 /** 32 * Constructor for a Texture32 * @brief Constructor for a Texture 33 33 */ 34 34 Texture::Texture(const std::string& imageName, GLenum target) … … 50 50 51 51 /** 52 * Destructor of a Texture53 54 55 */52 * @brief Destructor of a Texture 53 * 54 * Frees Data, and deletes the textures from GL 55 */ 56 56 Texture::~Texture() 57 57 { … … 64 64 65 65 /** 66 * loads an Image from a file to a Texture66 * @brief loads an Image from a file to a Texture 67 67 * @param imageName The image to load 68 68 */ … … 121 121 122 122 /** 123 * rebuilds the texture. 123 * @brief rebuilds the texture. 124 * 124 125 * reloads the Texture from Memory to OpenGL. 125 126 */ … … 142 143 143 144 /** 144 * set the surface this Texture handles145 * @brief set the surface this Texture handles 145 146 * @param newSurface the new Surface to set as the image for this Texture. 146 147 * … … 162 163 163 164 /** 164 * enables, disables textures165 * @brief enables, disables textures 165 166 * @param texturesEnabled true if the textures should be enabled 166 167 */ … … 175 176 ////////////////////////////////////// 176 177 /** 177 * converts surface to a new SDL_Surface, that is loadable by openGL178 * @brief converts surface to a new SDL_Surface, that is loadable by openGL 178 179 * @param surface the Surface to convert 179 180 * @param hasAlpha if the newly created Surface has an alpha channel, true is returned otherwise false. … … 182 183 SDL_Surface* Texture::prepareSurface(SDL_Surface* surface, bool& hasAlpha) const 183 184 { 185 assert(surface != NULL); 184 186 PRINTF(4)("Loading texture to OpenGL-Environment.\n"); 185 187 … … 190 192 191 193 hasAlpha = false; 192 retSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, 194 int pixelDepth = 24; 195 196 /* Save the alpha blending attributes */ 197 saved_flags = surface->flags&(SDL_SRCALPHA | SDL_RLEACCELOK); 198 saved_alpha = surface->format->alpha; 199 if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) 200 { 201 SDL_SetAlpha(surface, 0, 0); 202 hasAlpha = true; 203 pixelDepth = 32; 204 } 205 206 retSurface = SDL_CreateRGBSurface(SDL_HWSURFACE, 193 207 surface->w, surface->h, 194 32,208 pixelDepth, 195 209 #if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */ 196 210 0x000000FF, … … 206 220 ); 207 221 if ( retSurface == NULL ) 208 {209 222 return NULL; 210 }211 212 /* Save the alpha blending attributes */213 saved_flags = surface->flags&(SDL_SRCALPHA|SDL_RLEACCELOK);214 saved_alpha = surface->format->alpha;215 if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA )216 {217 SDL_SetAlpha(surface, 0, 0);218 }219 223 220 224 /* Copy the surface into the GL texture image */ … … 237 241 238 242 /** 239 * Loads a Texture to the openGL-environment.243 * @brief Loads a Texture to the openGL-environment. 240 244 * @param surface the Image to load to openGL 241 245 * @returns The ID of the texture. … … 246 250 // glDeleteTextures(1, &this->texture); 247 251 // this->texture = 0; 252 assert(surface != NULL); 248 253 249 254 int errorCode = 0; //!< the error code for the texture loading functions … … 252 257 int mipmapWidth = 0; //!< the width of the mipmap 253 258 int mipmapHight = 0; //!< the height of the mipmap 254 255 256 if (surface == NULL) 257 return 0; 259 GLenum format = GL_RGB; 260 if (this->bAlpha) 261 { 262 format = GL_RGBA; 263 assert(surface->format->BitsPerPixel == 32); 264 } 265 else 266 { 267 assert(surface->format->BitsPerPixel == 24); 268 } 258 269 259 270 /* Create an OpenGL texture for the image */ … … 261 272 glBindTexture(target, texture); 262 273 274 // glTexImage2D(target, 0, format, 275 // surface->w, surface->h, 276 // 0, format, GL_UNSIGNED_BYTE, 277 // surface->pixels); 278 263 279 glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_REPEAT); 264 280 glTexParameteri(target, GL_TEXTURE_WRAP_R, GL_REPEAT); … … 275 291 276 292 /* build the Texture OpenGL V >= 1.1 */ 277 glTexImage2D(target, 278 0, 279 GL_RGBA, 280 surface->w, 281 surface->h, 282 0, 283 GL_RGBA, 284 GL_UNSIGNED_BYTE, 285 surface->pixels); 293 286 294 // printf("%s, w:%d h:%d, 0x%x\n", this->getName(), surface->w, surface->h, target); 287 295 288 296 // build the MipMaps automaticaly 289 errorCode = gluBuild2DMipmaps(target, 290 GL_RGBA, 291 surface->w, 292 surface->h, 293 GL_RGBA, 294 GL_UNSIGNED_BYTE, 297 errorCode = gluBuild2DMipmaps(target, format, 298 surface->w, surface->h, 299 format, GL_UNSIGNED_BYTE, 295 300 surface->pixels 296 301 ); -
trunk/src/lib/graphics/importer/texture.h
r7221 r7727 43 43 44 44 protected: 45 46 45 bool setSurface(SDL_Surface* newSurface); 47 46 bool setAlpha(bool hasAlpha) { this->bAlpha = hasAlpha; }; 48 47 bool setTexture(GLuint texture) { this->texture = texture; }; 49 50 48 51 49 private: -
trunk/src/lib/graphics/render2D/element_2d.cc
r7342 r7727 123 123 if (this->toDirection != NULL) 124 124 delete this->toDirection; 125 if (this->toSize != NULL) 126 delete this->toSize; 125 127 126 128 if (this == Element2D::nullElement) -
trunk/src/lib/graphics/text_engine/font.cc
r7450 r7727 427 427 // Surface definition. 428 428 SDL_Rect tmpRect; // this represents a Rectangle for blitting. 429 SDL_Surface* tmpSurf = SDL_CreateRGBSurface(SDL_ SWSURFACE,429 SDL_Surface* tmpSurf = SDL_CreateRGBSurface(SDL_HWSURFACE, 430 430 rectSize, rectSize, 431 431 32, … … 494 494 // sprintf( outName, "%s-glyphs.bmp", this->getName()); 495 495 // SDL_SaveBMP(tmpSurf, outName); 496 496 this->setAlpha(true); 497 497 if (this->setSurface(tmpSurf)) 498 498 (this->setTexture(Texture::loadTexToGL(tmpSurf))); … … 500 500 501 501 /** 502 * stores Glyph Metrics in an Array.502 * @brief stores Glyph Metrics in an Array. 503 503 * @param from The Glyph to start from. 504 504 * @param count The number of Glyphs to start From. … … 535 535 /** 536 536 * @returns the optimal size to use as the texture size 537 538 539 540 541 542 537 * 538 * @todo: this algorithm can be a lot faster, althought it does 539 * not really matter within the init-context, and 128 glyphs. 540 * 541 * This function searches for a 2^n sizes texture-size, this is for 542 * openGL-version < 1.2 compatibility ( and because it is realy easy like this :)) 543 543 */ 544 544 int Font::findOptimalFastTextureSize()
Note: See TracChangeset
for help on using the changeset viewer.