Skip to content

Commit e48b9a6

Browse files
[Examples] Warning fixes (pt 1) (raysan5#1668)
* Fix some warnings in examples. * cleanups from review Co-authored-by: Jeffery Myers <JefMyers@blizzard.com>
1 parent c6dd414 commit e48b9a6

30 files changed

+104
-103
lines changed

examples/core/core_input_gamepad.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,20 @@ int main(void)
9292
// Draw axis: left joystick
9393
DrawCircle(259, 152, 39, BLACK);
9494
DrawCircle(259, 152, 34, LIGHTGRAY);
95-
DrawCircle(259 + (GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_X)*20),
96-
152 + (GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_Y)*20), 25, BLACK);
95+
DrawCircle(259 + ((int)GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_X)*20),
96+
152 + ((int)GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_Y)*20), 25, BLACK);
9797

9898
// Draw axis: right joystick
9999
DrawCircle(461, 237, 38, BLACK);
100100
DrawCircle(461, 237, 33, LIGHTGRAY);
101-
DrawCircle(461 + (GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_X)*20),
102-
237 + (GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_Y)*20), 25, BLACK);
101+
DrawCircle(461 + ((int)GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_X)*20),
102+
237 + ((int)GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_Y)*20), 25, BLACK);
103103

104104
// Draw axis: left-right triggers
105105
DrawRectangle(170, 30, 15, 70, GRAY);
106106
DrawRectangle(604, 30, 15, 70, GRAY);
107-
DrawRectangle(170, 30, 15, (((1.0f + GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_TRIGGER))/2.0f)*70), RED);
108-
DrawRectangle(604, 30, 15, (((1.0f + GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_TRIGGER))/2.0f)*70), RED);
107+
DrawRectangle(170, 30, 15, (((1 + (int)GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_TRIGGER))/2)*70), RED);
108+
DrawRectangle(604, 30, 15, (((1 + (int)GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_TRIGGER))/2)*70), RED);
109109

110110
//DrawText(TextFormat("Xbox axis LT: %02.02f", GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_TRIGGER)), 10, 40, 10, BLACK);
111111
//DrawText(TextFormat("Xbox axis RT: %02.02f", GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_TRIGGER)), 10, 60, 10, BLACK);
@@ -140,20 +140,20 @@ int main(void)
140140
// Draw axis: left joystick
141141
DrawCircle(319, 255, 35, BLACK);
142142
DrawCircle(319, 255, 31, LIGHTGRAY);
143-
DrawCircle(319 + (GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_X)*20),
144-
255 + (GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_Y)*20), 25, BLACK);
143+
DrawCircle(319 + ((int)GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_X) * 20),
144+
255 + ((int)GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_Y) * 20), 25, BLACK);
145145

146146
// Draw axis: right joystick
147147
DrawCircle(475, 255, 35, BLACK);
148148
DrawCircle(475, 255, 31, LIGHTGRAY);
149-
DrawCircle(475 + (GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_X)*20),
150-
255 + (GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_Y)*20), 25, BLACK);
149+
DrawCircle(475 + ((int)GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_X)*20),
150+
255 + ((int)GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_Y)*20), 25, BLACK);
151151

152152
// Draw axis: left-right triggers
153153
DrawRectangle(169, 48, 15, 70, GRAY);
154154
DrawRectangle(611, 48, 15, 70, GRAY);
155-
DrawRectangle(169, 48, 15, (((1.0f - GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_TRIGGER))/2.0f)*70), RED);
156-
DrawRectangle(611, 48, 15, (((1.0f - GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_TRIGGER))/2.0f)*70), RED);
155+
DrawRectangle(169, 48, 15, (((1 - (int)GetGamepadAxisMovement(0, GAMEPAD_AXIS_LEFT_TRIGGER)) / 2) * 70), RED);
156+
DrawRectangle(611, 48, 15, (((1 - (int)GetGamepadAxisMovement(0, GAMEPAD_AXIS_RIGHT_TRIGGER)) / 2) * 70), RED);
157157
}
158158
else
159159
{

examples/core/core_input_gestures.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ int main(void)
2424
InitWindow(screenWidth, screenHeight, "raylib [core] example - input gestures");
2525

2626
Vector2 touchPosition = { 0, 0 };
27-
Rectangle touchArea = { 220, 10, screenWidth - 230, screenHeight - 20 };
27+
Rectangle touchArea = { 220, 10, screenWidth - 230.0f, screenHeight - 20.0f };
2828

2929
int gesturesCount = 0;
3030
char gestureStrings[MAX_GESTURE_STRINGS][32];

examples/core/core_input_multitouch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ int main(void)
6868
{
6969
// Draw circle and touch index number
7070
DrawCircleV(touchPosition, 34, ORANGE);
71-
DrawText(TextFormat("%d", i), touchPosition.x - 10, touchPosition.y - 70, 40, BLACK);
71+
DrawText(TextFormat("%d", i), (int)touchPosition.x - 10, (int)touchPosition.y - 70, 40, BLACK);
7272
}
7373
}
7474

7575
// Draw the normal mouse location
76-
DrawCircleV(ballPosition, 30 + (touchCounter*3), ballColor);
76+
DrawCircleV(ballPosition, 30 + (touchCounter*3.0f), ballColor);
7777

7878
DrawText("move ball with mouse and click mouse button to change color", 10, 10, 20, DARKGRAY);
7979
DrawText("touch the screen at multiple locations to get multiple balls", 10, 30, 20, DARKGRAY);

examples/core/core_scissor_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ int main(void)
4646

4747
ClearBackground(RAYWHITE);
4848

49-
if (scissorMode) BeginScissorMode(scissorArea.x, scissorArea.y, scissorArea.width, scissorArea.height);
49+
if (scissorMode) BeginScissorMode((int)scissorArea.x, (int)scissorArea.y, (int)scissorArea.width, (int)scissorArea.height);
5050

5151
// Draw full screen rectangle and some text
5252
// NOTE: Only part defined by scissor area will be rendered

examples/core/core_vr_simulator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ int main(void)
116116
EndVrDrawing();
117117

118118
BeginShaderMode(distortion);
119-
DrawTextureRec(target.texture, (Rectangle){ 0, 0, target.texture.width, -target.texture.height }, (Vector2){ 0.0f, 0.0f }, WHITE);
119+
DrawTextureRec(target.texture, (Rectangle){ 0, 0, (float)target.texture.width, (float)-target.texture.height }, (Vector2){ 0.0f, 0.0f }, WHITE);
120120
EndShaderMode();
121121

122122
DrawFPS(10, 10);

examples/core/core_window_flags.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ int main(void)
3939
//SetConfigFlags(FLAG_VSYNC_HINT | FLAG_MSAA_4X_HINT | FLAG_WINDOW_HIGHDPI);
4040
InitWindow(screenWidth, screenHeight, "raylib [core] example - window flags");
4141

42-
Vector2 ballPosition = { GetScreenWidth() / 2, GetScreenHeight() / 2 };
42+
Vector2 ballPosition = { GetScreenWidth() / 2.0f, GetScreenHeight() / 2.0f };
4343
Vector2 ballSpeed = { 5.0f, 4.0f };
44-
int ballRadius = 20;
44+
float ballRadius = 20;
4545

4646
int framesCounter = 0;
4747

@@ -139,7 +139,7 @@ int main(void)
139139
else ClearBackground(RAYWHITE);
140140

141141
DrawCircleV(ballPosition, ballRadius, MAROON);
142-
DrawRectangleLinesEx((Rectangle) { 0, 0, GetScreenWidth(), GetScreenHeight() }, 4, RAYWHITE);
142+
DrawRectangleLinesEx((Rectangle) { 0, 0, (float)GetScreenWidth(), (float)GetScreenHeight() }, 4, RAYWHITE);
143143

144144
DrawCircleV(GetMousePosition(), 10, DARKBLUE);
145145

examples/core/core_window_letterbox.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ int main(void)
9898

9999
// Draw RenderTexture2D to window, properly scaled
100100
DrawTexturePro(target.texture, (Rectangle){ 0.0f, 0.0f, (float)target.texture.width, (float)-target.texture.height },
101-
(Rectangle){ (GetScreenWidth() - ((float)gameScreenWidth*scale))*0.5, (GetScreenHeight() - ((float)gameScreenHeight*scale))*0.5,
101+
(Rectangle){ (GetScreenWidth() - ((float)gameScreenWidth*scale))*0.5f, (GetScreenHeight() - ((float)gameScreenHeight*scale))*0.5f,
102102
(float)gameScreenWidth*scale, (float)gameScreenHeight*scale }, (Vector2){ 0, 0 }, 0.0f, WHITE);
103103

104104
EndDrawing();

examples/core/core_world_screen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ int main(void)
6262

6363
EndMode3D();
6464

65-
DrawText("Enemy: 100 / 100", cubeScreenPosition.x - MeasureText("Enemy: 100/100", 20)/2, cubeScreenPosition.y, 20, BLACK);
65+
DrawText("Enemy: 100 / 100", (int)cubeScreenPosition.x - MeasureText("Enemy: 100/100", 20)/2, (int)cubeScreenPosition.y, 20, BLACK);
6666
DrawText("Text is always on top of the cube", (screenWidth - MeasureText("Text is always on top of the cube", 20))/2, 25, 20, GRAY);
6767

6868
EndDrawing();

examples/models/models_cubicmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ int main(void)
6262

6363
EndMode3D();
6464

65-
DrawTextureEx(cubicmap, (Vector2){ screenWidth - cubicmap.width*4 - 20, 20 }, 0.0f, 4.0f, WHITE);
65+
DrawTextureEx(cubicmap, (Vector2){ screenWidth - cubicmap.width*4.0f - 20, 20.0f }, 0.0f, 4.0f, WHITE);
6666
DrawRectangleLines(screenWidth - cubicmap.width*4 - 20, 20, cubicmap.width*4, cubicmap.height*4, GREEN);
6767

6868
DrawText("cubicmap image used to", 658, 90, 10, GRAY);

examples/models/models_first_person_maze.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ int main(void)
9595
DrawModel(model, mapPosition, 1.0f, WHITE); // Draw maze map
9696
EndMode3D();
9797

98-
DrawTextureEx(cubicmap, (Vector2){ GetScreenWidth() - cubicmap.width*4 - 20, 20 }, 0.0f, 4.0f, WHITE);
98+
DrawTextureEx(cubicmap, (Vector2){ GetScreenWidth() - cubicmap.width*4.0f - 20, 20.0f }, 0.0f, 4.0f, WHITE);
9999
DrawRectangleLines(GetScreenWidth() - cubicmap.width*4 - 20, 20, cubicmap.width*4, cubicmap.height*4, GREEN);
100100

101101
// Draw player position radar

0 commit comments

Comments
 (0)