Browse Source

Fix warnings in visual studio (#3512)

Jeffery Myers 1 năm trước cách đây
mục cha
commit
6cd37e57a6

+ 4 - 4
examples/core/core_2d_camera_split_screen.c

@@ -85,12 +85,12 @@ int main(void)
                 // Draw full scene with first camera
                 // Draw full scene with first camera
                 for (int i = 0; i < screenWidth/PLAYER_SIZE + 1; i++)
                 for (int i = 0; i < screenWidth/PLAYER_SIZE + 1; i++)
                 {
                 {
-                    DrawLineV((Vector2){PLAYER_SIZE*i, 0}, (Vector2){PLAYER_SIZE*i, screenHeight}, LIGHTGRAY);
+                    DrawLineV((Vector2){(float)PLAYER_SIZE*i, 0}, (Vector2){ (float)PLAYER_SIZE*i, (float)screenHeight}, LIGHTGRAY);
                 }
                 }
 
 
                 for (int i = 0; i < screenHeight/PLAYER_SIZE + 1; i++)
                 for (int i = 0; i < screenHeight/PLAYER_SIZE + 1; i++)
                 {
                 {
-                    DrawLineV((Vector2){0, PLAYER_SIZE*i}, (Vector2){screenWidth, PLAYER_SIZE*i}, LIGHTGRAY);
+                    DrawLineV((Vector2){0, (float)PLAYER_SIZE*i}, (Vector2){ (float)screenWidth, (float)PLAYER_SIZE*i}, LIGHTGRAY);
                 }
                 }
 
 
                 for (int i = 0; i < screenWidth/PLAYER_SIZE; i++)
                 for (int i = 0; i < screenWidth/PLAYER_SIZE; i++)
@@ -118,12 +118,12 @@ int main(void)
                 // Draw full scene with second camera
                 // Draw full scene with second camera
                 for (int i = 0; i < screenWidth/PLAYER_SIZE + 1; i++)
                 for (int i = 0; i < screenWidth/PLAYER_SIZE + 1; i++)
                 {
                 {
-                    DrawLineV((Vector2){PLAYER_SIZE*i, 0}, (Vector2){PLAYER_SIZE*i, screenHeight}, LIGHTGRAY);
+                    DrawLineV((Vector2){ (float)PLAYER_SIZE*i, 0}, (Vector2){ (float)PLAYER_SIZE*i, (float)screenHeight}, LIGHTGRAY);
                 }
                 }
 
 
                 for (int i = 0; i < screenHeight/PLAYER_SIZE + 1; i++)
                 for (int i = 0; i < screenHeight/PLAYER_SIZE + 1; i++)
                 {
                 {
-                    DrawLineV((Vector2){0, PLAYER_SIZE*i}, (Vector2){screenWidth, PLAYER_SIZE*i}, LIGHTGRAY);
+                    DrawLineV((Vector2){0, (float)PLAYER_SIZE*i}, (Vector2){ (float)screenWidth, (float)PLAYER_SIZE*i}, LIGHTGRAY);
                 }
                 }
 
 
                 for (int i = 0; i < screenWidth/PLAYER_SIZE; i++)
                 for (int i = 0; i < screenWidth/PLAYER_SIZE; i++)

+ 2 - 2
examples/core/core_drop_files.c

@@ -53,7 +53,7 @@ int main(void)
         {
         {
             FilePathList droppedFiles = LoadDroppedFiles();
             FilePathList droppedFiles = LoadDroppedFiles();
 
 
-            for (int i = 0, offset = filePathCounter; i < droppedFiles.count; i++)
+            for (int i = 0, offset = filePathCounter; i < (int)droppedFiles.count; i++)
             {
             {
                 if (filePathCounter < (MAX_FILEPATH_RECORDED - 1))
                 if (filePathCounter < (MAX_FILEPATH_RECORDED - 1))
                 {
                 {
@@ -77,7 +77,7 @@ int main(void)
             {
             {
                 DrawText("Dropped files:", 100, 40, 20, DARKGRAY);
                 DrawText("Dropped files:", 100, 40, 20, DARKGRAY);
 
 
-                for (unsigned int i = 0; i < filePathCounter; i++)
+                for (int i = 0; i < filePathCounter; i++)
                 {
                 {
                     if (i%2 == 0) DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.5f));
                     if (i%2 == 0) DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.5f));
                     else DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.3f));
                     else DrawRectangle(0, 85 + 40*i, screenWidth, 40, Fade(LIGHTGRAY, 0.3f));

+ 1 - 1
examples/models/models_loading_m3d.c

@@ -85,7 +85,7 @@ int main(void)
                 animFrameCounter = 0;
                 animFrameCounter = 0;
                 animId++;
                 animId++;
 
 
-                if (animId >= animsCount) animId = 0;
+                if (animId >= (int)animsCount) animId = 0;
                 UpdateModelAnimation(model, anims[animId], 0);
                 UpdateModelAnimation(model, anims[animId], 0);
                 animPlaying = true;
                 animPlaying = true;
             }
             }

+ 4 - 4
examples/shaders/shaders_hybrid_render.c

@@ -68,7 +68,7 @@ int main(void)
     marchLocs.screenCenter = GetShaderLocation(shdrRaymarch, "screenCenter");
     marchLocs.screenCenter = GetShaderLocation(shdrRaymarch, "screenCenter");
 
 
     // Transfer screenCenter position to shader. Which is used to calculate ray direction. 
     // Transfer screenCenter position to shader. Which is used to calculate ray direction. 
-    Vector2 screenCenter = {.x = screenWidth/2.0, .y = screenHeight/2.0};
+    Vector2 screenCenter = {.x = screenWidth/2.0f, .y = screenHeight/2.0f};
     SetShaderValue(shdrRaymarch, marchLocs.screenCenter , &screenCenter , SHADER_UNIFORM_VEC2);
     SetShaderValue(shdrRaymarch, marchLocs.screenCenter , &screenCenter , SHADER_UNIFORM_VEC2);
 
 
     // Use Customized function to create writable depth texture buffer
     // Use Customized function to create writable depth texture buffer
@@ -84,7 +84,7 @@ int main(void)
     };
     };
     
     
     // Camera FOV is pre-calculated in the camera Distance.
     // Camera FOV is pre-calculated in the camera Distance.
-    double camDist = 1.0/(tan(camera.fovy*0.5*DEG2RAD));
+    float camDist = 1.0f/(tanf(camera.fovy*0.5f*DEG2RAD));
     
     
     SetTargetFPS(60);               // Set our game to run at 60 frames-per-second
     SetTargetFPS(60);               // Set our game to run at 60 frames-per-second
     //--------------------------------------------------------------------------------------
     //--------------------------------------------------------------------------------------
@@ -113,7 +113,7 @@ int main(void)
             // Raymarch Scene
             // Raymarch Scene
             rlEnableDepthTest(); //Manually enable Depth Test to handle multiple rendering methods.
             rlEnableDepthTest(); //Manually enable Depth Test to handle multiple rendering methods.
             BeginShaderMode(shdrRaymarch);
             BeginShaderMode(shdrRaymarch);
-                DrawRectangleRec((Rectangle){0,0,screenWidth,screenHeight},WHITE);
+                DrawRectangleRec((Rectangle){0,0, (float)screenWidth, (float)screenHeight},WHITE);
             EndShaderMode();
             EndShaderMode();
             
             
             // Raserize Scene
             // Raserize Scene
@@ -132,7 +132,7 @@ int main(void)
         BeginDrawing();
         BeginDrawing();
             ClearBackground(RAYWHITE);
             ClearBackground(RAYWHITE);
         
         
-            DrawTextureRec(target.texture, (Rectangle) { 0, 0, screenWidth, -screenHeight }, (Vector2) { 0, 0 }, WHITE);
+            DrawTextureRec(target.texture, (Rectangle) { 0, 0, (float)screenWidth, (float)-screenHeight }, (Vector2) { 0, 0 }, WHITE);
             DrawFPS(10, 10);
             DrawFPS(10, 10);
         EndDrawing();
         EndDrawing();
         //----------------------------------------------------------------------------------
         //----------------------------------------------------------------------------------

+ 1 - 1
examples/shaders/shaders_write_depth.c

@@ -92,7 +92,7 @@ int main(void)
         BeginDrawing();
         BeginDrawing();
             ClearBackground(RAYWHITE);
             ClearBackground(RAYWHITE);
         
         
-            DrawTextureRec(target.texture, (Rectangle) { 0, 0, screenWidth, -screenHeight }, (Vector2) { 0, 0 }, WHITE);
+            DrawTextureRec(target.texture, (Rectangle) { 0, 0, (float)screenWidth, (float)-screenHeight }, (Vector2) { 0, 0 }, WHITE);
             DrawFPS(10, 10);
             DrawFPS(10, 10);
         EndDrawing();
         EndDrawing();
         //----------------------------------------------------------------------------------
         //----------------------------------------------------------------------------------

+ 1 - 1
examples/shapes/raygui.h

@@ -2653,7 +2653,7 @@ int GuiTextBox(Rectangle bounds, char *text, int bufferSize, bool editMode)
                 if (GetMousePosition().x >= (textBounds.x + textEndWidth - glyphWidth/2))
                 if (GetMousePosition().x >= (textBounds.x + textEndWidth - glyphWidth/2))
                 {
                 {
                     mouseCursor.x = textBounds.x + textEndWidth;
                     mouseCursor.x = textBounds.x + textEndWidth;
-                    mouseCursorIndex = strlen(text);
+                    mouseCursorIndex = (int)strlen(text);
                 }
                 }
 
 
                 // Place cursor at required index on mouse click
                 // Place cursor at required index on mouse click

+ 2 - 2
examples/shapes/shapes_bouncing_ball.c

@@ -67,8 +67,8 @@ int main(void)
             // On pause, we draw a blinking message
             // On pause, we draw a blinking message
             if (pause && ((framesCounter/30)%2)) DrawText("PAUSED", 350, 200, 30, GRAY);
             if (pause && ((framesCounter/30)%2)) DrawText("PAUSED", 350, 200, 30, GRAY);
 
 
-            DrawCircle(400.5, 300.5, 50, BLACK);
-            DrawCircle(528.0, 172.0, 26, BLACK);
+            DrawCircle(400.5f, 300.5f, 50.0f, BLACK);
+            DrawCircle(528.0f, 172.0f, 26.0f, BLACK);
 
 
             DrawFPS(10, 10);
             DrawFPS(10, 10);
 
 

+ 1 - 1
examples/shapes/shapes_draw_circle_sector.c

@@ -70,7 +70,7 @@ int main(void)
             GuiSliderBar((Rectangle){ 600, 170, 120, 20}, "Segments", NULL, &segments, 0, 100);
             GuiSliderBar((Rectangle){ 600, 170, 120, 20}, "Segments", NULL, &segments, 0, 100);
             //------------------------------------------------------------------------------
             //------------------------------------------------------------------------------
 
 
-            minSegments = (int)ceilf((endAngle - startAngle) / 90);
+            minSegments = truncf(ceilf((endAngle - startAngle) / 90));
             DrawText(TextFormat("MODE: %s", (segments >= minSegments)? "MANUAL" : "AUTO"), 600, 200, 10, (segments >= minSegments)? MAROON : DARKGRAY);
             DrawText(TextFormat("MODE: %s", (segments >= minSegments)? "MANUAL" : "AUTO"), 600, 200, 10, (segments >= minSegments)? MAROON : DARKGRAY);
 
 
             DrawFPS(10, 10);
             DrawFPS(10, 10);

+ 1 - 1
examples/shapes/shapes_lines_bezier.c

@@ -30,7 +30,7 @@ int main(void)
     Vector2 end = { (float)screenWidth, (float)screenHeight };
     Vector2 end = { (float)screenWidth, (float)screenHeight };
     
     
     Vector2 startControl = { 100, 0 };
     Vector2 startControl = { 100, 0 };
-    Vector2 endControl = { GetScreenWidth() - 100, GetScreenHeight() };
+    Vector2 endControl = { (float)GetScreenWidth() - 100, (float)GetScreenHeight() };
 
 
     SetTargetFPS(60);               // Set our game to run at 60 frames-per-second
     SetTargetFPS(60);               // Set our game to run at 60 frames-per-second
     //--------------------------------------------------------------------------------------
     //--------------------------------------------------------------------------------------

+ 3 - 3
src/external/rprand.h

@@ -186,7 +186,7 @@ int *rprand_load_sequence(unsigned int count, int min, int max)
 {
 {
     int *sequence = NULL;
     int *sequence = NULL;
     
     
-    if (count > (abs(max - min) + 1)) 
+    if (count > (unsigned int)(abs(max - min) + 1)) 
     {
     {
         RPRAND_LOG("WARNING: Sequence count required is greater than range provided\n");
         RPRAND_LOG("WARNING: Sequence count required is greater than range provided\n");
         //count = (max - min);
         //count = (max - min);
@@ -198,9 +198,9 @@ int *rprand_load_sequence(unsigned int count, int min, int max)
     int value = 0;
     int value = 0;
     bool value_is_dup = false;
     bool value_is_dup = false;
 
 
-    for (int i = 0; i < count;)
+    for (unsigned int i = 0; i < count;)
     {
     {
-        value = (rprand_xoshiro()%(abs(max - min) + 1)) + min;
+        value = ((int)rprand_xoshiro()%(abs(max - min) + 1)) + min;
         value_is_dup = false;
         value_is_dup = false;
 
 
         for (int j = 0; j < i; j++)
         for (int j = 0; j < i; j++)

+ 1 - 1
src/rcore.c

@@ -2519,7 +2519,7 @@ bool ExportAutomationEventList(AutomationEventList list, const char *fileName)
 
 
     // Add events data
     // Add events data
     byteCount += sprintf(txtData + byteCount, "c %i\n", list.count);
     byteCount += sprintf(txtData + byteCount, "c %i\n", list.count);
-    for (int i = 0; i < list.count; i++)
+    for (unsigned int i = 0; i < list.count; i++)
     {
     {
         byteCount += snprintf(txtData + byteCount, 256, "e %i %i %i %i %i %i // Event: %s\n", list.events[i].frame, list.events[i].type,
         byteCount += snprintf(txtData + byteCount, 256, "e %i %i %i %i %i %i // Event: %s\n", list.events[i].frame, list.events[i].type,
             list.events[i].params[0], list.events[i].params[1], list.events[i].params[2], list.events[i].params[3], autoEventTypeName[list.events[i].type]);
             list.events[i].params[0], list.events[i].params[1], list.events[i].params[2], list.events[i].params[3], autoEventTypeName[list.events[i].type]);