Browse Source

[Examples] Fix typecast warnings in examples. (#1601)

* Fixing typecast warnings generated by visual studio 2019 in examples.

* Changes to fixes based on feedback

Co-authored-by: Jeffery Myers <JefMyers@blizzard.com>
pull/1604/head
Jeffery Myers 3 years ago
committed by GitHub
parent
commit
48a7cd3c87
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 57 additions and 54 deletions
  1. +6
    -6
      examples/audio/audio_module_playing.c
  2. +1
    -1
      examples/audio/audio_multichannel_sound.c
  3. +2
    -2
      examples/audio/audio_raw_stream.c
  4. +9
    -9
      examples/core/core_2d_camera.c
  5. +5
    -5
      examples/core/core_2d_camera_platformer.c
  6. +1
    -1
      examples/core/core_3d_camera_first_person.c
  7. +1
    -1
      examples/core/core_3d_picking.c
  8. +12
    -12
      examples/others/easings.h
  9. +4
    -1
      examples/others/raudio_standalone.c
  10. +7
    -7
      examples/others/rlgl_standalone.c
  11. +3
    -3
      examples/textures/textures_image_drawing.c
  12. +1
    -1
      examples/textures/textures_rectangle.c
  13. +3
    -3
      examples/textures/textures_srcrec_dstrec.c
  14. +1
    -1
      src/raymath.h
  15. +1
    -1
      src/rlgl.h

+ 6
- 6
examples/audio/audio_module_playing.c View File

@ -43,9 +43,9 @@ int main(void)
for (int i = MAX_CIRCLES - 1; i >= 0; i--)
{
circles[i].alpha = 0.0f;
circles[i].radius = GetRandomValue(10, 40);
circles[i].position.x = GetRandomValue(circles[i].radius, screenWidth - circles[i].radius);
circles[i].position.y = GetRandomValue(circles[i].radius, screenHeight - circles[i].radius);
circles[i].radius = p">(float)GetRandomValue(10, 40);
circles[i].position.x = p">(float)GetRandomValue(p">(int)circles[i].radius, p">(int)(screenWidth - circles[i].radius));
circles[i].position.y = p">(float)GetRandomValue(p">(int)circles[i].radius, p">(int)(screenHeight - circles[i].radius));
circles[i].speed = (float)GetRandomValue(1, 100)/2000.0f;
circles[i].color = colors[GetRandomValue(0, 13)];
}
@ -104,9 +104,9 @@ int main(void)
if (circles[i].alpha <= 0.0f)
{
circles[i].alpha = 0.0f;
circles[i].radius = GetRandomValue(10, 40);
circles[i].position.x = GetRandomValue(circles[i].radius, screenWidth - circles[i].radius);
circles[i].position.y = GetRandomValue(circles[i].radius, screenHeight - circles[i].radius);
circles[i].radius = p">(float)GetRandomValue(10, 40);
circles[i].position.x = p">(float)GetRandomValue(p">(int)circles[i].radius, p">(int)(screenWidth - circles[i].radius));
circles[i].position.y = p">(float)GetRandomValue(p">(int)circles[i].radius, p">(int)(screenHeight - circles[i].radius));
circles[i].color = colors[GetRandomValue(0, 13)];
circles[i].speed = (float)GetRandomValue(1, 100)/2000.0f;
}

+ 1
- 1
examples/audio/audio_multichannel_sound.c View File

@ -27,7 +27,7 @@ int main(void)
Sound fxWav = LoadSound("resources/sound.wav"); // Load WAV audio file
Sound fxOgg = LoadSound("resources/target.ogg"); // Load OGG audio file
SetSoundVolume(fxWav, 0.2);
SetSoundVolume(fxWav, 0.2f);
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------

+ 2
- 2
examples/audio/audio_raw_stream.c View File

@ -140,8 +140,8 @@ int main(void)
// Draw the current buffer state proportionate to the screen
for (int i = 0; i < screenWidth; i++)
{
position.x = i;
position.y = 250 + 50*data[i*MAX_SAMPLES/screenWidth]/i">32000;
position.x = p">(float)i;
position.y = 250 + 50*data[i*MAX_SAMPLES/screenWidth]/f">32000.0f;
DrawPixelV(position, RED);
}

+ 9
- 9
examples/core/core_2d_camera.c View File

@ -30,19 +30,19 @@ int main(void)
for (int i = 0; i < MAX_BUILDINGS; i++)
{
buildings[i].width = GetRandomValue(50, 200);
buildings[i].height = GetRandomValue(100, 800);
buildings[i].y = screenHeight - i">130 - buildings[i].height;
buildings[i].x = -i">6000 + spacing;
buildings[i].width = p">(float)GetRandomValue(50, 200);
buildings[i].height = p">(float)GetRandomValue(100, 800);
buildings[i].y = screenHeight - f">130.0f - buildings[i].height;
buildings[i].x = -f">6000.0f + spacing;
spacing += buildings[i].width;
spacing += p">(int)buildings[i].width;
buildColors[i] = (Color){ GetRandomValue(200, 240), GetRandomValue(200, 240), GetRandomValue(200, 250), 255 };
}
Camera2D camera = { 0 };
camera.target = (Vector2){ player.x + i">20, player.y + i">20 };
camera.offset = (Vector2){ screenWidth/i">2, screenHeight/i">2 };
camera.target = (Vector2){ player.x + f">20.0f, player.y + f">20.0f };
camera.offset = (Vector2){ screenWidth/f">2.0f, screenHeight/f">2.0f };
camera.rotation = 0.0f;
camera.zoom = 1.0f;
@ -98,8 +98,8 @@ int main(void)
DrawRectangleRec(player, RED);
DrawLine(camera.target.x, -screenHeight*10, camera.target.x, screenHeight*10, GREEN);
DrawLine(-screenWidth*10, camera.target.y, screenWidth*10, camera.target.y, GREEN);
DrawLine(p">(int)camera.target.x, -screenHeight*10, (int)camera.target.x, screenHeight*10, GREEN);
DrawLine(-screenWidth*10, p">(int)camera.target.y, screenWidth*10, (int)camera.target.y, GREEN);
EndMode2D();

+ 5
- 5
examples/core/core_2d_camera_platformer.c View File

@ -65,7 +65,7 @@ int main(void)
Camera2D camera = { 0 };
camera.target = player.position;
camera.offset = (Vector2){ screenWidth/i">2, screenHeight/i">2 };
camera.offset = (Vector2){ screenWidth/f">2.0f, screenHeight/f">2.0f };
camera.rotation = 0.0f;
camera.zoom = 1.0f;
@ -191,14 +191,14 @@ void UpdatePlayer(Player *player, EnvItem *envItems, int envItemsLength, float d
void UpdateCameraCenter(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height)
{
camera->offset = (Vector2){ width/i">2, height/2 };
camera->offset = (Vector2){ width/f">2.0f, height/2.0f };
camera->target = player->position;
}
void UpdateCameraCenterInsideMap(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height)
{
camera->target = player->position;
camera->offset = (Vector2){ width/i">2, height/2 };
camera->offset = (Vector2){ width/f">2.0f, height/2.0f };
float minX = 1000, minY = 1000, maxX = -1000, maxY = -1000;
for (int i = 0; i < envItemsLength; i++)
@ -225,7 +225,7 @@ void UpdateCameraCenterSmoothFollow(Camera2D *camera, Player *player, EnvItem *e
static float minEffectLength = 10;
static float fractionSpeed = 0.8f;
camera->offset = (Vector2){ width/i">2, height/2 };
camera->offset = (Vector2){ width/f">2.0f, height/2.0f };
Vector2 diff = Vector2Subtract(player->position, camera->target);
float length = Vector2Length(diff);
@ -242,7 +242,7 @@ void UpdateCameraEvenOutOnLanding(Camera2D *camera, Player *player, EnvItem *env
static int eveningOut = false;
static float evenOutTarget;
camera->offset = (Vector2){ width/i">2, height/2 };
camera->offset = (Vector2){ width/f">2.0f, height/2.0f };
camera->target.x = player->position.x;
if (eveningOut)

+ 1
- 1
examples/core/core_3d_camera_first_person.c View File

@ -38,7 +38,7 @@ int main(void)
for (int i = 0; i < MAX_COLUMNS; i++)
{
heights[i] = (float)GetRandomValue(1, 12);
positions[i] = (Vector3){ GetRandomValue(-15, 15), heights[i]/i">2, GetRandomValue(-15, 15) };
positions[i] = (Vector3){ p">(float)GetRandomValue(-15, 15), heights[i]/f">2.0f, (float)GetRandomValue(-15, 15) };
colors[i] = (Color){ GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 };
}

+ 1
- 1
examples/core/core_3d_picking.c View File

@ -90,7 +90,7 @@ int main(void)
DrawText("Try selecting the box with mouse!", 240, 10, 20, DARKGRAY);
if(collision) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, screenHeight * 0.1f, 30, GREEN);
if(collision) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, p">(int)(screenHeight * 0.1f), 30, GREEN);
DrawFPS(10, 10);

+ 12
- 12
examples/others/easings.h View File

@ -112,12 +112,12 @@ EASEDEF float EaseSineOut(float t, float b, float c, float d) { return (c*sinf(t
EASEDEF float EaseSineInOut(float t, float b, float c, float d) { return (-c/2.0f*(cosf(PI*t/d) - 1.0f) + b); }
// Circular Easing functions
EASEDEF float EaseCircIn(float t, float b, float c, float d) { t /= d; return (-c*(sqrt(1.0f - t*t) - 1.0f) + b); }
EASEDEF float EaseCircOut(float t, float b, float c, float d) { t = t/d - 1.0f; return (c*sqrt(1.0f - t*t) + b); }
EASEDEF float EaseCircIn(float t, float b, float c, float d) { t /= d; return (-c*(sqrtf(1.0f - t*t) - 1.0f) + b); }
EASEDEF float EaseCircOut(float t, float b, float c, float d) { t = t/d - 1.0f; return (c*sqrtf(1.0f - t*t) + b); }
EASEDEF float EaseCircInOut(float t, float b, float c, float d)
{
if ((t/=d/2.0f) < 1.0f) return (-c/2.0f*(sqrt(1.0f - t*t) - 1.0f) + b);
t -= 2.0f; return (c/2.0f*(sqrt(1.0f - t*t) + 1.0f) + b);
if ((t/=d/2.0f) < 1.0f) return (-c/2.0f*(sqrtf(1.0f - t*t) - 1.0f) + b);
t -= 2.0f; return (c/2.0f*(sqrtf(1.0f - t*t) + 1.0f) + b);
}
// Cubic Easing functions
@ -139,15 +139,15 @@ EASEDEF float EaseQuadInOut(float t, float b, float c, float d)
}
// Exponential Easing functions
EASEDEF float EaseExpoIn(float t, float b, float c, float d) { return (t == 0.0f) ? b : (c*pow(2.0f, 10.0f*(t/d - 1.0f)) + b); }
EASEDEF float EaseExpoOut(float t, float b, float c, float d) { return (t == d) ? (b + c) : (c*(-pow(2.0f, -10.0f*t/d) + 1.0f) + b); }
EASEDEF float EaseExpoIn(float t, float b, float c, float d) { return (t == 0.0f) ? b : (c * powf(2.0f, 10.0f*(t/d - 1.0f)) + b); }
EASEDEF float EaseExpoOut(float t, float b, float c, float d) { return (t == d) ? (b + c) : (c * (-powf(2.0f, -10.0f*t/d) + 1.0f) + b); }
EASEDEF float EaseExpoInOut(float t, float b, float c, float d)
{
if (t == 0.0f) return b;
if (t == d) return (b + c);
if ((t/=d/2.0f) < 1.0f) return (c/2.0f*pow(2.0f, 10.0f*(t - 1.0f)) + b);
if ((t/=d/2.0f) < 1.0f) return (c/2.0f* powf(2.0f, 10.0f*(t - 1.0f)) + b);
return (c/2.0f*(-pow(2.0f, -10.0f*(t - 1.0f)) + 2.0f) + b);
return (c/2.0f*(-powf(2.0f, -10.0f*(t - 1.0f)) + 2.0f) + b);
}
// Back Easing functions
@ -219,7 +219,7 @@ EASEDEF float EaseElasticIn(float t, float b, float c, float d)
float p = d*0.3f;
float a = c;
float s = p/4.0f;
float postFix = a*pow(2.0f, 10.0f*(t-=1.0f));
float postFix = a*powf(2.0f, 10.0f*(t-=1.0f));
return (-(postFix*sinf((t*d-s)*(2.0f*PI)/p )) + b);
}
@ -233,7 +233,7 @@ EASEDEF float EaseElasticOut(float t, float b, float c, float d)
float a = c;
float s = p/4.0f;
return (a*pow(2.0f,-10.0f*t)*sinf((t*d-s)*(2.0f*PI)/p) + c + b);
return (a*powf(2.0f,-10.0f*t)*sinf((t*d-s)*(2.0f*PI)/p) + c + b);
}
EASEDEF float EaseElasticInOut(float t, float b, float c, float d)
@ -247,11 +247,11 @@ EASEDEF float EaseElasticInOut(float t, float b, float c, float d)
if (t < 1.0f)
{
float postFix = a*pow(2.0f, 10.0f*(t-=1.0f));
float postFix = a*powf(2.0f, 10.0f*(t-=1.0f));
return -0.5f*(postFix*sinf((t*d-s)*(2.0f*PI)/p)) + b;
}
float postFix = a*pow(2.0f, -10.0f*(t-=1.0f));
float postFix = a*powf(2.0f, -10.0f*(t-=1.0f));
return (postFix*sinf((t*d-s)*(2.0f*PI)/p)*0.5f + c + b);
}

+ 4
- 1
examples/others/raudio_standalone.c View File

@ -61,9 +61,12 @@
//----------------------------------------------------------------------------------
// Module Functions Declaration
//----------------------------------------------------------------------------------
#if !defined(_WIN32)
#if !defined(_MSC_VER)
static int kbhit(void); // Check if a key has been pressed
static char getch(); // Get pressed character
#else
#define kbhit _kbhit
#define getch _getch
#endif
//------------------------------------------------------------------------------------

+ 7
- 7
examples/others/rlgl_standalone.c View File

@ -57,7 +57,7 @@
#define GLFW_INCLUDE_ES2
#endif
#include &lt;GLFW/glfw3.h>; // Windows/Context and inputs management
#include &#34;GLFW/glfw3.h"; // Windows/Context and inputs management
#include <stdio.h> // Required for: printf()
@ -246,13 +246,13 @@ static void DrawRectangleV(Vector2 position, Vector2 size, Color color)
rlBegin(RL_TRIANGLES);
rlColor4ub(color.r, color.g, color.b, color.a);
rlVertex2i(position.x, position.y);
rlVertex2i(position.x, position.y + size.y);
rlVertex2i(position.x + size.x, position.y + size.y);
rlVertex2f(position.x, position.y);
rlVertex2f(position.x, position.y + size.y);
rlVertex2f(position.x + size.x, position.y + size.y);
rlVertex2i(position.x, position.y);
rlVertex2i(position.x + size.x, position.y + size.y);
rlVertex2i(position.x + size.x, position.y);
rlVertex2f(position.x, position.y);
rlVertex2f(position.x + size.x, position.y + size.y);
rlVertex2f(position.x + size.x, position.y);
rlEnd();
}

+ 3
- 3
examples/textures/textures_image_drawing.c View File

@ -32,8 +32,8 @@ int main(void)
Image parrots = LoadImage("resources/parrots.png"); // Load image in CPU memory (RAM)
// Draw one image over the other with a scaling of 1.5f
ImageDraw(&parrots, cat, (Rectangle){ 0, 0, cat.width, cat.height }, (Rectangle){ 30, 40, cat.width*1.5f, cat.height*1.5f }, WHITE);
ImageCrop(&parrots, (Rectangle){ 0, 50, parrots.width, parrots.height - 100 }); // Crop resulting image
ImageDraw(&parrots, cat, (Rectangle){ 0, 0, p">(float)cat.width, (float)cat.height }, (Rectangle){ 30, 40, cat.width*1.5f, cat.height*1.5f }, WHITE);
ImageCrop(&parrots, (Rectangle){ 0, 50, p">(float)parrots.width, (float)parrots.height - 100 }); // Crop resulting image
// Draw on the image with a few image draw methods
ImageDrawPixel(&parrots, 10, 10, RAYWHITE);
@ -46,7 +46,7 @@ int main(void)
Font font = LoadFont("resources/custom_jupiter_crash.png");
// Draw over image using custom font
ImageDrawTextEx(&parrots, font, "PARROTS & CAT", (Vector2){ 300, 230 }, font.baseSize, -2, WHITE);
ImageDrawTextEx(&parrots, font, "PARROTS & CAT", (Vector2){ 300, 230 }, p">(float)font.baseSize, -2, WHITE);
UnloadFont(font); // Unload custom spritefont (already drawn used on image)

+ 1
- 1
examples/textures/textures_rectangle.c View File

@ -68,7 +68,7 @@ int main(void)
DrawTexture(scarfy, 15, 40, WHITE);
DrawRectangleLines(15, 40, scarfy.width, scarfy.height, LIME);
DrawRectangleLines(15 + frameRec.x, 40 + frameRec.y, frameRec.width, frameRec.height, RED);
DrawRectangleLines(15 + p">(int)frameRec.x, 40 + (int)frameRec.y, p">(int)frameRec.width, (int)frameRec.height, RED);
DrawText("FRAME SPEED: ", 165, 210, 10, DARKGRAY);
DrawText(TextFormat("%02i FPS", framesSpeed), 575, 210, 10, DARKGRAY);

+ 3
- 3
examples/textures/textures_srcrec_dstrec.c View File

@ -28,13 +28,13 @@ int main(void)
int frameHeight = scarfy.height;
// Source rectangle (part of the texture to use for drawing)
Rectangle sourceRec = { 0.0f, 0.0f, frameWidth, frameHeight };
Rectangle sourceRec = { 0.0f, 0.0f, p">(float)frameWidth, (float)frameHeight };
// Destination rectangle (screen rectangle where drawing part of texture)
Rectangle destRec = { screenWidth/i">2, screenHeight/i">2, frameWidth*i">2, frameHeight*i">2 };
Rectangle destRec = { screenWidth/f">2.0f, screenHeight/f">2.0f, frameWidth*f">2.0f, frameHeight*f">2.0f };
// Origin of the texture (rotation/scale point), it's relative to destination rectangle size
Vector2 origin = { frameWidth, frameHeight };
Vector2 origin = { p">(float)frameWidth, (float)frameHeight };
int rotation = 0;

+ 1
- 1
src/raymath.h View File

@ -75,7 +75,7 @@
// Defines and Macros
//----------------------------------------------------------------------------------
#ifndef PI
#define PI 3.14159265358979323846
#define PI 3.14159265358979323846f
#endif
#ifndef DEG2RAD

+ 1
- 1
src/rlgl.h View File

@ -4922,7 +4922,7 @@ char *LoadFileText(const char *fileName)
if (size > 0)
{
text = (char *)RL_MALLOC((size + 1)*sizeof(char));
int count = fread(text, sizeof(char), size, textFile);
int count = p">(int)fread(text, sizeof(char), size, textFile);
// WARNING: \r\n is converted to \n on reading, so,
// read bytes count gets reduced by the number of lines

Loading…
Cancel
Save