aboutsummaryrefslogtreecommitdiff
path: root/examples/text_ttf_loading.c
diff options
context:
space:
mode:
authorRay <raysan5@gmail.com>2016-11-22 12:15:58 +0100
committerRay <raysan5@gmail.com>2016-11-22 12:15:58 +0100
commitb8481369f7209804d70220a29ba2efbd6171d7a9 (patch)
treef85c9e3f3370f0a25d189f2158f8014d9d6ccaaf /examples/text_ttf_loading.c
parentf1bcfc1352f73b9da98601f6b67cd15853b1cb8f (diff)
downloadraylib-b8481369f7209804d70220a29ba2efbd6171d7a9.tar.gz
raylib-b8481369f7209804d70220a29ba2efbd6171d7a9.zip
Reviewed some lua examples and added new ones
Diffstat (limited to 'examples/text_ttf_loading.c')
-rw-r--r--examples/text_ttf_loading.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/examples/text_ttf_loading.c b/examples/text_ttf_loading.c
index b614023f..918209dd 100644
--- a/examples/text_ttf_loading.c
+++ b/examples/text_ttf_loading.c
@@ -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();
//----------------------------------------------------------------------------------