Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 38 additions & 52 deletions src/engine/renderer/tr_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5236,28 +5236,21 @@ const RenderCommand *Poly2dIndexedCommand::ExecuteSelf( ) const

// NERVE - SMF

#if 0 // unused ?
/*
=============
RB_RotatedPic
=============
*/
const void *RB_RotatedPic( const void *data )
const RenderCommand *RotatedPicCommand::ExecuteSelf( ) const
{
const stretchPicCommand_t *cmd;
shader_t *shader;
int numVerts, numIndexes;
float mx, my, cosA, sinA, cw, ch, sw, sh;

cmd = ( const stretchPicCommand_t * ) data;

if ( !backEnd.projection2D )
{
RB_SetGL2D();
}

shader = cmd->shader;

if ( shader != tess.surfaceShader )
{
if ( tess.numIndexes )
Expand Down Expand Up @@ -5287,50 +5280,50 @@ const void *RB_RotatedPic( const void *data )
tess.indexes[ numIndexes + 4 ] = numVerts + 0;
tess.indexes[ numIndexes + 5 ] = numVerts + 1;

mx = cmd->x + ( cmd->w / 2 );
my = cmd->y + ( cmd->h / 2 );
cosA = cos( DEG2RAD( cmd->angle ) );
sinA = sin( DEG2RAD( cmd->angle ) );
cw = cosA * ( cmd->w / 2 );
ch = cosA * ( cmd->h / 2 );
sw = sinA * ( cmd->w / 2 );
sh = sinA * ( cmd->h / 2 );
mx = x + ( w / 2 );
my = y + ( h / 2 );
cosA = cos( DEG2RAD( angle ) );
sinA = sin( DEG2RAD( angle ) );
cw = cosA * ( w / 2 );
ch = cosA * ( h / 2 );
sw = sinA * ( w / 2 );
sh = sinA * ( h / 2 );

tess.verts[ numVerts ].xyz[ 0 ] = mx - cw - sh;
tess.verts[ numVerts ].xyz[ 1 ] = my + sw - ch;
tess.verts[ numVerts ].xyz[ 2 ] = 0.0f;
tess.verts[ numVerts + 0 ].color = backEnd.color2D;

tess.verts[ numVerts ].texCoords[ 0 ] = floatToHalf( cmd->s1 );
tess.verts[ numVerts ].texCoords[ 1 ] = floatToHalf( cmd->t1 );
tess.verts[ numVerts ].texCoords[ 0 ] = floatToHalf( s1 );
tess.verts[ numVerts ].texCoords[ 1 ] = floatToHalf( t1 );

tess.verts[ numVerts + 1 ].xyz[ 0 ] = mx + cw - sh;
tess.verts[ numVerts + 1 ].xyz[ 1 ] = my - sw - ch;
tess.verts[ numVerts + 1 ].xyz[ 2 ] = 0.0f;
tess.verts[ numVerts + 1 ].color = backEnd.color2D;

tess.verts[ numVerts + 1 ].texCoords[ 0 ] = floatToHalf( cmd->s2 );
tess.verts[ numVerts + 1 ].texCoords[ 1 ] = floatToHalf( cmd->t1 );
tess.verts[ numVerts + 1 ].texCoords[ 0 ] = floatToHalf( s2 );
tess.verts[ numVerts + 1 ].texCoords[ 1 ] = floatToHalf( t1 );

tess.verts[ numVerts + 2 ].xyz[ 0 ] = mx + cw + sh;
tess.verts[ numVerts + 2 ].xyz[ 1 ] = my - sw + ch;
tess.verts[ numVerts + 2 ].xyz[ 2 ] = 0.0f;
tess.verts[ numVerts + 2 ].color = backEnd.color2D;

tess.verts[ numVerts + 2 ].texCoords[ 0 ] = floatToHalf( cmd->s2 );
tess.verts[ numVerts + 2 ].texCoords[ 1 ] = floatToHalf( cmd->t2 );
tess.verts[ numVerts + 2 ].texCoords[ 0 ] = floatToHalf( s2 );
tess.verts[ numVerts + 2 ].texCoords[ 1 ] = floatToHalf( t2 );

tess.verts[ numVerts + 3 ].xyz[ 0 ] = mx - cw + sh;
tess.verts[ numVerts + 3 ].xyz[ 1 ] = my + sw + ch;
tess.verts[ numVerts + 3 ].xyz[ 2 ] = 0.0f;
tess.verts[ numVerts + 3 ].color = backEnd.color2D;

tess.verts[ numVerts + 3 ].texCoords[ 0 ] = floatToHalf( cmd->s1 );
tess.verts[ numVerts + 3 ].texCoords[ 1 ] = floatToHalf( cmd->t2 );
tess.verts[ numVerts + 3 ].texCoords[ 0 ] = floatToHalf( s1 );
tess.verts[ numVerts + 3 ].texCoords[ 1 ] = floatToHalf( t2 );

tess.attribsSet |= ATTR_POSITION | ATTR_TEXCOORD | ATTR_COLOR;

return ( const void * )( cmd + 1 );
return this + 1;
}

// -NERVE - SMF
Expand All @@ -5340,21 +5333,15 @@ const void *RB_RotatedPic( const void *data )
RB_StretchPicGradient
==============
*/
const void *RB_StretchPicGradient( const void *data )
const RenderCommand *GradientPicCommand::ExecuteSelf( ) const
{
const stretchPicCommand_t *cmd;
shader_t *shader;
int numVerts, numIndexes;

cmd = ( const stretchPicCommand_t * ) data;

if ( !backEnd.projection2D )
{
RB_SetGL2D();
}

shader = cmd->shader;

if ( shader != tess.surfaceShader )
{
if ( tess.numIndexes )
Expand Down Expand Up @@ -5386,41 +5373,40 @@ const void *RB_StretchPicGradient( const void *data )

tess.verts[ numVerts + 0 ].color = backEnd.color2D;
tess.verts[ numVerts + 1 ].color = backEnd.color2D;
tess.verts[ numVerts + 2 ].color = cmd->gradientColor;
tess.verts[ numVerts + 3 ].color = cmd->gradientColor;
tess.verts[ numVerts + 2 ].color = gradientColor;
tess.verts[ numVerts + 3 ].color = gradientColor;

tess.verts[ numVerts ].xyz[ 0 ] = cmd->x;
tess.verts[ numVerts ].xyz[ 1 ] = cmd->y;
tess.verts[ numVerts ].xyz[ 0 ] = x;
tess.verts[ numVerts ].xyz[ 1 ] = y;
tess.verts[ numVerts ].xyz[ 2 ] = 0.0f;

tess.verts[ numVerts ].texCoords[ 0 ] = floatToHalf( cmd->s1 );
tess.verts[ numVerts ].texCoords[ 1 ] = floatToHalf( cmd->t1 );
tess.verts[ numVerts ].texCoords[ 0 ] = floatToHalf( s1 );
tess.verts[ numVerts ].texCoords[ 1 ] = floatToHalf( t1 );

tess.verts[ numVerts + 1 ].xyz[ 0 ] = cmd->x + cmd->w;
tess.verts[ numVerts + 1 ].xyz[ 1 ] = cmd->y;
tess.verts[ numVerts + 1 ].xyz[ 0 ] = x + w;
tess.verts[ numVerts + 1 ].xyz[ 1 ] = y;
tess.verts[ numVerts + 1 ].xyz[ 2 ] = 0.0f;

tess.verts[ numVerts + 1 ].texCoords[ 0 ] = floatToHalf( cmd->s2 );
tess.verts[ numVerts + 1 ].texCoords[ 1 ] = floatToHalf( cmd->t1 );
tess.verts[ numVerts + 1 ].texCoords[ 0 ] = floatToHalf( s2 );
tess.verts[ numVerts + 1 ].texCoords[ 1 ] = floatToHalf( t1 );

tess.verts[ numVerts + 2 ].xyz[ 0 ] = cmd->x + cmd->w;
tess.verts[ numVerts + 2 ].xyz[ 1 ] = cmd->y + cmd->h;
tess.verts[ numVerts + 2 ].xyz[ 0 ] = x + w;
tess.verts[ numVerts + 2 ].xyz[ 1 ] = y + h;
tess.verts[ numVerts + 2 ].xyz[ 2 ] = 0.0f;

tess.verts[ numVerts + 2 ].texCoords[ 0 ] = floatToHalf( cmd->s2 );
tess.verts[ numVerts + 2 ].texCoords[ 1 ] = floatToHalf( cmd->t2 );
tess.verts[ numVerts + 2 ].texCoords[ 0 ] = floatToHalf( s2 );
tess.verts[ numVerts + 2 ].texCoords[ 1 ] = floatToHalf( t2 );

tess.verts[ numVerts + 3 ].xyz[ 0 ] = cmd->x;
tess.verts[ numVerts + 3 ].xyz[ 1 ] = cmd->y + cmd->h;
tess.verts[ numVerts + 3 ].xyz[ 0 ] = x;
tess.verts[ numVerts + 3 ].xyz[ 1 ] = y + h;
tess.verts[ numVerts + 3 ].xyz[ 2 ] = 0.0f;

tess.verts[ numVerts + 3 ].texCoords[ 0 ] = floatToHalf( cmd->s1 );
tess.verts[ numVerts + 3 ].texCoords[ 1 ] = floatToHalf( cmd->t2 );
tess.verts[ numVerts + 3 ].texCoords[ 0 ] = floatToHalf( s1 );
tess.verts[ numVerts + 3 ].texCoords[ 1 ] = floatToHalf( t2 );

tess.attribsSet |= ATTR_POSITION | ATTR_TEXCOORD | ATTR_COLOR;
return ( const void * )( cmd + 1 );
return this + 1;
}
#endif

/*
=============
Expand Down
8 changes: 4 additions & 4 deletions src/engine/renderer/tr_cmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,9 +691,9 @@ RE_RotatedPic
*/
void RE_RotatedPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader, float angle )
{
StretchPicCommand *cmd;
RotatedPicCommand *cmd;

cmd = R_GetRenderCommand<StretchPicCommand>();
cmd = R_GetRenderCommand<RotatedPicCommand>();

if ( !cmd )
{
Expand Down Expand Up @@ -725,9 +725,9 @@ void RE_StretchPicGradient( float x, float y, float w, float h,
qhandle_t hShader, const Color::Color& gradientColor,
int gradientType )
{
StretchPicCommand *cmd;
GradientPicCommand *cmd;

cmd = R_GetRenderCommand<StretchPicCommand>();
cmd = R_GetRenderCommand<GradientPicCommand>();

if ( !cmd )
{
Expand Down
11 changes: 9 additions & 2 deletions src/engine/renderer/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -3765,10 +3765,17 @@ static inline void halfToFloat( const f16vec4_t in, vec4_t out )
float w, h;
float s1, t1;
float s2, t2;
};
struct RotatedPicCommand : public StretchPicCommand {
const RenderCommand *ExecuteSelf() const;

float angle;
};
struct GradientPicCommand : public StretchPicCommand {
const RenderCommand *ExecuteSelf() const;

Color::Color32Bit gradientColor; // color values 0-255
int gradientType; //----(SA) added
float angle; // NERVE - SMF
int gradientType;
};
struct Poly2dCommand : public RenderCommand {
const RenderCommand *ExecuteSelf() const;
Expand Down