summaryrefslogtreecommitdiffhomepage
path: root/src/core.c
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2020-05-06 19:12:09 +0200
committerraysan5 <[email protected]>2020-05-06 19:12:09 +0200
commitfdad1f023b0f4de982957a3baaa41b0ac2666748 (patch)
tree3701a104fc5e3250e9e81f8ee46ea4cf3deef824 /src/core.c
parent9a1e934621b6098093d709ceb149f1bb995c15cc (diff)
downloadraylib-fdad1f023b0f4de982957a3baaa41b0ac2666748.tar.gz
raylib-fdad1f023b0f4de982957a3baaa41b0ac2666748.zip
Avoid all MSVC compile warnings
Most warning were related to types conversion (casting required) and unsigned/signed types comparisons. Added preprocessor directives (_CRT_SECURE_NO_DEPRECATE; _CRT_NONSTDC_NO_DEPRECATE) to avoid warnings about unsafe functions, those functions are safe while used properly and recommended alternatives are MS only. Some external libraries still generate warnings.
Diffstat (limited to 'src/core.c')
-rw-r--r--src/core.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/core.c b/src/core.c
index 4ce2c04b..b0c38450 100644
--- a/src/core.c
+++ b/src/core.c
@@ -1690,7 +1690,7 @@ int GetFPS(void)
if ((GetTime() - last) > FPS_STEP)
{
- last = GetTime();
+ last = (float)GetTime();
index = (index + 1)%FPS_CAPTURE_FRAMES_COUNT;
average -= history[index];
history[index] = fpsFrame/FPS_CAPTURE_FRAMES_COUNT;
@@ -1752,10 +1752,10 @@ Color ColorFromNormalized(Vector4 normalized)
{
Color result;
- result.r = normalized.x*255.0f;
- result.g = normalized.y*255.0f;
- result.b = normalized.z*255.0f;
- result.a = normalized.w*255.0f;
+ result.r = (unsigned char)(normalized.x*255.0f);
+ result.g = (unsigned char)(normalized.y*255.0f);
+ result.b = (unsigned char)(normalized.z*255.0f);
+ result.a = (unsigned char)(normalized.w*255.0f);
return result;
}
@@ -1821,28 +1821,28 @@ Color ColorFromHSV(Vector3 hsv)
float h = hsv.x, s = hsv.y, v = hsv.z;
// Red channel
- float k = fmod((5.0f + h/60.0f), 6);
+ float k = fmodf((5.0f + h/60.0f), 6);
float t = 4.0f - k;
k = (t < k)? t : k;
k = (k < 1)? k : 1;
k = (k > 0)? k : 0;
- color.r = (v - v*s*k)*255;
+ color.r = (unsigned char)((v - v*s*k)*255.0f);
// Green channel
- k = fmod((3.0f + h/60.0f), 6);
+ k = fmodf((3.0f + h/60.0f), 6);
t = 4.0f - k;
k = (t < k)? t : k;
k = (k < 1)? k : 1;
k = (k > 0)? k : 0;
- color.g = (v - v*s*k)*255;
+ color.g = (unsigned char)((v - v*s*k)*255.0f);
// Blue channel
- k = fmod((1.0f + h/60.0f), 6);
+ k = fmodf((1.0f + h/60.0f), 6);
t = 4.0f - k;
k = (t < k)? t : k;
k = (k < 1)? k : 1;
k = (k > 0)? k : 0;
- color.b = (v - v*s*k)*255;
+ color.b = (unsigned char)((v - v*s*k)*255.0f);
return color;
}
@@ -2023,7 +2023,7 @@ const char *GetFileNameWithoutExt(const char *filePath)
if (filePath != NULL) strcpy(fileName, GetFileName(filePath)); // Get filename with extension
- int len = strlen(fileName);
+ int len = (int)strlen(fileName);
for (int i = 0; (i < len) && (i < MAX_FILENAMEWITHOUTEXT_LENGTH); i++)
{
@@ -2080,7 +2080,7 @@ const char *GetPrevDirectoryPath(const char *dirPath)
{
static char prevDirPath[MAX_FILEPATH_LENGTH];
memset(prevDirPath, 0, MAX_FILEPATH_LENGTH);
- int pathLen = strlen(dirPath);
+ int pathLen = (int)strlen(dirPath);
if (pathLen <= 3) strcpy(prevDirPath, dirPath);
@@ -2886,9 +2886,9 @@ static bool InitGraphicsDevice(int width, int height)
// Get closest video mode to desired CORE.Window.screen.width/CORE.Window.screen.height
for (int i = 0; i < count; i++)
{
- if (modes[i].width >= CORE.Window.screen.width)
+ if ((unsigned int)modes[i].width >= CORE.Window.screen.width)
{
- if (modes[i].height >= CORE.Window.screen.height)
+ if ((unsigned int)modes[i].height >= CORE.Window.screen.height)
{
CORE.Window.display.width = modes[i].width;
CORE.Window.display.height = modes[i].height;