diff options
| author | Jeffery Myers <[email protected]> | 2021-03-22 23:51:52 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-03-23 07:51:52 +0100 |
| commit | e48b9a6da1d3dd6163b1596e47c58e7026530dc1 (patch) | |
| tree | 9d1bca87d19ae07f7605c112c53971531b109dc2 /examples/text | |
| parent | c6dd41495b2c0d96cf4d1ca108729ec87c9a0b53 (diff) | |
| download | raylib-e48b9a6da1d3dd6163b1596e47c58e7026530dc1.tar.gz raylib-e48b9a6da1d3dd6163b1596e47c58e7026530dc1.zip | |
[Examples] Warning fixes (pt 1) (#1668)
* Fix some warnings in examples.
* cleanups from review
Co-authored-by: Jeffery Myers <[email protected]>
Diffstat (limited to 'examples/text')
| -rw-r--r-- | examples/text/text_font_loading.c | 4 | ||||
| -rw-r--r-- | examples/text/text_font_sdf.c | 2 | ||||
| -rw-r--r-- | examples/text/text_font_spritefont.c | 14 | ||||
| -rw-r--r-- | examples/text/text_raylib_fonts.c | 4 | ||||
| -rw-r--r-- | examples/text/text_rectangle_bounds.c | 12 | ||||
| -rw-r--r-- | examples/text/text_unicode.c | 14 |
6 files changed, 25 insertions, 25 deletions
diff --git a/examples/text/text_font_loading.c b/examples/text/text_font_loading.c index 7eaaed8f..e0515167 100644 --- a/examples/text/text_font_loading.c +++ b/examples/text/text_font_loading.c @@ -66,12 +66,12 @@ int main(void) if (!useTtf) { - DrawTextEx(fontBm, msg, (Vector2){ 20.0f, 100.0f }, fontBm.baseSize, 2, MAROON); + DrawTextEx(fontBm, msg, (Vector2){ 20.0f, 100.0f }, (float)fontBm.baseSize, 2, MAROON); DrawText("Using BMFont (Angelcode) imported", 20, GetScreenHeight() - 30, 20, GRAY); } else { - DrawTextEx(fontTtf, msg, (Vector2){ 20.0f, 100.0f }, fontTtf.baseSize, 2, LIME); + DrawTextEx(fontTtf, msg, (Vector2){ 20.0f, 100.0f }, (float)fontTtf.baseSize, 2, LIME); DrawText("Using TTF font generated", 20, GetScreenHeight() - 30, 20, GRAY); } diff --git a/examples/text/text_font_sdf.c b/examples/text/text_font_sdf.c index b83b3d67..36c0ae56 100644 --- a/examples/text/text_font_sdf.c +++ b/examples/text/text_font_sdf.c @@ -66,7 +66,7 @@ int main(void) Shader shader = LoadShader(0, TextFormat("resources/shaders/glsl%i/sdf.fs", GLSL_VERSION)); SetTextureFilter(fontSDF.texture, FILTER_BILINEAR); // Required for SDF font - Vector2 fontPosition = { 40, screenHeight/2 - 50 }; + Vector2 fontPosition = { 40, screenHeight/2.0f - 50 }; Vector2 textSize = { 0.0f, 0.0f }; float fontSize = 16.0f; int currentFont = 0; // 0 - fontDefault, 1 - fontSDF diff --git a/examples/text/text_font_spritefont.c b/examples/text/text_font_spritefont.c index 4a62c718..0f4a08b2 100644 --- a/examples/text/text_font_spritefont.c +++ b/examples/text/text_font_spritefont.c @@ -38,14 +38,14 @@ int main(void) Font font2 = LoadFont("resources/custom_alagard.png"); // Font loading Font font3 = LoadFont("resources/custom_jupiter_crash.png"); // Font loading - Vector2 fontPosition1 = { screenWidth/2 - MeasureTextEx(font1, msg1, font1.baseSize, -3).x/2, + Vector2 fontPosition1 = { screenWidth/2 - MeasureTextEx(font1, msg1, (float)font1.baseSize, -3).x/2, screenHeight/2 - font1.baseSize/2 - 80 }; - Vector2 fontPosition2 = { screenWidth/2 - MeasureTextEx(font2, msg2, font2.baseSize, -2).x/2, + Vector2 fontPosition2 = { screenWidth/2 - MeasureTextEx(font2, msg2, (float)font2.baseSize, -2).x/2, screenHeight/2 - font2.baseSize/2 - 10 }; - Vector2 fontPosition3 = { screenWidth/2 - MeasureTextEx(font3, msg3, font3.baseSize, 2).x/2, - screenHeight/2 - font3.baseSize/2 + 50 }; + Vector2 fontPosition3 = { screenWidth/2.0f - MeasureTextEx(font3, msg3, (float)font3.baseSize, 2).x/2, + screenHeight/2.0f - font3.baseSize/2 + 50 }; SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- @@ -64,9 +64,9 @@ int main(void) ClearBackground(RAYWHITE); - DrawTextEx(font1, msg1, fontPosition1, font1.baseSize, -3, WHITE); - DrawTextEx(font2, msg2, fontPosition2, font2.baseSize, -2, WHITE); - DrawTextEx(font3, msg3, fontPosition3, font3.baseSize, 2, WHITE); + DrawTextEx(font1, msg1, fontPosition1, (float)font1.baseSize, -3, WHITE); + DrawTextEx(font2, msg2, fontPosition2, (float)font2.baseSize, -2, WHITE); + DrawTextEx(font3, msg3, fontPosition3, (float)font3.baseSize, 2, WHITE); EndDrawing(); //---------------------------------------------------------------------------------- diff --git a/examples/text/text_raylib_fonts.c b/examples/text/text_raylib_fonts.c index d7e41a78..2718d67d 100644 --- a/examples/text/text_raylib_fonts.c +++ b/examples/text/text_raylib_fonts.c @@ -52,7 +52,7 @@ int main(void) for (int i = 0; i < MAX_FONTS; i++) { - positions[i].x = screenWidth/2 - MeasureTextEx(fonts[i], messages[i], fonts[i].baseSize*2, spacings[i]).x/2; + positions[i].x = screenWidth/2 - MeasureTextEx(fonts[i], messages[i], fonts[i].baseSize*2.0f, spacings[i]).x/2.0f); positions[i].y = 60 + fonts[i].baseSize + 45*i; } @@ -85,7 +85,7 @@ int main(void) for (int i = 0; i < MAX_FONTS; i++) { - DrawTextEx(fonts[i], messages[i], positions[i], fonts[i].baseSize*2, spacings[i], colors[i]); + DrawTextEx(fonts[i], messages[i], positions[i], fonts[i].baseSize*2.0f, (float)spacings[i], colors[i]); } EndDrawing(); diff --git a/examples/text/text_rectangle_bounds.c b/examples/text/text_rectangle_bounds.c index 870561e1..21dfcd91 100644 --- a/examples/text/text_rectangle_bounds.c +++ b/examples/text/text_rectangle_bounds.c @@ -33,10 +33,10 @@ tempor incididunt ut labore et dolore magna aliqua. Nec ullamcorper sit amet ris Rectangle resizer = { container.x + container.width - 17, container.y + container.height - 17, 14, 14 }; // Minimum width and heigh for the container rectangle - const int minWidth = 60; - const int minHeight = 60; - const int maxWidth = screenWidth - 50; - const int maxHeight = screenHeight - 160; + const float minWidth = 60; + const float minHeight = 60; + const float maxWidth = screenWidth - 50; + const float maxHeight = screenHeight - 160; Vector2 lastMouse = { 0.0f, 0.0f }; // Stores last mouse coordinates Color borderColor = MAROON; // Container border color @@ -63,10 +63,10 @@ tempor incididunt ut labore et dolore magna aliqua. Nec ullamcorper sit amet ris { if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) resizing = false; - int width = container.width + (mouse.x - lastMouse.x); + float width = container.width + (mouse.x - lastMouse.x); container.width = (width > minWidth)? ((width < maxWidth)? width : maxWidth) : minWidth; - int height = container.height + (mouse.y - lastMouse.y); + float height = container.height + (mouse.y - lastMouse.y); container.height = (height > minHeight)? ((height < maxHeight)? height : maxHeight) : minHeight; } else diff --git a/examples/text/text_unicode.c b/examples/text/text_unicode.c index 161d4677..f481cb2d 100644 --- a/examples/text/text_unicode.c +++ b/examples/text/text_unicode.c @@ -203,15 +203,15 @@ int main(int argc, char **argv) for (int i = 0; i < SIZEOF(emoji); ++i) { const char *txt = &emojiCodepoints[emoji[i].index]; - Rectangle emojiRect = { pos.x, pos.y, fontEmoji.baseSize, fontEmoji.baseSize }; + Rectangle emojiRect = { pos.x, pos.y, (float)fontEmoji.baseSize, (float)fontEmoji.baseSize }; if (!CheckCollisionPointRec(mouse, emojiRect)) { - DrawTextEx(fontEmoji, txt, pos, fontEmoji.baseSize, 1.0, selected == i ? emoji[i].color : Fade(LIGHTGRAY, 0.4f)); + DrawTextEx(fontEmoji, txt, pos, (float)fontEmoji.baseSize, 1.0f, selected == i ? emoji[i].color : Fade(LIGHTGRAY, 0.4f)); } else { - DrawTextEx(fontEmoji, txt, pos, fontEmoji.baseSize, 1.0, emoji[i].color ); + DrawTextEx(fontEmoji, txt, pos, (float)fontEmoji.baseSize, 1.0f, emoji[i].color ); hovered = i; hoveredPos = pos; } @@ -235,7 +235,7 @@ int main(int argc, char **argv) TextIsEqual(messages[message].language, "Japanese")) font = &fontAsian; // Calculate size for the message box (approximate the height and width) - Vector2 sz = MeasureTextEx(*font, messages[message].text, font->baseSize, 1.0f); + Vector2 sz = MeasureTextEx(*font, messages[message].text, (float)font->baseSize, 1.0f); if (sz.x > 300) { sz.y *= sz.x/300; sz.x = 300; } else if (sz.x < 160) sz.x = 160; @@ -267,15 +267,15 @@ int main(int argc, char **argv) // Draw the main text message Rectangle textRect = { msgRect.x + horizontalPadding/2, msgRect.y + verticalPadding/2, msgRect.width - horizontalPadding, msgRect.height }; - DrawTextRec(*font, messages[message].text, textRect, font->baseSize, 1.0f, true, WHITE); + DrawTextRec(*font, messages[message].text, textRect, (float)font->baseSize, 1.0f, true, WHITE); // Draw the info text below the main message - int size = strlen(messages[message].text); + int size = (int)strlen(messages[message].text); int len = GetCodepointsCount(messages[message].text); const char *info = TextFormat("%s %u characters %i bytes", messages[message].language, len, size); sz = MeasureTextEx(GetFontDefault(), info, 10, 1.0f); Vector2 pos = { textRect.x + textRect.width - sz.x, msgRect.y + msgRect.height - sz.y - 2 }; - DrawText(info, pos.x, pos.y, 10, RAYWHITE); + DrawText(info, (int)pos.x, (int)pos.y, 10, RAYWHITE); } //------------------------------------------------------------------------------ |
