summaryrefslogtreecommitdiff
path: root/noncore/games/sfcave-sdl/bfont.cpp
Unidiff
Diffstat (limited to 'noncore/games/sfcave-sdl/bfont.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/games/sfcave-sdl/bfont.cpp7
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
@@ -64,28 +64,24 @@ void BFont::LoadFont (const char *filename)
64 { 64 {
65 Surface = surface; 65 Surface = surface;
66 for (x=0; x<256; x++) 66 for (x=0; x<256; x++)
67 { 67 {
68 Chars[x].x = 0; 68 Chars[x].x = 0;
69 Chars[x].y = 0; 69 Chars[x].y = 0;
70 Chars[x].h = 0; 70 Chars[x].h = 0;
71 Chars[x].w = 0; 71 Chars[x].w = 0;
72 } 72 }
73 InitFont(); // Init the font 73 InitFont(); // Init the font
74 } 74 }
75 } 75 }
76 else
77 {
78 cerr << "Error! The font has not been loaded!" << endl;
79 }
80} 76}
81 77
82BFont * BFont :: SetFontColor(Uint8 r, Uint8 g, Uint8 b) 78BFont * BFont :: SetFontColor(Uint8 r, Uint8 g, Uint8 b)
83{ 79{
84 int x,y; 80 int x,y;
85 81
86 BFont *newfont; 82 BFont *newfont;
87 SDL_Surface *surface = NULL; 83 SDL_Surface *surface = NULL;
88 84
89 Uint32 pixel; 85 Uint32 pixel;
90 Uint8 old_r, old_g, old_b; 86 Uint8 old_r, old_g, old_b;
91 Uint8 new_r, new_g, new_b; 87 Uint8 new_r, new_g, new_b;
@@ -104,43 +100,42 @@ BFont * BFont :: SetFontColor(Uint8 r, Uint8 g, Uint8 b)
104 newfont->Chars[x].w = Chars[x].w; 100 newfont->Chars[x].w = Chars[x].w;
105 } 101 }
106 102
107 surface = SDL_CreateRGBSurface(SDL_SWSURFACE, Surface->w, Surface->h, 32, 103 surface = SDL_CreateRGBSurface(SDL_SWSURFACE, Surface->w, Surface->h, 32,
108 0x000000ff,0x0000ff00, 0x00ff0000, 0xff000000); 104 0x000000ff,0x0000ff00, 0x00ff0000, 0xff000000);
109 if (surface != NULL) { 105 if (surface != NULL) {
110 106
111 if (SDL_MUSTLOCK(surface)) SDL_LockSurface(surface); 107 if (SDL_MUSTLOCK(surface)) SDL_LockSurface(surface);
112 if (SDL_MUSTLOCK(Surface)) SDL_LockSurface(Surface); 108 if (SDL_MUSTLOCK(Surface)) SDL_LockSurface(Surface);
113 109
114 color_key = xGetPixel(Surface, 0, Surface->h-1); 110 color_key = xGetPixel(Surface, 0, Surface->h-1);
115 111
116 printf("looking...\n");
117 for( x=0; x < Surface->w; x++) { 112 for( x=0; x < Surface->w; x++) {
118 for( y=0; y < Surface->h; y++) { 113 for( y=0; y < Surface->h; y++) {
119 old_r = old_g = old_b = 0; 114 old_r = old_g = old_b = 0;
120 pixel = xGetPixel(Surface,x,y); 115 pixel = xGetPixel(Surface,x,y);
121 116
122 if (pixel != color_key) { 117 if (pixel != color_key) {
123 SDL_GetRGB(pixel, Surface->format, &old_r,&old_g,&old_b); 118 SDL_GetRGB(pixel, Surface->format, &old_r,&old_g,&old_b);
124 119
125 new_r = (Uint8) ((old_r * r) / 255); 120 new_r = (Uint8) ((old_r * r) / 255);
126 new_g = (Uint8) ((old_g * g) / 255); 121 new_g = (Uint8) ((old_g * g) / 255);
127 new_b = (Uint8) ((old_b * b) / 255); 122 new_b = (Uint8) ((old_b * b) / 255);
128 123
129 pixel = SDL_MapRGB(surface->format,new_r,new_g,new_b); 124 pixel = SDL_MapRGB(surface->format,new_r,new_g,new_b);
130 } 125 }
131 PutPixel(surface,x,y,pixel); 126 PutPixel(surface,x,y,pixel);
132 } 127 }
133 } 128 }
134 printf("unlooking...\n"); 129
135 if (SDL_MUSTLOCK(surface)) SDL_UnlockSurface(surface); 130 if (SDL_MUSTLOCK(surface)) SDL_UnlockSurface(surface);
136 if (SDL_MUSTLOCK(Surface)) SDL_UnlockSurface(Surface); 131 if (SDL_MUSTLOCK(Surface)) SDL_UnlockSurface(Surface);
137 132
138 SDL_SetColorKey(surface, SDL_SRCCOLORKEY, color_key); 133 SDL_SetColorKey(surface, SDL_SRCCOLORKEY, color_key);
139 } 134 }
140 135
141 newfont->Surface = surface; 136 newfont->Surface = surface;
142 } 137 }
143 return newfont; 138 return newfont;
144} 139}
145 140
146 141