From f06601091c387a76faae21d4776f84b3a1a22719 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Tue, 1 Jun 2021 22:20:42 -0400
Subject: [PATCH] Fixed a few test app type conversions that Visual Studio
complains about.
---
test/graywin.c | 2 +-
test/testdyngl.c | 8 ++++----
test/testoverlay.c | 16 ++++++++--------
test/testoverlay2.c | 20 ++++++++++----------
test/testsprite.c | 6 +++---
5 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/test/graywin.c b/test/graywin.c
index 4563114..c1f8a5d 100644
--- a/test/graywin.c
+++ b/test/graywin.c
@@ -24,7 +24,7 @@ void DrawBox(SDL_Surface *screen, int X, int Y, int width, int height)
/* Seed the random number generator */
if ( seeded == 0 ) {
- srand(time(NULL));
+ srand((unsigned int) time(NULL));
seeded = 1;
}
diff --git a/test/testdyngl.c b/test/testdyngl.c
index a20bd1a..538b47f 100644
--- a/test/testdyngl.c
+++ b/test/testdyngl.c
@@ -138,9 +138,9 @@ int main(int argc,char *argv[])
for(i=0;i<NB_PIXELS;i++)
{
- pixels[3*i]=rand()%250-125;
- pixels[3*i+1]=rand()%250-125;
- pixels[3*i+2]=rand()%250-125;
+ pixels[3*i]=(GLfloat) (rand()%250-125);
+ pixels[3*i+1]=(GLfloat) (rand()%250-125);
+ pixels[3*i+2]=(GLfloat) (rand()%250-125);
}
f.glViewport(0,0,640,480);
@@ -166,7 +166,7 @@ int main(int argc,char *argv[])
f.glEnable(GL_FOG);
f.glFogf(GL_FOG_START,-500);
f.glFogf(GL_FOG_END,500);
- f.glFogf(GL_FOG_DENSITY,0.005);
+ f.glFogf(GL_FOG_DENSITY,0.005f);
do
{
diff --git a/test/testoverlay.c b/test/testoverlay.c
index da53f9e..823e453 100644
--- a/test/testoverlay.c
+++ b/test/testoverlay.c
@@ -37,11 +37,11 @@ void RGBtoYUV(Uint8 *rgb, int *yuv, int monochrome, int luminance)
if (monochrome)
{
#if 1 /* these are the two formulas that I found on the FourCC site... */
- yuv[0] = 0.299*rgb[0] + 0.587*rgb[1] + 0.114*rgb[2];
+ yuv[0] = (int) (0.299*rgb[0] + 0.587*rgb[1] + 0.114*rgb[2]);
yuv[1] = 128;
yuv[2] = 128;
#else
- yuv[0] = (0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16;
+ yuv[0] = (int) ((0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16);
yuv[1] = 128;
yuv[2] = 128;
#endif
@@ -49,13 +49,13 @@ void RGBtoYUV(Uint8 *rgb, int *yuv, int monochrome, int luminance)
else
{
#if 1 /* these are the two formulas that I found on the FourCC site... */
- yuv[0] = 0.299*rgb[0] + 0.587*rgb[1] + 0.114*rgb[2];
- yuv[1] = (rgb[2]-yuv[0])*0.565 + 128;
- yuv[2] = (rgb[0]-yuv[0])*0.713 + 128;
+ yuv[0] = (int) (0.299*rgb[0] + 0.587*rgb[1] + 0.114*rgb[2]);
+ yuv[1] = (int) ((rgb[2]-yuv[0])*0.565 + 128);
+ yuv[2] = (int) ((rgb[0]-yuv[0])*0.713 + 128);
#else
- yuv[0] = (0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16;
- yuv[1] = 128 - (0.148 * rgb[0]) - (0.291 * rgb[1]) + (0.439 * rgb[2]);
- yuv[2] = 128 + (0.439 * rgb[0]) - (0.368 * rgb[1]) - (0.071 * rgb[2]);
+ yuv[0] = (int) ((0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16);
+ yuv[1] = (int) (128 - (0.148 * rgb[0]) - (0.291 * rgb[1]) + (0.439 * rgb[2]));
+ yuv[2] = (int) (128 + (0.439 * rgb[0]) - (0.368 * rgb[1]) - (0.071 * rgb[2]));
#endif
}
diff --git a/test/testoverlay2.c b/test/testoverlay2.c
index 5f491f2..b93989a 100644
--- a/test/testoverlay2.c
+++ b/test/testoverlay2.c
@@ -60,11 +60,11 @@ void RGBtoYUV(Uint8 *rgb, int *yuv, int monochrome, int luminance)
if (monochrome)
{
#if 1 /* these are the two formulas that I found on the FourCC site... */
- yuv[0] = 0.299*rgb[0] + 0.587*rgb[1] + 0.114*rgb[2];
+ yuv[0] = (int) (0.299*rgb[0] + 0.587*rgb[1] + 0.114*rgb[2]);
yuv[1] = 128;
yuv[2] = 128;
#else
- yuv[0] = (0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16;
+ yuv[0] = (int) ((0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16);
yuv[1] = 128;
yuv[2] = 128;
#endif
@@ -72,13 +72,13 @@ void RGBtoYUV(Uint8 *rgb, int *yuv, int monochrome, int luminance)
else
{
#if 1 /* these are the two formulas that I found on the FourCC site... */
- yuv[0] = 0.299*rgb[0] + 0.587*rgb[1] + 0.114*rgb[2];
- yuv[1] = (rgb[2]-yuv[0])*0.565 + 128;
- yuv[2] = (rgb[0]-yuv[0])*0.713 + 128;
+ yuv[0] = (int) (0.299*rgb[0] + 0.587*rgb[1] + 0.114*rgb[2]);
+ yuv[1] = (int) ((rgb[2]-yuv[0])*0.565 + 128);
+ yuv[2] = (int) ((rgb[0]-yuv[0])*0.713 + 128);
#else
- yuv[0] = (0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16;
- yuv[1] = 128 - (0.148 * rgb[0]) - (0.291 * rgb[1]) + (0.439 * rgb[2]);
- yuv[2] = 128 + (0.439 * rgb[0]) - (0.368 * rgb[1]) - (0.071 * rgb[2]);
+ yuv[0] = (int) ((0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16);
+ yuv[1] = (int) (128 - (0.148 * rgb[0]) - (0.291 * rgb[1]) + (0.439 * rgb[2]));
+ yuv[2] = (int) (128 + (0.439 * rgb[0]) - (0.368 * rgb[1]) - (0.071 * rgb[2]));
#endif
}
@@ -290,7 +290,7 @@ int main(int argc, char **argv)
int resized=0;
int i;
int fps=12;
- int fpsdelay;
+ Uint32 fpsdelay;
int overlay_format=SDL_YUY2_OVERLAY;
int scale=5;
@@ -503,7 +503,7 @@ int main(int argc, char **argv)
/* set the start frame */
i=0;
- fpsdelay=1000/fps;
+ fpsdelay=(Uint32)(1000/fps);
/* Ignore key up events, they don't even get filtered */
SDL_EventState(SDL_KEYUP, SDL_IGNORE);
diff --git a/test/testsprite.c b/test/testsprite.c
index 6d9e0a8..b777dbb 100644
--- a/test/testsprite.c
+++ b/test/testsprite.c
@@ -97,7 +97,7 @@ void MoveSprites(SDL_Surface *screen, Uint32 background)
Uint32 color = SDL_MapRGB (screen->format, 255, 0, 0);
SDL_Rect r;
- r.x = (sin((float)t * 2 * 3.1459) + 1.0) / 2.0 * (screen->w-20);
+ r.x = (Sint16) ((sin((float)t * 2 * 3.1459) + 1.0) / 2.0 * (screen->w-20));
r.y = 0;
r.w = 20;
r.h = screen->h;
@@ -137,7 +137,7 @@ Uint32 FastestFlags(Uint32 flags, int width, int height, int bpp)
/* Direct hardware blitting without double-buffering
causes really bad flickering.
*/
- if ( info->video_mem*1024 > (height*width*bpp/8) ) {
+ if ( info->video_mem*1024 > ((Uint32)(height*width*bpp/8)) ) {
flags |= SDL_DOUBLEBUF;
} else {
flags &= ~SDL_HWSURFACE;
@@ -239,7 +239,7 @@ int main(int argc, char *argv[])
sprite_rects += numsprites;
sprite_w = sprite->w;
sprite_h = sprite->h;
- srand(time(NULL));
+ srand((unsigned int) time(NULL));
for ( i=0; i<numsprites; ++i ) {
positions[i].x = rand()%(screen->w - sprite_w);
positions[i].y = rand()%(screen->h - sprite_h);