Diffstat (limited to 'noncore/games/sfcave-sdl/bfont.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/sfcave-sdl/bfont.cpp | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/noncore/games/sfcave-sdl/bfont.cpp b/noncore/games/sfcave-sdl/bfont.cpp index 0f29104..7dec8f5 100644 --- a/noncore/games/sfcave-sdl/bfont.cpp +++ b/noncore/games/sfcave-sdl/bfont.cpp @@ -52,107 +52,102 @@ void BFont::LoadFont (const char *filename) { SDL_Surface *surface(NULL); int x; // tutta roba inutile in C++.... :-) /* BFont_Info *Font=NULL; Font = (BFont_Info *) malloc(sizeof(BFont_Info));*/ if ((filename != NULL ) && (this != NULL)) { surface = IMG_Load( filename ); if (surface != NULL) { Surface = surface; for (x=0; x<256; x++) { Chars[x].x = 0; Chars[x].y = 0; Chars[x].h = 0; Chars[x].w = 0; } InitFont(); // Init the font } } - else - { - cerr << "Error! The font has not been loaded!" << endl; - } } BFont * BFont :: SetFontColor(Uint8 r, Uint8 g, Uint8 b) { int x,y; BFont *newfont; SDL_Surface *surface = NULL; Uint32 pixel; Uint8 old_r, old_g, old_b; Uint8 new_r, new_g, new_b; Uint32 color_key; newfont = new BFont(NULL); if (newfont != NULL) { newfont->h = h; for (x=0; x<256; x++) { newfont->Chars[x].x = Chars[x].x; newfont->Chars[x].y = Chars[x].y; newfont->Chars[x].h = Chars[x].h; newfont->Chars[x].w = Chars[x].w; } surface = SDL_CreateRGBSurface(SDL_SWSURFACE, Surface->w, Surface->h, 32, 0x000000ff,0x0000ff00, 0x00ff0000, 0xff000000); if (surface != NULL) { if (SDL_MUSTLOCK(surface)) SDL_LockSurface(surface); if (SDL_MUSTLOCK(Surface)) SDL_LockSurface(Surface); color_key = xGetPixel(Surface, 0, Surface->h-1); - printf("looking...\n"); for( x=0; x < Surface->w; x++) { for( y=0; y < Surface->h; y++) { old_r = old_g = old_b = 0; pixel = xGetPixel(Surface,x,y); if (pixel != color_key) { SDL_GetRGB(pixel, Surface->format, &old_r,&old_g,&old_b); new_r = (Uint8) ((old_r * r) / 255); new_g = (Uint8) ((old_g * g) / 255); new_b = (Uint8) ((old_b * b) / 255); pixel = SDL_MapRGB(surface->format,new_r,new_g,new_b); } PutPixel(surface,x,y,pixel); } } - printf("unlooking...\n"); + if (SDL_MUSTLOCK(surface)) SDL_UnlockSurface(surface); if (SDL_MUSTLOCK(Surface)) SDL_UnlockSurface(Surface); SDL_SetColorKey(surface, SDL_SRCCOLORKEY, color_key); } newfont->Surface = surface; } return newfont; } /* Puts a single char on the surface with the specified font */ int BFont::PutChar(SDL_Surface *screen, int x, int y, char c) { int r=0; SDL_Rect dest; dest.w = CharWidth(' '); dest.h = FontHeight(); dest.x = x; dest.y = y; if (c != ' ') |