Browse Source

ref_gl: explicitly cast literals to floats

pull/2/head
Alibek Omarov 5 years ago
parent
commit
1218f4aeb6
  1. 4
      ref_gl/gl_backend.c
  2. 36
      ref_gl/gl_beams.c
  3. 4
      ref_gl/gl_decals.c
  4. 13
      ref_gl/gl_rmain.c
  5. 2
      ref_gl/gl_rmath.c
  6. 2
      ref_gl/gl_rpart.c
  7. 8
      ref_gl/gl_rsurf.c
  8. 4
      ref_gl/gl_sprite.c
  9. 10
      ref_gl/gl_studio.c
  10. 4
      ref_gl/gl_warp.c

4
ref_gl/gl_backend.c

@ -737,7 +737,7 @@ void SCR_TimeRefresh_f( void ) @@ -737,7 +737,7 @@ void SCR_TimeRefresh_f( void )
pglDrawBuffer( GL_FRONT );
for( i = 0; i < 128; i++ )
{
gpGlobals->viewangles[1] = i / 128.0 * 360.0f;
gpGlobals->viewangles[1] = i / 128.0f * 360.0f;
R_RenderScene();
}
pglFinish();
@ -748,7 +748,7 @@ void SCR_TimeRefresh_f( void ) @@ -748,7 +748,7 @@ void SCR_TimeRefresh_f( void )
for( i = 0; i < 128; i++ )
{
R_BeginFrame( true );
gpGlobals->viewangles[1] = i / 128.0 * 360.0f;
gpGlobals->viewangles[1] = i / 128.0f * 360.0f;
R_RenderScene();
R_EndFrame();
}

36
ref_gl/gl_beams.c

@ -21,8 +21,10 @@ GNU General Public License for more details. @@ -21,8 +21,10 @@ GNU General Public License for more details.
#include "customentity.h"
#include "cl_tent.h"
#include "pm_local.h"
#include "studio.h"
#ifdef HAVE_TGMATH_H
#include <tgmath.h>
#endif
#define NOISE_DIVISIONS 64 // don't touch - many tripmines cause the crash when it equal 128
@ -64,7 +66,7 @@ static void FracNoise( float *noise, int divs ) @@ -64,7 +66,7 @@ static void FracNoise( float *noise, int divs )
static void SineNoise( float *noise, int divs )
{
float freq = 0;
float step = M_PI / (float)divs;
float step = M_PI_F / (float)divs;
int i;
for( i = 0; i < divs; i++ )
@ -234,7 +236,7 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f @@ -234,7 +236,7 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f
}
else
{
scale *= length * 2.0;
scale *= length * 2.0f;
}
// Iterator to resample noise waveform (it needs to be generated in powers of 2)
@ -272,7 +274,7 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f @@ -272,7 +274,7 @@ static void R_DrawSegs( vec3_t source, vec3_t delta, float width, float scale, f
{
float s, c;
SinCos( fraction * M_PI * length + freq, &s, &c );
SinCos( fraction * M_PI_F * length + freq, &s, &c );
VectorMA( nextSeg.pos, (factor * s), RI.vup, nextSeg.pos );
// rotate the noise along the perpendicluar axis a bit to keep the bolt from looking diagonal
@ -384,8 +386,8 @@ void R_DrawTorus( vec3_t source, vec3_t delta, float width, float scale, float f @@ -384,8 +386,8 @@ void R_DrawTorus( vec3_t source, vec3_t delta, float width, float scale, float f
if( segments > NOISE_DIVISIONS )
segments = NOISE_DIVISIONS;
length = VectorLength( delta ) * 0.01;
if( length < 0.5 ) length = 0.5; // don't lose all of the noise/texture on short beams
length = VectorLength( delta ) * 0.01f;
if( length < 0.5f ) length = 0.5f; // don't lose all of the noise/texture on short beams
div = 1.0f / (segments - 1);
@ -404,7 +406,7 @@ void R_DrawTorus( vec3_t source, vec3_t delta, float width, float scale, float f @@ -404,7 +406,7 @@ void R_DrawTorus( vec3_t source, vec3_t delta, float width, float scale, float f
float s, c;
fraction = i * div;
SinCos( fraction * M_PI2, &s, &c );
SinCos( fraction * M_PI2_F, &s, &c );
point[0] = s * freq * delta[2] + source[0];
point[1] = c * freq * delta[2] + source[1];
@ -419,7 +421,7 @@ void R_DrawTorus( vec3_t source, vec3_t delta, float width, float scale, float f @@ -419,7 +421,7 @@ void R_DrawTorus( vec3_t source, vec3_t delta, float width, float scale, float f
VectorMA( point, factor, RI.vup, point );
// rotate the noise along the perpendicluar axis a bit to keep the bolt from looking diagonal
factor = rgNoise[noiseIndex>>16] * scale * cos( fraction * M_PI * 3 + freq );
factor = rgNoise[noiseIndex>>16] * scale * cos( fraction * M_PI_F * 3 + freq );
VectorMA( point, factor, RI.vright, point );
}
}
@ -499,7 +501,7 @@ void R_DrawDisk( vec3_t source, vec3_t delta, float width, float scale, float fr @@ -499,7 +501,7 @@ void R_DrawDisk( vec3_t source, vec3_t delta, float width, float scale, float fr
TriTexCoord2f( 1.0f, vLast );
TriVertex3fv( point );
SinCos( fraction * M_PI2, &s, &c );
SinCos( fraction * M_PI2_F, &s, &c );
point[0] = s * w + source[0];
point[1] = c * w + source[1];
point[2] = source[2];
@ -547,7 +549,7 @@ void R_DrawCylinder( vec3_t source, vec3_t delta, float width, float scale, floa @@ -547,7 +549,7 @@ void R_DrawCylinder( vec3_t source, vec3_t delta, float width, float scale, floa
float s, c;
fraction = i * div;
SinCos( fraction * M_PI2, &s, &c );
SinCos( fraction * M_PI2_F, &s, &c );
point[0] = s * freq * delta[2] + source[0];
point[1] = c * freq * delta[2] + source[1];
@ -656,11 +658,11 @@ void R_DrawBeamFollow( BEAM *pbeam, float frametime ) @@ -656,11 +658,11 @@ void R_DrawBeamFollow( BEAM *pbeam, float frametime )
VectorMA( delta, pbeam->width, normal, last1 );
VectorMA( delta, -pbeam->width, normal, last2 );
div = 1.0 / pbeam->amplitude;
div = 1.0f / pbeam->amplitude;
fraction = ( pbeam->die - gpGlobals->time ) * div;
vLast = 0.0;
vStep = 1.0;
vLast = 0.0f;
vStep = 1.0f;
while( particles )
{
@ -738,12 +740,12 @@ void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitude, floa @@ -738,12 +740,12 @@ void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitude, floa
return;
VectorClear( screenLast );
segments = segments * M_PI;
segments = segments * M_PI_F;
if( segments > NOISE_DIVISIONS * 8 )
segments = NOISE_DIVISIONS * 8;
length = VectorLength( delta ) * 0.01f * M_PI;
length = VectorLength( delta ) * 0.01f * M_PI_F;
if( length < 0.5f ) length = 0.5f; // Don't lose all of the noise/texture on short beams
div = 1.0f / ( segments - 1 );
@ -789,7 +791,7 @@ void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitude, floa @@ -789,7 +791,7 @@ void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitude, floa
for( i = 0; i < segments + 1; i++ )
{
fraction = i * div;
SinCos( fraction * M_PI2, &x, &y );
SinCos( fraction * M_PI2_F, &x, &y );
VectorMAMAM( x, xaxis, y, yaxis, 1.0f, center, point );
@ -799,7 +801,7 @@ void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitude, floa @@ -799,7 +801,7 @@ void R_DrawRing( vec3_t source, vec3_t delta, float width, float amplitude, floa
// Rotate the noise along the perpendicluar axis a bit to keep the bolt from looking diagonal
factor = rgNoise[(noiseIndex >> 16) & (NOISE_DIVISIONS - 1)] * scale;
factor *= cos( fraction * M_PI * 24 + freq );
factor *= cos( fraction * M_PI_F * 24 + freq );
VectorMA( point, factor, RI.vright, point );
// Transform point into screen space

4
ref_gl/gl_decals.c

@ -406,12 +406,12 @@ static void R_DecalVertsLight( float *v, msurface_t *surf, int vertCount ) @@ -406,12 +406,12 @@ static void R_DecalVertsLight( float *v, msurface_t *surf, int vertCount )
// lightmap texture coordinates
s = DotProduct( v, info->lmvecs[0] ) + info->lmvecs[0][3] - info->lightmapmins[0];
s += surf->light_s * sample_size;
s += sample_size * 0.5;
s += sample_size * 0.5f;
s /= BLOCK_SIZE * sample_size; //fa->texinfo->texture->width;
t = DotProduct( v, info->lmvecs[1] ) + info->lmvecs[1][3] - info->lightmapmins[1];
t += surf->light_t * sample_size;
t += sample_size * 0.5;
t += sample_size * 0.5f;
t /= BLOCK_SIZE * sample_size; //fa->texinfo->texture->height;
v[5] = s;

13
ref_gl/gl_rmain.c

@ -19,6 +19,9 @@ GNU General Public License for more details. @@ -19,6 +19,9 @@ GNU General Public License for more details.
#include "beamdef.h"
#include "particledef.h"
#include "entity_types.h"
#ifdef HAVE_TGMATH_H
#include <tgmath.h>
#endif
#define IsLiquidContents( cnt ) ( cnt == CONTENTS_WATER || cnt == CONTENTS_SLIME || cnt == CONTENTS_LAVA )
@ -340,8 +343,8 @@ void R_SetupFrustum( void ) @@ -340,8 +343,8 @@ void R_SetupFrustum( void )
if( RP_NORMALPASS() && ( ENGINE_GET_PARM( PARM_WATER_LEVEL ) >= 3 ))
{
RI.fov_x = atan( tan( DEG2RAD( RI.fov_x ) / 2 ) * ( 0.97 + sin( gpGlobals->time * 1.5 ) * 0.03 )) * 2 / (M_PI / 180.0);
RI.fov_y = atan( tan( DEG2RAD( RI.fov_y ) / 2 ) * ( 1.03 - sin( gpGlobals->time * 1.5 ) * 0.03 )) * 2 / (M_PI / 180.0);
RI.fov_x = atan( tan( DEG2RAD( RI.fov_x ) / 2 ) * ( 0.97f + sin( gpGlobals->time * 1.5f ) * 0.03f )) * 2 / (M_PI_F / 180.0f);
RI.fov_y = atan( tan( DEG2RAD( RI.fov_y ) / 2 ) * ( 1.03f - sin( gpGlobals->time * 1.5f ) * 0.03f )) * 2 / (M_PI_F / 180.0f);
}
// build the transformation matrix for the given view angles
@ -367,7 +370,7 @@ R_SetupProjectionMatrix @@ -367,7 +370,7 @@ R_SetupProjectionMatrix
*/
static void R_SetupProjectionMatrix( matrix4x4 m )
{
GLdouble xMin, xMax, yMin, yMax, zNear, zFar;
GLfloat xMin, xMax, yMin, yMax, zNear, zFar;
if( RI.drawOrtho )
{
@ -381,10 +384,10 @@ static void R_SetupProjectionMatrix( matrix4x4 m ) @@ -381,10 +384,10 @@ static void R_SetupProjectionMatrix( matrix4x4 m )
zNear = 4.0f;
zFar = max( 256.0f, RI.farClip );
yMax = zNear * tan( RI.fov_y * M_PI / 360.0 );
yMax = zNear * tan( RI.fov_y * M_PI_F / 360.0f );
yMin = -yMax;
xMax = zNear * tan( RI.fov_x * M_PI / 360.0 );
xMax = zNear * tan( RI.fov_x * M_PI_F / 360.0f );
xMin = -xMax;
Matrix4x4_CreateProjection( m, xMax, xMin, yMax, yMin, zNear, zFar );

2
ref_gl/gl_rmath.c

@ -169,7 +169,7 @@ void Matrix4x4_CreateRotate( matrix4x4 out, float angle, float x, float y, float @@ -169,7 +169,7 @@ void Matrix4x4_CreateRotate( matrix4x4 out, float angle, float x, float y, float
y *= len;
z *= len;
angle *= (-M_PI / 180.0f);
angle *= (-M_PI_F / 180.0f);
SinCos( angle, &s, &c );
out[0][0]=x * x + c * (1 - x * x);

2
ref_gl/gl_rpart.c

@ -265,7 +265,7 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers ) @@ -265,7 +265,7 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers )
}
else if( p->type == pt_slowgrav )
{
p->vel[2] = gravity * 0.05;
p->vel[2] = gravity * 0.05f;
}
}

8
ref_gl/gl_rsurf.c

@ -185,13 +185,13 @@ static void SubdividePolygon_r( msurface_t *warpface, int numverts, float *verts @@ -185,13 +185,13 @@ static void SubdividePolygon_r( msurface_t *warpface, int numverts, float *verts
s = DotProduct( verts, warpinfo->lmvecs[0] ) + warpinfo->lmvecs[0][3];
s -= warpinfo->lightmapmins[0];
s += warpface->light_s * sample_size;
s += sample_size * 0.5;
s += sample_size * 0.5f;
s /= BLOCK_SIZE * sample_size; //fa->texinfo->texture->width;
t = DotProduct( verts, warpinfo->lmvecs[1] ) + warpinfo->lmvecs[1][3];
t -= warpinfo->lightmapmins[1];
t += warpface->light_t * sample_size;
t += sample_size * 0.5;
t += sample_size * 0.5f;
t /= BLOCK_SIZE * sample_size; //fa->texinfo->texture->height;
poly->verts[i][5] = s;
@ -808,7 +808,7 @@ void DrawGLPoly( glpoly_t *p, float xScale, float yScale ) @@ -808,7 +808,7 @@ void DrawGLPoly( glpoly_t *p, float xScale, float yScale )
flRate = abs( flConveyorSpeed ) / (float)texture->srcWidth;
flAngle = ( flConveyorSpeed >= 0 ) ? 180 : 0;
SinCos( flAngle * ( M_PI / 180.0f ), &sy, &cy );
SinCos( flAngle * ( M_PI_F / 180.0f ), &sy, &cy );
sOffset = gpGlobals->time * cy * flRate;
tOffset = gpGlobals->time * sy * flRate;
@ -1603,7 +1603,7 @@ void R_DrawBrushModel( cl_entity_t *e ) @@ -1603,7 +1603,7 @@ void R_DrawBrushModel( cl_entity_t *e )
{
if( psurf->plane->type != PLANE_Z && !FBitSet( e->curstate.effects, EF_WATERSIDES ))
continue;
if( mins[2] + 1.0 >= psurf->plane->dist )
if( mins[2] + 1.0f >= psurf->plane->dist )
continue;
}

4
ref_gl/gl_sprite.c

@ -53,7 +53,7 @@ upload a single frame @@ -53,7 +53,7 @@ upload a single frame
*/
static const dframetype_t *R_SpriteLoadFrame( model_t *mod, const void *pin, mspriteframe_t **ppframe, int num )
{
const dspriteframe_t pinframe;
dspriteframe_t pinframe;
mspriteframe_t *pspriteframe;
int gl_texturenum = 0;
char texname[128];
@ -87,7 +87,7 @@ static const dframetype_t *R_SpriteLoadFrame( model_t *mod, const void *pin, msp @@ -87,7 +87,7 @@ static const dframetype_t *R_SpriteLoadFrame( model_t *mod, const void *pin, msp
pspriteframe->gl_texturenum = gl_texturenum;
*ppframe = pspriteframe;
return ( (const byte*)pin + sizeof(dspriteframe_t) + pinframe.width * pinframe.height * bytes );
return ( const dspriteframe_t* )(( const byte* )pin + sizeof( dspriteframe_t ) + pinframe.width * pinframe.height * bytes );
}
/*

10
ref_gl/gl_studio.c

@ -24,6 +24,10 @@ GNU General Public License for more details. @@ -24,6 +24,10 @@ GNU General Public License for more details.
//#include "client.h"
#include "pmtrace.h"
#ifdef HAVE_TGMATH_H
#include <tgmath.h>
#endif
#define EVENT_CLIENT 5000 // less than this value it's a server-side studio events
#define MAX_LOCALLIGHTS 4
@ -641,7 +645,7 @@ float R_StudioEstimateFrame( cl_entity_t *e, mstudioseqdesc_t *pseqdesc ) @@ -641,7 +645,7 @@ float R_StudioEstimateFrame( cl_entity_t *e, mstudioseqdesc_t *pseqdesc )
else dfdt = 0;
if( pseqdesc->numframes <= 1 ) f = 0.0;
else f = (e->curstate.frame * (pseqdesc->numframes - 1)) / 256.0;
else f = (e->curstate.frame * (pseqdesc->numframes - 1)) / 256.0f;
f += dfdt;
@ -3068,7 +3072,7 @@ static void GL_StudioDrawShadow( void ) @@ -3068,7 +3072,7 @@ static void GL_StudioDrawShadow( void )
if( r_shadows.value && g_studio.rendermode != kRenderTransAdd && !FBitSet( RI.currentmodel->flags, STUDIO_AMBIENT_LIGHT ))
{
float color = 1.0 - (tr.blend * 0.5);
float color = 1.0f - (tr.blend * 0.5f);
pglDisable( GL_TEXTURE_2D );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
@ -3250,7 +3254,7 @@ void R_StudioEstimateGait( entity_state_t *pplayer ) @@ -3250,7 +3254,7 @@ void R_StudioEstimateGait( entity_state_t *pplayer )
}
else
{
m_pPlayerInfo->gaityaw = ( atan2( est_velocity[1], est_velocity[0] ) * 180 / M_PI );
m_pPlayerInfo->gaityaw = ( atan2( est_velocity[1], est_velocity[0] ) * 180 / M_PI_F );
if( m_pPlayerInfo->gaityaw > 180.0f ) m_pPlayerInfo->gaityaw = 180.0f;
if( m_pPlayerInfo->gaityaw < -180.0f ) m_pPlayerInfo->gaityaw = -180.0f;
}

4
ref_gl/gl_warp.c

@ -576,9 +576,9 @@ void R_CloudRenderSide( int axis ) @@ -576,9 +576,9 @@ void R_CloudRenderSide( int axis )
p->numverts = 4;
di = SKYCLOUDS_QUALITY;
qi = 1.0 / di;
qi = 1.0f / di;
dj = (axis < 4) ? di * 2 : di; //subdivide vertically more than horizontally on skybox sides
qj = 1.0 / dj;
qj = 1.0f / dj;
for( i = 0; i < di; i++ )
{

Loading…
Cancel
Save