Skip to content

Commit f6d05cc

Browse files
authored
Merge pull request #4899 from JeffM2501/examples_casting_4-26-25
[Examples] Fix cast warnings in examples.
2 parents 5b94069 + eb3d96a commit f6d05cc

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

examples/core/core_high_dpi.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616
static void DrawTextCenter(const char *text, int x, int y, int fontSize, Color color)
1717
{
18-
Vector2 size = MeasureTextEx(GetFontDefault(), text, fontSize, 3);
18+
Vector2 size = MeasureTextEx(GetFontDefault(), text, (float)fontSize, 3);
1919
Vector2 pos = (Vector2){x - size.x/2, y - size.y/2 };
20-
DrawTextEx(GetFontDefault(), text, pos, fontSize, 3, color);
20+
DrawTextEx(GetFontDefault(), text, pos, (float)fontSize, 3, color);
2121
}
2222

2323
//------------------------------------------------------------------------------------
@@ -86,11 +86,11 @@ int main(void)
8686
const int minTextSpace = 30;
8787
int last_text_x = -minTextSpace;
8888
for (int i = cellSize; i < GetRenderWidth(); i += cellSize, odd = !odd) {
89-
int x = ((float)i) / dpiScale.x;
89+
int x = (int)(((float)i) / dpiScale.x);
9090
if (odd) {
91-
DrawRectangle(x, pixelGridTop, cellSizePx, pixelGridBottom-pixelGridTop, CLITERAL(Color){ 0, 121, 241, 100 });
91+
DrawRectangle(x, pixelGridTop, (int)cellSizePx, pixelGridBottom-pixelGridTop, CLITERAL(Color){ 0, 121, 241, 100 });
9292
}
93-
DrawLine(x, pixelGridTop, ((float)i) / dpiScale.x, pixelGridLabelY - 10, GRAY);
93+
DrawLine(x, pixelGridTop, (int)(((float)i) / dpiScale.x), pixelGridLabelY - 10, GRAY);
9494
if (x - last_text_x >= minTextSpace) {
9595
DrawTextCenter(TextFormat("%d", i), x, pixelGridLabelY, 12, LIGHTGRAY);
9696
last_text_x = x;

examples/shaders/shaders_rounded_rectangle.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ int main(void)
108108

109109
// Draw rectangle box with rounded corners using shader
110110
Rectangle rec = { 50, 70, 110, 60 };
111-
DrawRectangleLines(rec.x - 20, rec.y - 20, rec.width + 40, rec.height + 40, DARKGRAY);
112-
DrawText("Rounded rectangle", rec.x - 20, rec.y - 35, 10, DARKGRAY);
111+
DrawRectangleLines((int)rec.x - 20, (int)rec.y - 20, (int)rec.width + 40, (int)rec.height + 40, DARKGRAY);
112+
DrawText("Rounded rectangle", (int)rec.x - 20, (int)rec.y - 35, 10, DARKGRAY);
113113

114114
// Flip Y axis to match shader coordinate system
115115
rec.y = screenHeight - rec.y - rec.height;
@@ -128,8 +128,8 @@ int main(void)
128128

129129
// Draw rectangle shadow using shader
130130
rec = (Rectangle){ 50, 200, 110, 60 };
131-
DrawRectangleLines(rec.x - 20, rec.y - 20, rec.width + 40, rec.height + 40, DARKGRAY);
132-
DrawText("Rounded rectangle shadow", rec.x - 20, rec.y - 35, 10, DARKGRAY);
131+
DrawRectangleLines((int)rec.x - 20, (int)rec.y - 20, (int)rec.width + 40, (int)rec.height + 40, DARKGRAY);
132+
DrawText("Rounded rectangle shadow", (int)rec.x - 20, (int)rec.y - 35, 10, DARKGRAY);
133133

134134
rec.y = screenHeight - rec.y - rec.height;
135135
SetShaderValue(shader, roundedRectangle.rectangleLoc, (float[]){ rec.x, rec.y, rec.width, rec.height }, SHADER_UNIFORM_VEC4);
@@ -147,8 +147,8 @@ int main(void)
147147

148148
// Draw rectangle's border using shader
149149
rec = (Rectangle){ 50, 330, 110, 60 };
150-
DrawRectangleLines(rec.x - 20, rec.y - 20, rec.width + 40, rec.height + 40, DARKGRAY);
151-
DrawText("Rounded rectangle border", rec.x - 20, rec.y - 35, 10, DARKGRAY);
150+
DrawRectangleLines((int)rec.x - 20, (int)rec.y - 20, (int)rec.width + 40, (int)rec.height + 40, DARKGRAY);
151+
DrawText("Rounded rectangle border", (int)rec.x - 20, (int)rec.y - 35, 10, DARKGRAY);
152152

153153
rec.y = screenHeight - rec.y - rec.height;
154154
SetShaderValue(shader, roundedRectangle.rectangleLoc, (float[]){ rec.x, rec.y, rec.width, rec.height }, SHADER_UNIFORM_VEC4);
@@ -166,8 +166,8 @@ int main(void)
166166

167167
// Draw one more rectangle with all three colors
168168
rec = (Rectangle){ 240, 80, 500, 300 };
169-
DrawRectangleLines(rec.x - 30, rec.y - 30, rec.width + 60, rec.height + 60, DARKGRAY);
170-
DrawText("Rectangle with all three combined", rec.x - 30, rec.y - 45, 10, DARKGRAY);
169+
DrawRectangleLines((int)rec.x - 30, (int)rec.y - 30, (int)rec.width + 60, (int)rec.height + 60, DARKGRAY);
170+
DrawText("Rectangle with all three combined", (int)rec.x - 30, (int)rec.y - 45, 10, DARKGRAY);
171171

172172
rec.y = screenHeight - rec.y - rec.height;
173173
SetShaderValue(shader, roundedRectangle.rectangleLoc, (float[]){ rec.x, rec.y, rec.width, rec.height }, SHADER_UNIFORM_VEC4);

0 commit comments

Comments
 (0)