Changeset 4662 in orxonox.OLD for orxonox/trunk/src/lib/graphics
- Timestamp:
- Jun 23, 2005, 2:09:07 AM (19 years ago)
- Location:
- orxonox/trunk/src/lib/graphics
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/importer/texture.cc
r4370 r4662 1 /* 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 … … 21 21 #include "graphics_engine.h" 22 22 23 #ifdef HAVE_SDL_IMAGE_H 23 24 #include <SDL_image.h> 25 #else 26 #include <SDL/SDL_image.h> 27 #endif 24 28 25 29 /** … … 32 36 if (imageName) 33 37 this->loadImage(imageName); 34 } 38 } 35 39 36 40 /** 37 41 \brief Destructor of a Texture 38 42 39 43 Frees Data, and deletes the textures from GL 40 44 */ … … 62 66 Uint32 saved_flags; 63 67 Uint8 saved_alpha; 64 68 65 69 w = surface->w; 66 70 h = surface->h; 67 71 68 72 image = SDL_CreateRGBSurface(SDL_SWSURFACE, 69 70 73 w, h, 74 32, 71 75 #if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */ 72 0x000000FF, 73 0x0000FF00, 74 0x00FF0000, 75 76 0x000000FF, 77 0x0000FF00, 78 0x00FF0000, 79 0xFF000000 76 80 #else 77 78 0x00FF0000, 79 0x0000FF00, 80 81 0xFF000000, 82 0x00FF0000, 83 0x0000FF00, 84 0x000000FF 81 85 #endif 82 86 ); 83 87 if ( image == NULL ) { 84 88 return 0; 85 89 } 86 90 87 91 /* Save the alpha blending attributes */ 88 92 saved_flags = surface->flags&(SDL_SRCALPHA|SDL_RLEACCELOK); 89 93 saved_alpha = surface->format->alpha; 90 94 if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) { 91 95 SDL_SetAlpha(surface, 0, 0); 92 96 } 93 97 94 98 /* Copy the surface into the GL texture image */ 95 99 area.x = 0; … … 98 102 area.h = surface->h; 99 103 SDL_BlitSurface(surface, &area, image, &area); 100 104 101 105 /* Restore the alpha blending attributes */ 102 106 if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) { 103 104 107 SDL_SetAlpha(surface, saved_flags | SDL_OPENGL, saved_alpha); 108 this->bAlpha = true; 105 109 } 106 110 107 111 /* Create an OpenGL texture for the image */ 108 112 glGenTextures(1, &texture); … … 112 116 // build the Texture 113 117 glTexImage2D(GL_TEXTURE_2D, 114 115 116 117 118 119 120 118 0, 119 GL_RGBA, 120 w, h, 121 0, 122 GL_RGBA, 123 GL_UNSIGNED_BYTE, 124 image->pixels); 121 125 // build the MipMaps 122 126 gluBuild2DMipmaps(GL_TEXTURE_2D, 123 124 125 126 127 128 129 127 GL_RGBA, 128 w, 129 h, 130 GL_RGBA, 131 GL_UNSIGNED_BYTE, 132 image->pixels); 133 130 134 SDL_FreeSurface(image); /* No longer needed */ 131 135 132 136 return texture; 133 137 } … … 143 147 { 144 148 if (imageName) 145 146 147 148 149 150 151 152 153 154 155 149 { 150 SDL_Surface* tmpSurf; 151 if (this->texture) 152 glDeleteTextures(1, &this->texture); 153 // load the new Image to memory 154 tmpSurf = IMG_Load(imageName); 155 if(!tmpSurf) 156 { 157 PRINTF(1)("IMG_Load: %s\n", IMG_GetError()); 158 return false; 159 } 156 160 157 161 GLubyte* pixels = (GLubyte*)tmpSurf->pixels; 158 162 159 160 161 163 PRINTF(3)("loading Image %s\n", imageName); 164 if (tmpSurf) 165 this->texture = loadTexToGL(tmpSurf); 162 166 163 164 165 166 167 168 SDL_FreeSurface(tmpSurf); 169 return true; 170 } 167 171 else 168 169 170 171 172 { 173 PRINTF(2)("Image not Found: %s\n", imageName); 174 return false; 175 } 172 176 } 173 177 } -
orxonox/trunk/src/lib/graphics/text_engine.h
r4597 r4662 19 19 20 20 #include "glincl.h" 21 22 #ifdef HAVE_SDL_IMAGE_H 21 23 #include "SDL_ttf.h" 24 #else 25 #include "SDL/SDL_ttf.h" 26 #endif 22 27 23 28 #include "vector.h"
Note: See TracChangeset
for help on using the changeset viewer.