Reviewed some lua examples and added new ones
This commit is contained in:
parent
f1bcfc1352
commit
b8481369f7
19 changed files with 401 additions and 139 deletions
|
@ -20,17 +20,22 @@ int main()
|
|||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [text] example - ttf loading");
|
||||
|
||||
const char msg1[50] = "TTF SpriteFont";
|
||||
const char msg[50] = "TTF SpriteFont";
|
||||
|
||||
// NOTE: Textures/Fonts MUST be loaded after Window initialization (OpenGL context is required)
|
||||
|
||||
// TTF SpriteFont loading with custom generation parameters
|
||||
SpriteFont font = LoadSpriteFontTTF("resources/fonts/KAISG.ttf", 96, 0, 0);
|
||||
|
||||
// Generate mipmap levels to use trilinear filtering
|
||||
// NOTE: On 2D drawing it won't be noticeable, it looks like FILTER_BILINEAR
|
||||
GenTextureMipmaps(&font.texture);
|
||||
|
||||
float fontSize = font.size;
|
||||
Vector2 fontPosition = { 40, screenHeight/2 + 50 };
|
||||
Vector2 textSize;
|
||||
|
||||
SetTextureFilter(font.texture, FILTER_POINT);
|
||||
int currentFontFilter = 0; // FILTER_POINT
|
||||
|
||||
int count = 0;
|
||||
|
@ -59,12 +64,12 @@ int main()
|
|||
}
|
||||
else if (IsKeyPressed(KEY_THREE))
|
||||
{
|
||||
// NOTE: Trilinear filter not supported in font because there are not mipmap levels
|
||||
// NOTE: Trilinear filter won't be noticed on 2D drawing
|
||||
SetTextureFilter(font.texture, FILTER_TRILINEAR);
|
||||
//currentFontFilter = 2;
|
||||
currentFontFilter = 2;
|
||||
}
|
||||
|
||||
textSize = MeasureTextEx(font, msg1, fontSize, 0);
|
||||
textSize = MeasureTextEx(font, msg, fontSize, 0);
|
||||
|
||||
if (IsKeyDown(KEY_LEFT)) fontPosition.x -= 10;
|
||||
else if (IsKeyDown(KEY_RIGHT)) fontPosition.x += 10;
|
||||
|
@ -94,7 +99,7 @@ int main()
|
|||
DrawText("Use 1, 2, 3 to change texture filter", 20, 60, 10, GRAY);
|
||||
DrawText("Drop a new TTF font for dynamic loading", 20, 80, 10, DARKGRAY);
|
||||
|
||||
DrawTextEx(font, msg1, fontPosition, fontSize, 0, BLACK);
|
||||
DrawTextEx(font, msg, fontPosition, fontSize, 0, BLACK);
|
||||
|
||||
// TODO: It seems texSize measurement is not accurate due to chars offsets...
|
||||
//DrawRectangleLines(fontPosition.x, fontPosition.y, textSize.x, textSize.y, RED);
|
||||
|
@ -106,6 +111,7 @@ int main()
|
|||
|
||||
if (currentFontFilter == 0) DrawText("POINT", 570, 400, 20, BLACK);
|
||||
else if (currentFontFilter == 1) DrawText("BILINEAR", 570, 400, 20, BLACK);
|
||||
else if (currentFontFilter == 2) DrawText("TRILINEAR", 570, 400, 20, BLACK);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue