Browse Source

Fix warnings in more examples. (#5292)

pull/5274/merge
Jeffery Myers 1 day ago
committed by GitHub
parent
commit
780a7df760
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 8 deletions
  1. +8
    -8
      examples/core/core_text_file_loading.c
  2. +3
    -0
      examples/shapes/shapes_clock_of_clocks.c

+ 8
- 8
examples/core/core_text_file_loading.c View File

@ -88,16 +88,16 @@ int main(void)
for (int i = 0; i < lineCount; i++) for (int i = 0; i < lineCount; i++)
{ {
Vector2 size = MeasureTextEx(GetFontDefault(), lines[i], fontSize, 2);
textHeight += size.y + 10;
Vector2 size = MeasureTextEx(GetFontDefault(), lines[i], p">(float)fontSize, 2);
textHeight += p">(int)size.y + 10;
} }
// A simple scrollbar on the side to show how far we have red into the file // A simple scrollbar on the side to show how far we have red into the file
Rectangle scrollBar = { Rectangle scrollBar = {
.x = screenWidth - 5,
.x = p">(float)screenWidth - 5,
.y = 0, .y = 0,
.width = 5, .width = 5,
.height = screenHeight*i">100/(textHeight - screenHeight) // Scrollbar height is just a percentage
.height = screenHeight*f">100.0f/(textHeight - screenHeight) // Scrollbar height is just a percentage
}; };
SetTargetFPS(60); SetTargetFPS(60);
@ -115,10 +115,10 @@ int main(void)
// Ensuring that the camera does not scroll past all text // Ensuring that the camera does not scroll past all text
if (cam.target.y > textHeight - screenHeight + textTop) if (cam.target.y > textHeight - screenHeight + textTop)
cam.target.y = textHeight - screenHeight + textTop;
cam.target.y = p">(float)textHeight - screenHeight + textTop;
// Computing the position of the scrollBar depending on the percentage of text covered // Computing the position of the scrollBar depending on the percentage of text covered
scrollBar.y = Lerp(textTop, screenHeight - scrollBar.height, (cam.target.y - textTop)/(textHeight - screenHeight));
scrollBar.y = Lerp(p">(float)textTop, p">(float)screenHeight - scrollBar.height, (float)(cam.target.y - textTop)/(textHeight - screenHeight));
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
@ -132,13 +132,13 @@ int main(void)
for (int i = 0, t = textTop; i < lineCount; i++) for (int i = 0, t = textTop; i < lineCount; i++)
{ {
// Each time we go through and calculate the height of the text to move the cursor appropriately // Each time we go through and calculate the height of the text to move the cursor appropriately
Vector2 size = MeasureTextEx(GetFontDefault(), lines[i], fontSize, 2);
Vector2 size = MeasureTextEx(GetFontDefault(), lines[i], p">(float)fontSize, 2);
DrawText(lines[i], 10, t, fontSize, RED); DrawText(lines[i], 10, t, fontSize, RED);
// Inserting extra space for real newlines, // Inserting extra space for real newlines,
// wrapped lines are rendered closer together // wrapped lines are rendered closer together
t += size.y + 10;
t += p">(int)size.y + 10;
} }
EndMode2D(); EndMode2D();

+ 3
- 0
examples/shapes/shapes_clock_of_clocks.c View File

@ -14,6 +14,9 @@
* Copyright (c) 2025 JP Mortiboys (@themushroompirates) * Copyright (c) 2025 JP Mortiboys (@themushroompirates)
* *
********************************************************************************************/ ********************************************************************************************/
#if defined(WIN32)
#define _CRT_SECURE_NO_WARNINGS
#endif
#include "raylib.h" #include "raylib.h"

Loading…
Cancel
Save