mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-25 08:12:20 +00:00
[CHG] TTF functions are now using RGBA color instead of RGB
This commit is contained in:
parent
2dbb1380df
commit
8d1b10574e
2 changed files with 14 additions and 12 deletions
|
@ -72,10 +72,12 @@ GRRLIB_ttfFont* GRRLIB_LoadTTF (const u8* file_base, s32 file_size) {
|
||||||
* @param myFont A TTF.
|
* @param myFont A TTF.
|
||||||
*/
|
*/
|
||||||
void GRRLIB_FreeTTF (GRRLIB_ttfFont *myFont) {
|
void GRRLIB_FreeTTF (GRRLIB_ttfFont *myFont) {
|
||||||
|
if(myFont) {
|
||||||
FT_Done_Face(myFont->face);
|
FT_Done_Face(myFont->face);
|
||||||
free(myFont);
|
free(myFont);
|
||||||
myFont = NULL;
|
myFont = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print function for TTF font.
|
* Print function for TTF font.
|
||||||
|
@ -84,7 +86,7 @@ void GRRLIB_FreeTTF (GRRLIB_ttfFont *myFont) {
|
||||||
* @param myFont A TTF.
|
* @param myFont A TTF.
|
||||||
* @param string Text to draw.
|
* @param string Text to draw.
|
||||||
* @param fontSize Size of the font.
|
* @param fontSize Size of the font.
|
||||||
* @param color Text color in RGB format.
|
* @param color Text color in RGBA format.
|
||||||
*/
|
*/
|
||||||
void GRRLIB_PrintfTTF(int x, int y, GRRLIB_ttfFont *myFont, const char *string, unsigned int fontSize, const u32 color) {
|
void GRRLIB_PrintfTTF(int x, int y, GRRLIB_ttfFont *myFont, const char *string, unsigned int fontSize, const u32 color) {
|
||||||
if(myFont == NULL || string == NULL)
|
if(myFont == NULL || string == NULL)
|
||||||
|
@ -110,7 +112,7 @@ void GRRLIB_PrintfTTF(int x, int y, GRRLIB_ttfFont *myFont, const char *string,
|
||||||
* @param myFont A TTF.
|
* @param myFont A TTF.
|
||||||
* @param utf32 Text to draw.
|
* @param utf32 Text to draw.
|
||||||
* @param fontSize Size of the font.
|
* @param fontSize Size of the font.
|
||||||
* @param color Text color in RGB format.
|
* @param color Text color in RGBA format.
|
||||||
*/
|
*/
|
||||||
void GRRLIB_PrintfTTFW(int x, int y, GRRLIB_ttfFont *myFont, const wchar_t *utf32, unsigned int fontSize, const u32 color) {
|
void GRRLIB_PrintfTTFW(int x, int y, GRRLIB_ttfFont *myFont, const wchar_t *utf32, unsigned int fontSize, const u32 color) {
|
||||||
if(myFont == NULL || utf32 == NULL)
|
if(myFont == NULL || utf32 == NULL)
|
||||||
|
@ -159,7 +161,7 @@ void GRRLIB_PrintfTTFW(int x, int y, GRRLIB_ttfFont *myFont, const wchar_t *utf3
|
||||||
* @param bitmap Bitmap to draw.
|
* @param bitmap Bitmap to draw.
|
||||||
* @param offset x-coordinate offset.
|
* @param offset x-coordinate offset.
|
||||||
* @param top y-coordinate.
|
* @param top y-coordinate.
|
||||||
* @param color character color in RGB format.
|
* @param color character color in RGBA format.
|
||||||
*/
|
*/
|
||||||
static void DrawBitmap(FT_Bitmap *bitmap, int offset, int top, const u32 color) {
|
static void DrawBitmap(FT_Bitmap *bitmap, int offset, int top, const u32 color) {
|
||||||
FT_Int i, j, p, q;
|
FT_Int i, j, p, q;
|
||||||
|
@ -169,9 +171,9 @@ static void DrawBitmap(FT_Bitmap *bitmap, int offset, int top, const u32 color)
|
||||||
for ( i = offset, p = 0; i < x_max; i++, p++ ) {
|
for ( i = offset, p = 0; i < x_max; i++, p++ ) {
|
||||||
for ( j = top, q = 0; j < y_max; j++, q++ ) {
|
for ( j = top, q = 0; j < y_max; j++, q++ ) {
|
||||||
GRRLIB_Plot( i, j,
|
GRRLIB_Plot( i, j,
|
||||||
RGBA((color >> 16) & 0xFF,
|
RGBA(R(color),
|
||||||
(color >> 8) & 0xFF,
|
G(color),
|
||||||
color & 0xFF,
|
B(color),
|
||||||
bitmap->buffer[ q * bitmap->width + p ]) );
|
bitmap->buffer[ q * bitmap->width + p ]) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,13 +59,13 @@ int main(int argc, char **argv) {
|
||||||
myFont,
|
myFont,
|
||||||
Letter,
|
Letter,
|
||||||
rand() % 180 + 20,
|
rand() % 180 + 20,
|
||||||
rand() % 0xFFFFFF);
|
((rand() % 0xFFFFFF) << 8) | 0xFF);
|
||||||
GRRLIB_Screen2Texture(0, 0, CopiedImg, false);
|
GRRLIB_Screen2Texture(0, 0, CopiedImg, false);
|
||||||
|
|
||||||
if(ShowFPS) {
|
if(ShowFPS) {
|
||||||
sprintf(FPS, "Current FPS: %d", CalculateFrameRate());
|
sprintf(FPS, "Current FPS: %d", CalculateFrameRate());
|
||||||
GRRLIB_PrintfTTF(500+1, 25+1, myFont, FPS, 12, 0x000000);
|
GRRLIB_PrintfTTF(500+1, 25+1, myFont, FPS, 12, 0x000000FF);
|
||||||
GRRLIB_PrintfTTF(500, 25, myFont, FPS, 12, 0xFFFFFF);
|
GRRLIB_PrintfTTF(500, 25, myFont, FPS, 12, 0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
GRRLIB_Render(); // Render the frame buffer to the TV
|
GRRLIB_Render(); // Render the frame buffer to the TV
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue