Browse Source

Merge pull request #618 from kimkulling/fix_compiler_warnings

Fix compiler warnings
Ray 7 years ago
parent
commit
61b32e45ed

+ 3 - 3
examples/textures/textures_image_processing.c

@@ -59,7 +59,7 @@ int main()
 
     Rectangle selectRecs[NUM_PROCESSES];
     
-    for (int i = 0; i < NUM_PROCESSES; i++) selectRecs[i] = (Rectangle){ 40, 50 + 32*i, 150, 30 };
+    for (int i = 0; i < NUM_PROCESSES; i++) selectRecs[i] = (Rectangle){ 40.0f, (float)(50 + 32*i), 150.0f, 30.0f };
     
     SetTargetFPS(60);
     //---------------------------------------------------------------------------------------
@@ -122,8 +122,8 @@ int main()
             for (int i = 0; i < NUM_PROCESSES; i++)
             {
                 DrawRectangleRec(selectRecs[i], (i == currentProcess) ? SKYBLUE : LIGHTGRAY);
-                DrawRectangleLines(selectRecs[i].x, selectRecs[i].y, selectRecs[i].width, selectRecs[i].height, (i == currentProcess) ? BLUE : GRAY);
-                DrawText(processText[i], selectRecs[i].x + selectRecs[i].width/2 - MeasureText(processText[i], 10)/2, selectRecs[i].y + 11, 10, (i == currentProcess) ? DARKBLUE : DARKGRAY);
+                DrawRectangleLines((int)selectRecs[i].x, (int) selectRecs[i].y, (int) selectRecs[i].width, (int) selectRecs[i].height, (i == currentProcess) ? BLUE : GRAY);
+                DrawText( processText[i], (int)( selectRecs[i].x + selectRecs[i].width/2 - MeasureText(processText[i], 10)/2), (int) selectRecs[i].y + 11, 10, (i == currentProcess) ? DARKBLUE : DARKGRAY);
             }
 
             DrawTexture(texture, screenWidth - texture.width - 60, screenHeight/2 - texture.height/2, WHITE);

+ 3 - 3
examples/textures/textures_image_text.c

@@ -26,12 +26,12 @@ int main()
     Image parrots = LoadImage("resources/parrots.png"); // Load image in CPU memory (RAM)
 
     // Draw over image using custom font
-    ImageDrawTextEx(&parrots, (Vector2){ 20, 20 }, font, "[Parrots font drawing]", font.baseSize, 0, WHITE);
+    ImageDrawTextEx(&parrots, (Vector2){ 20.0f, 20.0f }, font, "[Parrots font drawing]", (float)font.baseSize, 0.0f, WHITE);
 
     Texture2D texture = LoadTextureFromImage(parrots);  // Image converted to texture, uploaded to GPU memory (VRAM)
     UnloadImage(parrots);   // Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM
     
-    Vector2 position = { screenWidth/2 - texture.width/2, screenHeight/2 - texture.height/2 - 20 };
+    Vector2 position = { (float)(screenWidth/2 - texture.width/2), (float)(screenHeight/2 - texture.height/2 - 20) };
     
     bool showFont = false;
 
@@ -60,7 +60,7 @@ int main()
                 
                 // Draw text directly using sprite font
                 DrawTextEx(font, "[Parrots font drawing]", (Vector2){ position.x + 20, 
-                           position.y + 20 + 280 }, font.baseSize, 0, WHITE);
+                           position.y + 20 + 280 }, (float)font.baseSize, 0.0f, WHITE);
             }
             else DrawTexture(font.texture, screenWidth/2 - font.texture.width/2, 50, BLACK);
             

+ 3 - 3
examples/textures/textures_particles_blending.c

@@ -42,7 +42,7 @@ int main()
         mouseTail[i].color = (Color){ GetRandomValue(0, 255), GetRandomValue(0, 255), GetRandomValue(0, 255), 255 };
         mouseTail[i].alpha = 1.0f;
         mouseTail[i].size = (float)GetRandomValue(1, 30)/20.0f;
-        mouseTail[i].rotation = GetRandomValue(0, 360);
+        mouseTail[i].rotation = (float) GetRandomValue(0, 360);
         mouseTail[i].active = false;
     }
     
@@ -107,9 +107,9 @@ int main()
                 // Draw active particles
                 for (int i = 0; i < MAX_PARTICLES; i++)
                 {
-                    if (mouseTail[i].active) DrawTexturePro(smoke, (Rectangle){ 0, 0, smoke.width, smoke.height }, 
+                    if (mouseTail[i].active) DrawTexturePro(smoke, (Rectangle){ 0.0f, 0.0f, (float) smoke.width, (float) smoke.height }, 
                                                            (Rectangle){ mouseTail[i].position.x, mouseTail[i].position.y, smoke.width*mouseTail[i].size, smoke.height*mouseTail[i].size },
-                                                           (Vector2){ smoke.width*mouseTail[i].size/2, smoke.height*mouseTail[i].size/2 }, mouseTail[i].rotation,
+                                                           (Vector2){ (float) (smoke.width*mouseTail[i].size/2.0f), (float)(smoke.height*mouseTail[i].size/2.0f) }, mouseTail[i].rotation,
                                                            Fade(mouseTail[i].color, mouseTail[i].alpha));
                 }
             

+ 6 - 6
examples/textures/textures_srcrec_dstrec.c

@@ -27,13 +27,13 @@ int main()
     int frameHeight = scarfy.height;
     
     // NOTE: Source rectangle (part of the texture to use for drawing)
-    Rectangle sourceRec = { 0, 0, frameWidth, frameHeight };
+    Rectangle sourceRec = { 0.0f, 0.0f, (float)frameWidth, (float)frameHeight };
 
     // NOTE: Destination rectangle (screen rectangle where drawing part of texture)
-    Rectangle destRec = { screenWidth/2, screenHeight/2, frameWidth*2, frameHeight*2 };
+    Rectangle destRec = { (float) screenWidth/2, (float)screenHeight/2, (float)frameWidth*2, (float)frameHeight*2 };
 
     // NOTE: Origin of the texture (rotation/scale point), it's relative to destination rectangle size
-    Vector2 origin = { frameWidth, frameHeight };
+    Vector2 origin = { (float) frameWidth, (float) frameHeight };
     
     int rotation = 0;
     
@@ -59,10 +59,10 @@ int main()
             // destRec defines the rectangle where our texture part will fit (scaling it to fit)
             // origin defines the point of the texture used as reference for rotation and scaling
             // rotation defines the texture rotation (using origin as rotation point)
-            DrawTexturePro(scarfy, sourceRec, destRec, origin, rotation, WHITE);
+            DrawTexturePro(scarfy, sourceRec, destRec, origin, (float)rotation, WHITE);
 
-            DrawLine(destRec.x, 0, destRec.x, screenHeight, GRAY);
-            DrawLine(0, destRec.y, screenWidth, destRec.y, GRAY);
+            DrawLine((int) destRec.x, 0, (int) destRec.x, screenHeight, GRAY);
+            DrawLine(0, (int)destRec.y, screenWidth, (int)destRec.y, GRAY);
             
             DrawText("(c) Scarfy sprite by Eiden Marsal", screenWidth - 200, screenHeight - 20, 10, GRAY);
 

+ 2 - 2
src/camera.h

@@ -244,8 +244,8 @@ void SetCameraMode(Camera camera, int mode)
     distance.y = sqrtf(dx*dx + dy*dy);
     
     // Camera angle calculation
-    cameraAngle.x = asinf(fabs(dx)/distance.x);  // Camera angle in plane XZ (0 aligned with Z, move positive CCW)
-    cameraAngle.y = -asinf(fabs(dy)/distance.y); // Camera angle in plane XY (0 aligned with X, move positive CW)
+    cameraAngle.x = asinf( (float)fabs(dx)/distance.x);  // Camera angle in plane XZ (0 aligned with Z, move positive CCW)
+    cameraAngle.y = -asinf( (float)fabs(dy)/distance.y); // Camera angle in plane XY (0 aligned with X, move positive CW)
     
     // NOTE: Just testing what cameraAngle means
     //cameraAngle.x = 0.0f*DEG2RAD;       // Camera angle in plane XZ (0 aligned with Z, move positive CCW)

+ 2 - 2
src/core.c

@@ -886,7 +886,7 @@ void EndDrawing(void)
     // Wait for some milliseconds...
     if (frameTime < targetTime)
     {
-        Wait((targetTime - frameTime)*1000.0f);
+        Wait( (float)(targetTime - frameTime)*1000.0f);
 
         currentTime = GetTime();
         double extraTime = currentTime - previousTime;
@@ -2510,7 +2510,7 @@ static void SetupFramebufferSize(int displayWidth, int displayHeight)
 // Initialize hi-resolution timer
 static void InitTimer(void)
 {
-    srand(time(NULL));              // Initialize random seed
+    srand((unsigned int)time(NULL));              // Initialize random seed
     
 #if !defined(SUPPORT_BUSY_WAIT_LOOP) && defined(_WIN32)
     timeBeginPeriod(1);             // Setup high-resolution timer to 1ms (granularity of 1-2 ms)

+ 5 - 5
src/models.c

@@ -1771,7 +1771,7 @@ void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis, float
 // Draw a billboard
 void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size, Color tint)
 {
-    Rectangle sourceRec = { 0, 0, texture.width, texture.height };
+    Rectangle sourceRec = { 0.0f, 0.0f, (float)texture.width, (float)texture.height };
 
     DrawBillboardRec(camera, texture, sourceRec, center, size, tint);
 }
@@ -1837,9 +1837,9 @@ void DrawBoundingBox(BoundingBox box, Color color)
 {
     Vector3 size;
 
-    size.x = fabs(box.max.x - box.min.x);
-    size.y = fabs(box.max.y - box.min.y);
-    size.z = fabs(box.max.z - box.min.z);
+    size.x = (float)fabs(box.max.x - box.min.x);
+    size.y = (float)fabs(box.max.y - box.min.y);
+    size.z = (float)fabs(box.max.z - box.min.z);
 
     Vector3 center = { box.min.x + size.x/2.0f, box.min.y + size.y/2.0f, box.min.z + size.z/2.0f };
 
@@ -2206,9 +2206,9 @@ void MeshBinormals(Mesh *mesh)
         Vector3 tangent = { mesh->tangents[i*4 + 0], mesh->tangents[i*4 + 1], mesh->tangents[i*4 + 2] };
         float tangentW = mesh->tangents[i*4 + 3];
     
-        Vector3 binormal = Vector3Multiply(Vector3CrossProduct(normal, tangent), tangentW);
         
         // TODO: Register computed binormal in mesh->binormal ?
+        // Vector3 binormal = Vector3Multiply( Vector3CrossProduct( normal, tangent ), tangentW );
     }
 }
 

+ 20 - 20
src/raymath.h

@@ -296,12 +296,12 @@ RMDEF Vector3 Vector3Perpendicular(Vector3 v)
 {
     Vector3 result = { 0 };
 
-    float min = fabs(v.x);
+    float min = (float) fabs(v.x);
     Vector3 cardinalAxis = {1.0f, 0.0f, 0.0f};
 
     if (fabs(v.y) < min)
     {
-        min = fabs(v.y);
+        min = (float) fabs(v.y);
         Vector3 tmp = {0.0f, 1.0f, 0.0f};
         cardinalAxis = tmp;
     }
@@ -840,28 +840,28 @@ RMDEF Matrix MatrixFrustum(double left, double right, double bottom, double top,
 {
     Matrix result = { 0 };
 
-    float rl = (right - left);
-    float tb = (top - bottom);
-    float fn = (far - near);
+    float rl = (float)(right - left);
+    float tb = (float)(top - bottom);
+    float fn = (float)(far - near);
 
-    result.m0 = (near*2.0f)/rl;
+    result.m0 = ((float) near*2.0f)/rl;
     result.m1 = 0.0f;
     result.m2 = 0.0f;
     result.m3 = 0.0f;
 
     result.m4 = 0.0f;
-    result.m5 = (near*2.0f)/tb;
+    result.m5 = ((float) near*2.0f)/tb;
     result.m6 = 0.0f;
     result.m7 = 0.0f;
 
-    result.m8 = (right + left)/rl;
-    result.m9 = (top + bottom)/tb;
-    result.m10 = -(far + near)/fn;
+    result.m8 = ((float)right + (float)left)/rl;
+    result.m9 = ((float)top + (float)bottom)/tb;
+    result.m10 = -((float)far + (float)near)/fn;
     result.m11 = -1.0f;
 
     result.m12 = 0.0f;
     result.m13 = 0.0f;
-    result.m14 = -(far*near*2.0f)/fn;
+    result.m14 = -((float)far*(float)near*2.0f)/fn;
     result.m15 = 0.0f;
 
     return result;
@@ -883,9 +883,9 @@ RMDEF Matrix MatrixOrtho(double left, double right, double bottom, double top, d
 {
     Matrix result = { 0 };
 
-    float rl = (right - left);
-    float tb = (top - bottom);
-    float fn = (far - near);
+    float rl = (float)(right - left);
+    float tb = (float)(top - bottom);
+    float fn = (float)(far - near);
 
     result.m0 = 2.0f/rl;
     result.m1 = 0.0f;
@@ -899,9 +899,9 @@ RMDEF Matrix MatrixOrtho(double left, double right, double bottom, double top, d
     result.m9 = 0.0f;
     result.m10 = -2.0f/fn;
     result.m11 = 0.0f;
-    result.m12 = -(left + right)/rl;
-    result.m13 = -(top + bottom)/tb;
-    result.m14 = -(far + near)/fn;
+    result.m12 = -((float)left + (float)right)/rl;
+    result.m13 = -((float)top + (float)bottom)/tb;
+    result.m14 = -((float)far + (float)near)/fn;
     result.m15 = 1.0f;
 
     return result;
@@ -980,7 +980,7 @@ RMDEF Quaternion QuaternionIdentity(void)
 // Computes the length of a quaternion
 RMDEF float QuaternionLength(Quaternion q)
 {
-    float result = sqrt(q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w);
+    float result = (float)sqrt(q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w);
     return result;
 }
 
@@ -1071,8 +1071,8 @@ RMDEF Quaternion QuaternionSlerp(Quaternion q1, Quaternion q2, float amount)
     else if (cosHalfTheta > 0.95f) result = QuaternionNlerp(q1, q2, amount);
     else
     {
-        float halfTheta = acos(cosHalfTheta);
-        float sinHalfTheta = sqrt(1.0f - cosHalfTheta*cosHalfTheta);
+        float halfTheta = (float) acos(cosHalfTheta);
+        float sinHalfTheta = (float) sqrt(1.0f - cosHalfTheta*cosHalfTheta);
 
         if (fabs(sinHalfTheta) < 0.001f)
         {

+ 8 - 8
src/rlgl.h

@@ -3306,8 +3306,8 @@ Texture2D GenTexturePrefilter(Shader shader, Texture2D cubemap, int size)
     for (unsigned int mip = 0; mip < MAX_MIPMAP_LEVELS; mip++)
     {
         // Resize framebuffer according to mip-level size.
-        unsigned int mipWidth  = size*powf(0.5f, mip);
-        unsigned int mipHeight = size*powf(0.5f, mip);
+        unsigned int mipWidth  = size*(int) powf(0.5f, (float) mip);
+        unsigned int mipHeight = size* (int) powf(0.5f, (float) mip);
 
         glBindRenderbuffer(GL_RENDERBUFFER, rbo);
         glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, mipWidth, mipHeight);
@@ -3633,15 +3633,15 @@ void EndVrDrawing(void)
 
                 // Bottom-right corner for texture and quad
                 rlTexCoord2f(0.0f, 0.0f);
-                rlVertex2f(0.0f, vrConfig.stereoFbo.texture.height);
+                rlVertex2f(0.0f, (float)vrConfig.stereoFbo.texture.height);
 
                 // Top-right corner for texture and quad
                 rlTexCoord2f(1.0f, 0.0f);
-                rlVertex2f(vrConfig.stereoFbo.texture.width, vrConfig.stereoFbo.texture.height);
+                rlVertex2f( (float)vrConfig.stereoFbo.texture.width, (float)vrConfig.stereoFbo.texture.height);
 
                 // Top-left corner for texture and quad
                 rlTexCoord2f(1.0f, 1.0f);
-                rlVertex2f(vrConfig.stereoFbo.texture.width, 0.0f);
+                rlVertex2f( (float)vrConfig.stereoFbo.texture.width, 0.0f);
             rlEnd();
         rlPopMatrix();
 
@@ -4502,7 +4502,7 @@ static void SetStereoConfig(VrDeviceInfo hmd)
 
     // Compute distortion scale parameters
     // NOTE: To get lens max radius, lensShift must be normalized to [-1..1]
-    float lensRadius = fabs(-1.0f - 4.0f*lensShift);
+    float lensRadius = (float)fabs(-1.0f - 4.0f*lensShift);
     float lensRadiusSq = lensRadius*lensRadius;
     float distortionScale = hmd.lensDistortionValues[0] +
                             hmd.lensDistortionValues[1]*lensRadiusSq +
@@ -4553,8 +4553,8 @@ static void SetStereoConfig(VrDeviceInfo hmd)
     vrConfig.eyesViewOffset[1] = MatrixTranslate(hmd.interpupillaryDistance*0.5f, 0.075f, 0.045f);
 
     // Compute eyes Viewports
-    vrConfig.eyesViewport[0] = (Rectangle){ 0, 0, hmd.hResolution/2, hmd.vResolution };
-    vrConfig.eyesViewport[1] = (Rectangle){ hmd.hResolution/2, 0, hmd.hResolution/2, hmd.vResolution };
+    vrConfig.eyesViewport[0] = (Rectangle){ 0.0f, 0.0f, (float)hmd.hResolution/2, (float)hmd.vResolution };
+    vrConfig.eyesViewport[1] = (Rectangle){ hmd.hResolution/2.0f, 0.0f, (float)hmd.hResolution/2, (float) hmd.vResolution };
 }
 
 // Set internal projection and modelview matrix depending on eyes tracking data

+ 23 - 23
src/shapes.c

@@ -153,9 +153,9 @@ void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color)
     for (int i = 1; i <= LINE_DIVISIONS; i++)
     {
         // Cubic easing in-out
-        // NOTE: Easing is calcutated only for y position value 
-        current.y = EaseCubicInOut(i, startPos.y, endPos.y - startPos.y, LINE_DIVISIONS);
-        current.x = previous.x + (endPos.x - startPos.x)/LINE_DIVISIONS;
+        // NOTE: Easing is calculated only for y position value 
+        current.y = EaseCubicInOut((float)i, startPos.y, endPos.y - startPos.y, (float) LINE_DIVISIONS);
+        current.x = previous.x + (endPos.x - startPos.x)/ (float) LINE_DIVISIONS;
         
         DrawLineEx(previous, current, thick, color);
         
@@ -324,7 +324,7 @@ void DrawRectangleV(Vector2 position, Vector2 size, Color color)
 // Draw a color-filled rectangle
 void DrawRectangleRec(Rectangle rec, Color color)
 {
-    DrawRectangle(rec.x, rec.y, rec.width, rec.height, color);
+    DrawRectangle((int)rec.x, (int)rec.y, (int)rec.width, (int)rec.height, color);
 }
 
 void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color)
@@ -354,14 +354,14 @@ void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color
 // NOTE: Gradient goes from bottom (color1) to top (color2)
 void DrawRectangleGradientV(int posX, int posY, int width, int height, Color color1, Color color2)
 {
-    DrawRectangleGradientEx((Rectangle){ posX, posY, width, height }, color1, color2, color2, color1);
+    DrawRectangleGradientEx((Rectangle){ (float)posX, (float)posY, (float)width, (float)height }, color1, color2, color2, color1);
 }
 
 // Draw a horizontal-gradient-filled rectangle
 // NOTE: Gradient goes from bottom (color1) to top (color2)
 void DrawRectangleGradientH(int posX, int posY, int width, int height, Color color1, Color color2)
 {
-    DrawRectangleGradientEx((Rectangle){ posX, posY, width, height }, color1, color1, color2, color2);
+    DrawRectangleGradientEx((Rectangle){ (float)posX, (float)posY, (float)width, (float)height }, color1, color1, color2, color2);
 }
 
 // Draw a gradient-filled rectangle
@@ -457,14 +457,14 @@ void DrawRectangleLinesEx(Rectangle rec, int lineThick, Color color)
 {   
     if (lineThick > rec.width || lineThick > rec.height)
     {
-        if(rec.width > rec.height) lineThick = rec.height/2;
-        else if (rec.width < rec.height) lineThick = rec.width/2;
+        if(rec.width > rec.height) lineThick = (int)rec.height/2;
+        else if (rec.width < rec.height) lineThick = (int)rec.width/2;
     }        
     
-    DrawRectangle(rec.x, rec.y, rec.width, lineThick, color);
-    DrawRectangle(rec.x - lineThick + rec.width, rec.y + lineThick, lineThick, rec.height - lineThick*2, color);
-    DrawRectangle(rec.x, rec.y + rec.height - lineThick, rec.width, lineThick, color);
-    DrawRectangle(rec.x, rec.y + lineThick, lineThick, rec.height - lineThick*2, color);
+    DrawRectangle( (int)rec.x, (int)rec.y, (int)rec.width, lineThick, color);
+    DrawRectangle( (int)(rec.x - lineThick + rec.width), (int)(rec.y + lineThick), lineThick, (int)(rec.height - lineThick*2.0f), color);
+    DrawRectangle( (int)rec.x, (int)(rec.y + rec.height - lineThick), (int)rec.width, lineThick, color);
+    DrawRectangle( (int)rec.x, (int)(rec.y + lineThick), lineThick, (int)(rec.height - lineThick*2), color);
 }
 
 // Draw a triangle
@@ -648,8 +648,8 @@ bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2)
 {
     bool collision = false;
 
-    float dx = fabs((rec1.x + rec1.width/2) - (rec2.x + rec2.width/2));
-    float dy = fabs((rec1.y + rec1.height/2) - (rec2.y + rec2.height/2));
+    float dx = (float)fabs((rec1.x + rec1.width/2) - (rec2.x + rec2.width/2));
+    float dy = (float)fabs((rec1.y + rec1.height/2) - (rec2.y + rec2.height/2));
 
     if ((dx <= (rec1.width/2 + rec2.width/2)) && ((dy <= (rec1.height/2 + rec2.height/2)))) collision = true;
 
@@ -675,11 +675,11 @@ bool CheckCollisionCircles(Vector2 center1, float radius1, Vector2 center2, floa
 // NOTE: Reviewed version to take into account corner limit case
 bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec)
 {
-    int recCenterX = rec.x + rec.width/2;
-    int recCenterY = rec.y + rec.height/2;
+    int recCenterX = (int)(rec.x + rec.width/2.0f);
+    int recCenterY = (int)(rec.y + rec.height/2.0f);
     
-    float dx = fabs(center.x - recCenterX);
-    float dy = fabs(center.y - recCenterY);
+    float dx = (float)fabs(center.x - recCenterX);
+    float dy = (float)fabs(center.y - recCenterY);
 
     if (dx > (rec.width/2.0f + radius)) { return false; }
     if (dy > (rec.height/2.0f + radius)) { return false; }
@@ -700,8 +700,8 @@ Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2)
 
     if (CheckCollisionRecs(rec1, rec2))
     {
-        float dxx = fabs(rec1.x - rec2.x);
-        float dyy = fabs(rec1.y - rec2.y);
+        float dxx = (float)fabs(rec1.x - rec2.x);
+        float dyy = (float)fabs(rec1.y - rec2.y);
 
         if (rec1.x <= rec2.x)
         {
@@ -768,8 +768,8 @@ Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2)
 // NOTE: Required for DrawLineBezier()
 static float EaseCubicInOut(float t, float b, float c, float d) 
 { 
-    if ((t /= 0.5*d) < 1)
-        return 0.5*c*t*t*t + b;
+    if ((t /= 0.5f*d) < 1)
+        return 0.5f*c*t*t*t + b;
     t -= 2;
-    return 0.5*c*(t*t*t + 2) + b;
+    return 0.5f*c*(t*t*t + 2.0f) + b;
 }

+ 22 - 22
src/text.c

@@ -220,12 +220,12 @@ extern void LoadDefaultFont(void)
     {
         defaultFont.chars[i].value = 32 + i;  // First char is 32
 
-        defaultFont.chars[i].rec.x = currentPosX;
-        defaultFont.chars[i].rec.y = charsDivisor + currentLine*(charsHeight + charsDivisor);
-        defaultFont.chars[i].rec.width = charsWidth[i];
-        defaultFont.chars[i].rec.height = charsHeight;
+        defaultFont.chars[i].rec.x = (float) currentPosX;
+        defaultFont.chars[i].rec.y = (float) charsDivisor + currentLine*(charsHeight + charsDivisor);
+        defaultFont.chars[i].rec.width = (float) charsWidth[i];
+        defaultFont.chars[i].rec.height = (float) charsHeight;
 
-        testPosX += (defaultFont.chars[i].rec.width + charsDivisor);
+        testPosX += (int) (defaultFont.chars[i].rec.width + (float) charsDivisor);
 
         if (testPosX >= defaultFont.texture.width)
         {
@@ -233,8 +233,8 @@ extern void LoadDefaultFont(void)
             currentPosX = 2*charsDivisor + charsWidth[i];
             testPosX = currentPosX;
 
-            defaultFont.chars[i].rec.x = charsDivisor;
-            defaultFont.chars[i].rec.y = charsDivisor + currentLine*(charsHeight + charsDivisor);
+            defaultFont.chars[i].rec.x = (float)charsDivisor;
+            defaultFont.chars[i].rec.y = (float)charsDivisor + currentLine*(charsHeight + charsDivisor);
         }
         else currentPosX = testPosX;
 
@@ -244,7 +244,7 @@ extern void LoadDefaultFont(void)
         defaultFont.chars[i].advanceX = 0;
     }
 
-    defaultFont.baseSize = defaultFont.chars[0].rec.height;
+    defaultFont.baseSize = (int) defaultFont.chars[0].rec.height;
     
     TraceLog(LOG_INFO, "[TEX ID %i] Default font loaded successfully", defaultFont.texture.id);
 }
@@ -361,14 +361,14 @@ CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int c
     if (!stbtt_InitFont(&fontInfo, fontBuffer, 0)) TraceLog(LOG_WARNING, "Failed to init font!");
 
     // Calculate font scale factor
-    float scaleFactor = stbtt_ScaleForPixelHeight(&fontInfo, fontSize);
+    float scaleFactor = stbtt_ScaleForPixelHeight(&fontInfo, (float) fontSize);
 
     // Calculate font basic metrics
     // NOTE: ascent is equivalent to font baseline
     int ascent, descent, lineGap;
     stbtt_GetFontVMetrics(&fontInfo, &ascent, &descent, &lineGap);
-    ascent *= scaleFactor;
-    descent *= scaleFactor;
+    ascent *= (int) scaleFactor;
+    descent *= (int) scaleFactor;
     
     // Fill fontChars in case not provided externally
     // NOTE: By default we fill charsCount consecutevely, starting at 32 (Space)
@@ -407,7 +407,7 @@ CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int c
         TraceLog(LOG_DEBUG, "Character offsetY: %i", ascent + chY1);
 
         stbtt_GetCodepointHMetrics(&fontInfo, ch, &chars[i].advanceX, NULL);
-        chars[i].advanceX *= scaleFactor;
+        chars[i].advanceX *= (int) scaleFactor;
     }
     
     free(fontBuffer);
@@ -460,8 +460,8 @@ Image GenImageFontAtlas(CharInfo *chars, int charsCount, int fontSize, int paddi
                 }
             }
             
-            chars[i].rec.x = offsetX;
-            chars[i].rec.y = offsetY;
+            chars[i].rec.x = (float) offsetX;
+            chars[i].rec.y = (float) offsetY;
             
             // Move atlas position X for next character drawing
             offsetX += ((int)chars[i].rec.width + 2*padding);
@@ -502,8 +502,8 @@ Image GenImageFontAtlas(CharInfo *chars, int charsCount, int fontSize, int paddi
         
         for (int i = 0; i < charsCount; i++)
         {
-            chars[i].rec.x = rects[i].x + padding;
-            chars[i].rec.y = rects[i].y + padding;
+            chars[i].rec.x = rects[i].x + (float) padding;
+            chars[i].rec.y = rects[i].y + (float) padding;
             
             if (rects[i].was_packed)
             {
@@ -834,15 +834,15 @@ static Font LoadImageFont(Image image, Color key, int firstChar)
         {
             tempCharValues[index] = firstChar + index;
 
-            tempCharRecs[index].x = xPosToRead;
-            tempCharRecs[index].y = lineSpacing + lineToRead*(charHeight + lineSpacing);
-            tempCharRecs[index].height = charHeight;
+            tempCharRecs[index].x = (float) xPosToRead;
+            tempCharRecs[index].y = (float) (lineSpacing + lineToRead*(charHeight + lineSpacing));
+            tempCharRecs[index].height = (float) charHeight;
 
             int charWidth = 0;
 
             while (!COLOR_EQUAL(pixels[(lineSpacing + (charHeight+lineSpacing)*lineToRead)*image.width + xPosToRead + charWidth], key)) charWidth++;
 
-            tempCharRecs[index].width = charWidth;
+            tempCharRecs[index].width = (float) charWidth;
 
             index++;
 
@@ -887,7 +887,7 @@ static Font LoadImageFont(Image image, Color key, int firstChar)
         spriteFont.chars[i].advanceX = 0;
     }
 
-    spriteFont.baseSize = spriteFont.chars[0].rec.height;
+    spriteFont.baseSize = (int) spriteFont.chars[0].rec.height;
 
     TraceLog(LOG_INFO, "Image file loaded correctly as Font");
 
@@ -996,7 +996,7 @@ static Font LoadBMFont(const char *fileName)
 
         // Save data properly in sprite font
         font.chars[i].value = charId;
-        font.chars[i].rec = (Rectangle){ charX, charY, charWidth, charHeight };
+        font.chars[i].rec = (Rectangle){ (float) charX, (float) charY, (float) charWidth, (float) charHeight };
         font.chars[i].offsetX = charOffsetX;
         font.chars[i].offsetY = charOffsetY;
         font.chars[i].advanceX = charAdvanceX;

+ 34 - 33
src/textures.c

@@ -314,7 +314,7 @@ Image LoadImageRaw(const char *fileName, int width, int height, int format, int
 
         // NOTE: fread() returns num read elements instead of bytes,
         // to get bytes we need to read (1 byte size, elements) instead of (x byte size, 1 element)
-        int bytes = fread(image.data, 1, size, rawFile);
+        size_t bytes = fread(image.data, 1, size, rawFile);
 
         // Check if data has been read successfully
         if (bytes < size)
@@ -1051,16 +1051,16 @@ void ImageAlphaCrop(Image *image, float threshold)
             minx = i%image->width;
             miny = -(-((i/image->width) + 1) + 1);
 
-            if (crop.y == 0) crop.y = miny;
+            if (crop.y == 0.0f) crop.y = (float)miny;
 
-            if (crop.x == 0) crop.x = minx;
-            else if (minx < crop.x) crop.x = minx;
+            if (crop.x == 0.0f) crop.x = (float)minx;
+            else if (minx < crop.x) crop.x = (float)minx;
 
-            if (crop.width == 0) crop.width = minx; 
-            else if (crop.width < minx) crop.width = minx;
+            if (crop.width == 0.0f) crop.width = (float)minx;
+            else if (crop.width < minx) crop.width = (float)minx;
 
-            if (crop.height == 0) crop.height = miny;
-            else if (crop.height < miny) crop.height = miny;
+            if (crop.height == 0.0f) crop.height = (float)miny;
+            else if (crop.height < (float) miny) crop.height = (float)miny;
         }
     }
     
@@ -1216,8 +1216,8 @@ void ImageResizeNN(Image *image,int newWidth,int newHeight)
 void ImageResizeCanvas(Image *image, int newWidth,int newHeight, int offsetX, int offsetY, Color color)
 {
     Image imTemp = GenImageColor(newWidth, newHeight, color);
-    Rectangle srcRec = { 0, 0, image->width, image->height };
-    Rectangle dstRec = { offsetX, offsetY, srcRec.width, srcRec.height };
+    Rectangle srcRec = { 0.0f, 0.0f, (float)image->width, (float)image->height };
+    Rectangle dstRec = { (float)offsetX, (float)offsetY, (float)srcRec.width, (float)srcRec.height };
     
     // TODO: Review different scaling situations
     
@@ -1450,7 +1450,7 @@ void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec)
     if (dstRec.y < 0) dstRec.y = 0;
 
     // Scale source image in case destination rec size is different than source rec size
-    if ((dstRec.width != srcRec.width) || (dstRec.height != srcRec.height)) ImageResize(&srcCopy, dstRec.width, dstRec.height);
+    if ((dstRec.width != srcRec.width) || (dstRec.height != srcRec.height)) ImageResize(&srcCopy, (int)dstRec.width, (int)dstRec.height);
 
     if ((dstRec.x + dstRec.width) > dst->width)
     {
@@ -1530,7 +1530,7 @@ Image ImageText(const char *text, int fontSize, Color color)
 {
     int defaultFontSize = 10;   // Default Font chars height in pixel
     if (fontSize < defaultFontSize) fontSize = defaultFontSize;
-    int spacing = (float)fontSize/defaultFontSize;
+    int spacing = fontSize / defaultFontSize;
 
     Image imText = ImageTextEx(GetFontDefault(), text, (float)fontSize, (float)spacing, color);
 
@@ -1546,7 +1546,7 @@ Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Co
     unsigned char character;    // Current character
 
     // TODO: ISSUE: Measured text size does not seem to be correct... issue on ImageDraw()
-    Vector2 imSize = MeasureTextEx(font, text, font.baseSize, spacing);
+    Vector2 imSize = MeasureTextEx(font, text, (float)font.baseSize, spacing);
     
     TraceLog(LOG_DEBUG, "Text Image size: %f, %f", imSize.x, imSize.y);
 
@@ -1588,12 +1588,12 @@ Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Co
             
             if ((unsigned char)text[i] != ' ')
             {
-                ImageDraw(&imText, imFont, letter.rec, (Rectangle){ posX + letter.offsetX, 
-                          letter.offsetY, letter.rec.width, letter.rec.height });
+                ImageDraw(&imText, imFont, letter.rec, (Rectangle){ (float) (posX + letter.offsetX), 
+                    (float)letter.offsetY, (float)letter.rec.width, (float)letter.rec.height });
             }
 
-            if (letter.advanceX == 0) posX += letter.rec.width + spacing;
-            else posX += letter.advanceX + spacing;
+            if (letter.advanceX == 0) posX += (int)(letter.rec.width + spacing);
+            else posX += letter.advanceX + (int) spacing;
         }
     }
 
@@ -1616,9 +1616,9 @@ Image ImageTextEx(Font font, const char *text, float fontSize, float spacing, Co
 // Draw rectangle within an image
 void ImageDrawRectangle(Image *dst, Vector2 position, Rectangle rec, Color color)
 {
-    Image imRec = GenImageColor(rec.width, rec.height, color);
+    Image imRec = GenImageColor((int)rec.width, (int)rec.height, color);
     
-    Rectangle dstRec = { position.x, position.y, imRec.width, imRec.height };
+    Rectangle dstRec = { position.x, position.y, (float)imRec.width, (float)imRec.height };
 
     ImageDraw(dst, imRec, rec, dstRec);
     
@@ -1637,8 +1637,8 @@ void ImageDrawTextEx(Image *dst, Vector2 position, Font font, const char *text,
 {
     Image imText = ImageTextEx(font, text, fontSize, spacing, color);
 
-    Rectangle srcRec = { 0, 0, imText.width, imText.height };
-    Rectangle dstRec = { position.x, position.y, imText.width, imText.height };
+    Rectangle srcRec = { 0.0f, 0.0f, (float)imText.width, (float)imText.height };
+    Rectangle dstRec = { position.x, position.y, (float)imText.width, (float)imText.height };
 
     ImageDraw(dst, imText, srcRec, dstRec);
 
@@ -1759,10 +1759,11 @@ void ImageColorTint(Image *image, Color color)
     {
         for (int x = 0; x < image->width; x++)
         {
-            unsigned char r = 255*((float)pixels[y*image->width + x].r/255*cR);
-            unsigned char g = 255*((float)pixels[y*image->width + x].g/255*cG);
-            unsigned char b = 255*((float)pixels[y*image->width + x].b/255*cB);
-            unsigned char a = 255*((float)pixels[y*image->width + x].a/255*cA);
+            int index = y * image->width + x;
+            unsigned char r = 255*((float)pixels[index].r/255*cR);
+            unsigned char g = 255*((float)pixels[index].g/255*cG);
+            unsigned char b = 255*((float)pixels[index].b/255*cB);
+            unsigned char a = 255*((float)pixels[index].a/255*cA);
 
             pixels[y*image->width + x].r = r;
             pixels[y*image->width + x].g = g;
@@ -2010,8 +2011,8 @@ Image GenImageGradientRadial(int width, int height, float density, Color inner,
             float dist = hypotf((float)x - centerX, (float)y - centerY);
             float factor = (dist - radius*density)/(radius*(1.0f - density));
             
-            factor = fmax(factor, 0.f);
-            factor = fmin(factor, 1.f); // dist can be bigger than radius so we have to check
+            factor = (float)fmax(factor, 0.f);
+            factor = (float)fmin(factor, 1.f); // dist can be bigger than radius so we have to check
             
             pixels[y*width + x].r = (int)((float)outer.r*factor + (float)inner.r*(1.0f - factor));
             pixels[y*width + x].g = (int)((float)outer.g*factor + (float)inner.g*(1.0f - factor));
@@ -2109,7 +2110,7 @@ Image GenImageCellular(int width, int height, int tileSize)
     {
         int y = (i/seedsPerRow)*tileSize + GetRandomValue(0, tileSize - 1);
         int x = (i%seedsPerRow)*tileSize + GetRandomValue(0, tileSize - 1);
-        seeds[i] = (Vector2){x, y};
+        seeds[i] = (Vector2){ (float)x, (float)y};
     }
 
     for (int y = 0; y < height; y++)
@@ -2120,7 +2121,7 @@ Image GenImageCellular(int width, int height, int tileSize)
         {
             int tileX = x/tileSize;
 
-            float minDistance = strtod("Inf", NULL);
+            float minDistance = (float)strtod("Inf", NULL);
 
             // Check all adjacent tiles
             for (int i = -1; i < 2; i++)
@@ -2133,8 +2134,8 @@ Image GenImageCellular(int width, int height, int tileSize)
 
                     Vector2 neighborSeed = seeds[(tileY + j)*seedsPerRow + tileX + i];
 
-                    float dist = hypot(x - (int)neighborSeed.x, y - (int)neighborSeed.y);
-                    minDistance = fmin(minDistance, dist);
+                    float dist = (float)hypot(x - (int)neighborSeed.x, y - (int)neighborSeed.y);
+                    minDistance = (float)fmin(minDistance, dist);
                 }
             }
 
@@ -2278,7 +2279,7 @@ void DrawTextureEx(Texture2D texture, Vector2 position, float rotation, float sc
 // Draw a part of a texture (defined by a rectangle)
 void DrawTextureRec(Texture2D texture, Rectangle sourceRec, Vector2 position, Color tint)
 {
-    Rectangle destRec = { position.x, position.y, sourceRec.width, fabs(sourceRec.height) };
+    Rectangle destRec = { position.x, position.y, sourceRec.width, (float)fabs(sourceRec.height) };
     Vector2 origin = { 0.0f, 0.0f };
 
     DrawTexturePro(texture, sourceRec, destRec, origin, 0.0f, tint);
@@ -2684,7 +2685,7 @@ static Image LoadKTX(const char *fileName)
 
             if (ktxHeader.keyValueDataSize > 0)
             {
-                for (int i = 0; i < ktxHeader.keyValueDataSize; i++) fread(&unused, sizeof(unsigned char), 1, ktxFile);
+                for (unsigned int i = 0; i < ktxHeader.keyValueDataSize; i++) fread(&unused, sizeof(unsigned char), 1U, ktxFile);
             }
 
             int dataSize;