[Examples] Warning fixes (pt 1) (#1668)
* Fix some warnings in examples. * cleanups from review Co-authored-by: Jeffery Myers <JefMyers@blizzard.com>
This commit is contained in:
parent
c6dd41495b
commit
e48b9a6da1
30 changed files with 104 additions and 103 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue