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/textures | |
| 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/textures')
| -rw-r--r-- | examples/textures/textures_bunnymark.c | 2 | ||||
| -rw-r--r-- | examples/textures/textures_draw_tiled.c | 14 | ||||
| -rw-r--r-- | examples/textures/textures_mouse_painting.c | 10 | ||||
| -rw-r--r-- | examples/textures/textures_sprite_button.c | 6 | ||||
| -rw-r--r-- | examples/textures/textures_sprite_explosion.c | 8 |
5 files changed, 20 insertions, 20 deletions
diff --git a/examples/textures/textures_bunnymark.c b/examples/textures/textures_bunnymark.c index 8182102c..b92b3d41 100644 --- a/examples/textures/textures_bunnymark.c +++ b/examples/textures/textures_bunnymark.c @@ -94,7 +94,7 @@ int main(void) // Process of sending data is costly and it could happen that GPU data has not been completely // processed for drawing while new data is tried to be sent (updating current in-use buffers) // it could generates a stall and consequently a frame drop, limiting the number of drawn bunnies - DrawTexture(texBunny, bunnies[i].position.x, bunnies[i].position.y, bunnies[i].color); + DrawTexture(texBunny, (int)bunnies[i].position.x, (int)bunnies[i].position.y, bunnies[i].color); } DrawRectangle(0, 0, screenWidth, 40, BLACK); diff --git a/examples/textures/textures_draw_tiled.c b/examples/textures/textures_draw_tiled.c index 7d8a3c41..97bffc80 100644 --- a/examples/textures/textures_draw_tiled.c +++ b/examples/textures/textures_draw_tiled.c @@ -47,10 +47,10 @@ int main(int argc, char **argv) // Calculate rectangle for each color for (int i = 0, x = 0, y = 0; i < MAX_COLORS; i++) { - colorRec[i].x = 2 + MARGIN_SIZE + x; - colorRec[i].y = 22 + 256 + MARGIN_SIZE + y; - colorRec[i].width = COLOR_SIZE*2; - colorRec[i].height = COLOR_SIZE; + colorRec[i].x = 2.0f + MARGIN_SIZE + x; + colorRec[i].y = 22.0f + 256.0f + MARGIN_SIZE + y; + colorRec[i].width = COLOR_SIZE*2.0f; + colorRec[i].height = (float)COLOR_SIZE; if (i == (MAX_COLORS/2 - 1)) { @@ -122,7 +122,7 @@ int main(int argc, char **argv) ClearBackground(RAYWHITE); // Draw the tiled area - DrawTextureTiled(texPattern, recPattern[activePattern], (Rectangle){OPT_WIDTH+MARGIN_SIZE, MARGIN_SIZE, screenWidth - OPT_WIDTH - 2*MARGIN_SIZE, screenHeight - 2*MARGIN_SIZE}, + DrawTextureTiled(texPattern, recPattern[activePattern], (Rectangle){(float)OPT_WIDTH+MARGIN_SIZE, (float)MARGIN_SIZE, screenWidth - OPT_WIDTH - 2.0f*MARGIN_SIZE, screenHeight - 2.0f*MARGIN_SIZE}, (Vector2){0.0f, 0.0f}, rotation, scale, colors[activeCol]); // Draw options @@ -130,13 +130,13 @@ int main(int argc, char **argv) DrawText("Select Pattern", 2 + MARGIN_SIZE, 30 + MARGIN_SIZE, 10, BLACK); DrawTexture(texPattern, 2 + MARGIN_SIZE, 40 + MARGIN_SIZE, BLACK); - DrawRectangle(2 + MARGIN_SIZE + recPattern[activePattern].x, 40 + MARGIN_SIZE + recPattern[activePattern].y, recPattern[activePattern].width, recPattern[activePattern].height, ColorAlpha(DARKBLUE, 0.3f)); + DrawRectangle(2 + MARGIN_SIZE + (int)recPattern[activePattern].x, 40 + MARGIN_SIZE + (int)recPattern[activePattern].y, (int)recPattern[activePattern].width, (int)recPattern[activePattern].height, ColorAlpha(DARKBLUE, 0.3f)); DrawText("Select Color", 2+MARGIN_SIZE, 10+256+MARGIN_SIZE, 10, BLACK); for (int i = 0; i < MAX_COLORS; i++) { DrawRectangleRec(colorRec[i], colors[i]); - if (activeCol == i) DrawRectangleLinesEx(colorRec[i], 3.0f, ColorAlpha(WHITE, 0.5f)); + if (activeCol == i) DrawRectangleLinesEx(colorRec[i], 3, ColorAlpha(WHITE, 0.5f)); } DrawText("Scale (UP/DOWN to change)", 2 + MARGIN_SIZE, 80 + 256 + MARGIN_SIZE, 10, BLACK); diff --git a/examples/textures/textures_mouse_painting.c b/examples/textures/textures_mouse_painting.c index e9b876b4..30fd390f 100644 --- a/examples/textures/textures_mouse_painting.c +++ b/examples/textures/textures_mouse_painting.c @@ -35,7 +35,7 @@ int main(void) for (int i = 0; i < MAX_COLORS_COUNT; i++) { - colorsRecs[i].x = 10 + 30*i + 2*i; + colorsRecs[i].x = 10 + 30.0f*i + 2*i; colorsRecs[i].y = 10; colorsRecs[i].width = 30; colorsRecs[i].height = 30; @@ -44,7 +44,7 @@ int main(void) int colorSelected = 0; int colorSelectedPrev = colorSelected; int colorMouseHover = 0; - int brushSize = 20; + float brushSize = 20.0f; bool mouseWasPressed = false; Rectangle btnSaveRec = { 750, 10, 40, 30 }; @@ -113,7 +113,7 @@ int main(void) // NOTE: To avoid discontinuous circles, we could store // previous-next mouse points and just draw a line using brush size BeginTextureMode(target); - if (mousePos.y > 50) DrawCircle(mousePos.x, mousePos.y, brushSize, colors[colorSelected]); + if (mousePos.y > 50) DrawCircle((int)mousePos.x, (int)mousePos.y, brushSize, colors[colorSelected]); EndTextureMode(); } @@ -129,7 +129,7 @@ int main(void) // Erase circle from render texture BeginTextureMode(target); - if (mousePos.y > 50) DrawCircle(mousePos.x, mousePos.y, brushSize, colors[0]); + if (mousePos.y > 50) DrawCircle((int)mousePos.x, (int)mousePos.y, brushSize, colors[0]); EndTextureMode(); } else if (IsMouseButtonReleased(MOUSE_RIGHT_BUTTON) && mouseWasPressed) @@ -172,7 +172,7 @@ int main(void) ClearBackground(RAYWHITE); // NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom) - DrawTextureRec(target.texture, (Rectangle) { 0, 0, target.texture.width, -target.texture.height }, (Vector2) { 0, 0 }, WHITE); + DrawTextureRec(target.texture, (Rectangle) { 0, 0, (float)target.texture.width, (float)-target.texture.height }, (Vector2) { 0, 0 }, WHITE); // Draw drawing circle for reference if (mousePos.y > 50) diff --git a/examples/textures/textures_sprite_button.c b/examples/textures/textures_sprite_button.c index a5b2d8d1..6ca4ea90 100644 --- a/examples/textures/textures_sprite_button.c +++ b/examples/textures/textures_sprite_button.c @@ -28,11 +28,11 @@ int main(void) Texture2D button = LoadTexture("resources/button.png"); // Load button texture // Define frame rectangle for drawing - int frameHeight = button.height/NUM_FRAMES; - Rectangle sourceRec = { 0, 0, button.width, frameHeight }; + float frameHeight = (float)button.height/NUM_FRAMES; + Rectangle sourceRec = { 0, 0, (float)button.width, frameHeight }; // Define button bounds on screen - Rectangle btnBounds = { screenWidth/2 - button.width/2, screenHeight/2 - button.height/NUM_FRAMES/2, button.width, frameHeight }; + Rectangle btnBounds = { screenWidth/2.0f - button.width/2.0f, screenHeight/2.0f - button.height/NUM_FRAMES/2.0f, (float)button.width, frameHeight }; int btnState = 0; // Button state: 0-NORMAL, 1-MOUSE_HOVER, 2-PRESSED bool btnAction = false; // Button action should be activated diff --git a/examples/textures/textures_sprite_explosion.c b/examples/textures/textures_sprite_explosion.c index 53f2626e..52ac2606 100644 --- a/examples/textures/textures_sprite_explosion.c +++ b/examples/textures/textures_sprite_explosion.c @@ -58,8 +58,8 @@ int main(void) position = GetMousePosition(); active = true; - position.x -= frameWidth/2; - position.y -= frameHeight/2; + position.x -= frameWidth/2.0f; + position.y -= frameHeight/2.0f; PlaySound(fxBoom); } @@ -89,8 +89,8 @@ int main(void) } } - frameRec.x = frameWidth*currentFrame; - frameRec.y = frameHeight*currentLine; + frameRec.x = (float)frameWidth*currentFrame; + frameRec.y = (float)frameHeight*currentLine; //---------------------------------------------------------------------------------- // Draw |
