summaryrefslogtreecommitdiffhomepage
path: root/examples/text_ttf_loading.c
diff options
context:
space:
mode:
authorvictorfisac <[email protected]>2017-03-06 09:40:04 +0100
committervictorfisac <[email protected]>2017-03-06 09:40:04 +0100
commit9261c3b8dc03d093bff5246a18ad9310ae8eaeb3 (patch)
treeaf87165723ac563ee1a7e1c605c7a4df821d74ea /examples/text_ttf_loading.c
parente8630c78d069a1cba50b1a78108663ebc19e5b9b (diff)
parentb734802743f2089c8d649b27aea48ab71fa653b3 (diff)
downloadraylib-9261c3b8dc03d093bff5246a18ad9310ae8eaeb3.tar.gz
raylib-9261c3b8dc03d093bff5246a18ad9310ae8eaeb3.zip
Merge remote-tracking branch 'refs/remotes/raysan5/develop' into develop
Diffstat (limited to 'examples/text_ttf_loading.c')
-rw-r--r--examples/text_ttf_loading.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/examples/text_ttf_loading.c b/examples/text_ttf_loading.c
index b614023f..10025c2f 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;
+ float fontSize = font.baseSize;
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();
//----------------------------------------------------------------------------------