The above seems to track the problem to sparrow3d, sparrowFont.c line 151:
PREFIX void spFontChangeLetter( spFontPointer font, spLetterPointer letter, Uint32 character, Uint16 color )
{
letter->color = color;
Uint16 buffer[2];
buffer[0] = character;
buffer[1] = 0;
SDL_Color sdlcolor = {( color >> 11 ) << 3, ( ( color << 5 ) >> 10 ) << 2, ( ( color & 31 ) << 3 )};
SDL_Surface* surface;
if (spFontBackgroundColor == SP_FONT_NO_BORDER)
surface = TTF_RenderUNICODE_Solid( font->font, buffer, sdlcolor );
else
{
SDL_Color background = {( spFontBackgroundColor >> 11 ) << 3, ( ( spFontBackgroundColor << 5 ) >> 10 ) << 2, ( ( spFontBackgroundColor & 31 ) << 3 )};
surface = TTF_RenderUNICODE_Shaded( font->font, buffer, sdlcolor ,background );
}
if (!surface)
surface = spCreateSurface(0,font->maxheight);
int width = surface->w + SP_FONT_EXTRASPACE * 2;
if ( width & 1 )
width++;
letter->surface = spCreateSurface(width, surface->h + SP_FONT_EXTRASPACE * 2);
SDL_FillRect( letter->surface, NULL, SP_ALPHA_COLOR );
SDL_Rect DestR;
DestR.x = SP_FONT_EXTRASPACE;
DestR.y = SP_FONT_EXTRASPACE;
DestR.w = surface->w;
DestR.h = surface->h;
SDL_BlitSurface( surface, NULL, letter->surface, &DestR );
SDL_FreeSurface( surface );
//Setting every spFontBackgroundColor to the alpha color
SDL_LockSurface( letter->surface );
Uint16* pixel = ( Uint16* )( letter->surface->pixels );
int scanline = letter->surface->pitch/letter->surface->format->BytesPerPixel;
int x, y;
for ( x = 0; x < letter->surface->w; x++ )
for ( y = 0; y < letter->surface->h; y++ )
if ( pixel[x + y * scanline] == spFontBackgroundColor )
pixel[x + y * scanline] = SP_ALPHA_COLOR;
SDL_UnlockSurface( letter->surface );
TTF_SizeUNICODE( font->font, buffer, &( letter->width ), &( letter->height ) );
if ( font->maxheight < letter->height )
font->maxheight = letter->height;
}
Do you need to link sparrowDefines.h in order to obtain the value of SP_ALPHA_COLOR?
Ah, I see it is already linked in sparrowFont.h.
So is letter->surface NULL?