engine: remove FillRGBABlend from RefAPI. FillRGBA now accepts rendermode parameter

This commit is contained in:
Alibek Omarov 2024-11-03 02:24:01 +03:00
parent 6cd2dbf178
commit addd50467e
8 changed files with 22 additions and 101 deletions

View file

@ -1604,35 +1604,16 @@ CL_FillRGBA
*/ */
static void GAME_EXPORT CL_FillRGBA( int x, int y, int w, int h, int r, int g, int b, int a ) static void GAME_EXPORT CL_FillRGBA( int x, int y, int w, int h, int r, int g, int b, int a )
{ {
float _x = x, _y = y, _w = w, _h = h; float x_ = x, y_ = y, w_ = w, h_ = h;
r = bound( 0, r, 255 ); r = bound( 0, r, 255 );
g = bound( 0, g, 255 ); g = bound( 0, g, 255 );
b = bound( 0, b, 255 ); b = bound( 0, b, 255 );
a = bound( 0, a, 255 ); a = bound( 0, a, 255 );
SPR_AdjustSize( &_x, &_y, &_w, &_h ); SPR_AdjustSize( &x_, &y_, &w_, &h_ );
#if 1 ref.dllFuncs.FillRGBA( kRenderTransAdd, x_, y_, w_, h_, r, g, b, a );
ref.dllFuncs.FillRGBA( _x, _y, _w, _h, r, g, b, a );
#else
pglDisable( GL_TEXTURE_2D );
pglEnable( GL_BLEND );
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE );
pglColor4f( r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f );
pglBegin( GL_QUADS );
pglVertex2f( _x, _y );
pglVertex2f( _x + _w, _y );
pglVertex2f( _x + _w, _y + _h );
pglVertex2f( _x, _y + _h );
pglEnd ();
pglColor3f( 1.0f, 1.0f, 1.0f );
pglEnable( GL_TEXTURE_2D );
pglDisable( GL_BLEND );
#endif
} }
/* /*
@ -3111,35 +3092,16 @@ pfnFillRGBABlend
*/ */
static void GAME_EXPORT CL_FillRGBABlend( int x, int y, int w, int h, int r, int g, int b, int a ) static void GAME_EXPORT CL_FillRGBABlend( int x, int y, int w, int h, int r, int g, int b, int a )
{ {
float _x = x, _y = y, _w = w, _h = h; float x_ = x, y_ = y, w_ = w, h_ = h;
r = bound( 0, r, 255 ); r = bound( 0, r, 255 );
g = bound( 0, g, 255 ); g = bound( 0, g, 255 );
b = bound( 0, b, 255 ); b = bound( 0, b, 255 );
a = bound( 0, a, 255 ); a = bound( 0, a, 255 );
SPR_AdjustSize( &_x, &_y, &_w, &_h ); SPR_AdjustSize( &x_, &y_, &w_, &h_ );
#if 1 // REFTODO: ref.dllFuncs.FillRGBA( kRenderTransTexture, x_, y_, w_, h_, r, g, b, a );
ref.dllFuncs.FillRGBABlend( _x, _y, _w, _h, r, g, b, a );
#else
pglDisable( GL_TEXTURE_2D );
pglEnable( GL_BLEND );
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
pglColor4f( r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f );
pglBegin( GL_QUADS );
pglVertex2f( _x, _y );
pglVertex2f( _x + _w, _y );
pglVertex2f( _x + _w, _y + _h );
pglVertex2f( _x, _y + _h );
pglEnd ();
pglColor3f( 1.0f, 1.0f, 1.0f );
pglEnable( GL_TEXTURE_2D );
pglDisable( GL_BLEND );
#endif
} }
/* /*

View file

@ -679,10 +679,8 @@ static void GAME_EXPORT pfnFillRGBA( int x, int y, int width, int height, int r,
g = bound( 0, g, 255 ); g = bound( 0, g, 255 );
b = bound( 0, b, 255 ); b = bound( 0, b, 255 );
a = bound( 0, a, 255 ); a = bound( 0, a, 255 );
ref.dllFuncs.Color4ub( r, g, b, a );
ref.dllFuncs.GL_SetRenderMode( kRenderTransTexture ); ref.dllFuncs.FillRGBA( kRenderTransTexture, x, y, width, height, r, g, b, a );
ref.dllFuncs.R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, R_GetBuiltinTexture( REF_WHITE_TEXTURE ) );
ref.dllFuncs.Color4ub( 255, 255, 255, 255 );
} }
/* /*

View file

@ -1144,7 +1144,7 @@ static void OSK_DrawSymbolButton( int symb, float x, float y, float width, float
h = height * refState.height; h = height * refState.height;
if( symb == osk.curbutton.val ) if( symb == osk.curbutton.val )
ref.dllFuncs.FillRGBABlend( x1, y1, w, h, 255, 160, 0, 100 ); ref.dllFuncs.FillRGBA( kRenderTransTexture, x1, y1, w, h, 255, 160, 0, 100 );
if( !symb || symb == ' ' || (symb >= OSK_TAB && symb < OSK_SPECKEY_LAST ) ) if( !symb || symb == ' ' || (symb >= OSK_TAB && symb < OSK_SPECKEY_LAST ) )
return; return;
@ -1191,7 +1191,7 @@ void OSK_Draw( void )
return; return;
// draw keyboard // draw keyboard
ref.dllFuncs.FillRGBABlend( X_START * refState.width, Y_START * refState.height, ref.dllFuncs.FillRGBA( kRenderTransTexture, X_START * refState.width, Y_START * refState.height,
X_STEP * MAX_OSK_ROWS * refState.width, X_STEP * MAX_OSK_ROWS * refState.width,
Y_STEP * MAX_OSK_LINES * refState.height, 100, 100, 100, 100 ); Y_STEP * MAX_OSK_LINES * refState.height, 100, 100, 100, 100 );

View file

@ -191,7 +191,7 @@ static void GAME_EXPORT VGUI_DrawQuad( const vpoint_t *ul, const vpoint_t *lr )
} }
else else
{ {
ref.dllFuncs.FillRGBABlend( x, y, w, h, vgui.color[0], vgui.color[1], vgui.color[2], vgui.color[3] ); ref.dllFuncs.FillRGBA( kRenderTransTexture, x, y, w, h, vgui.color[0], vgui.color[1], vgui.color[2], vgui.color[3] );
} }
} }

View file

@ -56,6 +56,7 @@ GNU General Public License for more details.
// Removed lightstyle, dynamic and entity light functions. Renderer is supposed to get them through PARM_GET_*_PTR. // Removed lightstyle, dynamic and entity light functions. Renderer is supposed to get them through PARM_GET_*_PTR.
// CL_RunLightStyles now accepts lightstyles array. // CL_RunLightStyles now accepts lightstyles array.
// Removed R_DrawTileClear. // Removed R_DrawTileClear.
// Removed FillRGBABlend. Now FillRGBA accepts rendermode parameter.
#define REF_API_VERSION 9 #define REF_API_VERSION 9
#define TF_SKY (TF_SKYSIDE|TF_NOMIPMAP|TF_ALLOW_NEAREST) #define TF_SKY (TF_SKYSIDE|TF_NOMIPMAP|TF_ALLOW_NEAREST)
@ -516,8 +517,7 @@ typedef struct ref_interface_s
void (*R_Set2DMode)( qboolean enable ); void (*R_Set2DMode)( qboolean enable );
void (*R_DrawStretchRaw)( float x, float y, float w, float h, int cols, int rows, const byte *data, qboolean dirty ); void (*R_DrawStretchRaw)( float x, float y, float w, float h, int cols, int rows, const byte *data, qboolean dirty );
void (*R_DrawStretchPic)( float x, float y, float w, float h, float s1, float t1, float s2, float t2, int texnum ); void (*R_DrawStretchPic)( float x, float y, float w, float h, float s1, float t1, float s2, float t2, int texnum );
void (*FillRGBA)( float x, float y, float w, float h, int r, int g, int b, int a ); // in screen space void (*FillRGBA)( int rendermode, float x, float y, float w, float h, byte r, byte g, byte b, byte a ); // in screen space
void (*FillRGBABlend)( float x, float y, float w, float h, int r, int g, int b, int a ); // in screen space
int (*WorldToScreen)( const vec3_t world, vec3_t screen ); // Returns 1 if it's z clipped int (*WorldToScreen)( const vec3_t world, vec3_t screen ); // Returns 1 if it's z clipped
// screenshot, cubemapshot // screenshot, cubemapshot

View file

@ -59,39 +59,16 @@ CL_FillRGBA
============= =============
*/ */
static void CL_FillRGBA( float _x, float _y, float _w, float _h, int r, int g, int b, int a ) static void CL_FillRGBA( int rendermode, float _x, float _y, float _w, float _h, byte r, byte g, byte b, byte a )
{ {
pglDisable( GL_TEXTURE_2D ); pglDisable( GL_TEXTURE_2D );
pglEnable( GL_BLEND ); pglEnable( GL_BLEND );
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
if( rendermode == kRenderTransAdd )
pglBlendFunc( GL_SRC_ALPHA, GL_ONE ); pglBlendFunc( GL_SRC_ALPHA, GL_ONE );
pglColor4f( r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f ); else
pglBegin( GL_QUADS );
pglVertex2f( _x, _y );
pglVertex2f( _x + _w, _y );
pglVertex2f( _x + _w, _y + _h );
pglVertex2f( _x, _y + _h );
pglEnd ();
pglColor3f( 1.0f, 1.0f, 1.0f );
pglEnable( GL_TEXTURE_2D );
pglDisable( GL_BLEND );
}
/*
=============
pfnFillRGBABlend
=============
*/
static void GAME_EXPORT CL_FillRGBABlend( float _x, float _y, float _w, float _h, int r, int g, int b, int a )
{
pglDisable( GL_TEXTURE_2D );
pglEnable( GL_BLEND );
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
pglColor4f( r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f ); pglColor4ub( r, g, b, a );
pglBegin( GL_QUADS ); pglBegin( GL_QUADS );
pglVertex2f( _x, _y ); pglVertex2f( _x, _y );
@ -100,7 +77,6 @@ static void GAME_EXPORT CL_FillRGBABlend( float _x, float _y, float _w, float _h
pglVertex2f( _x, _y + _h ); pglVertex2f( _x, _y + _h );
pglEnd (); pglEnd ();
pglColor3f( 1.0f, 1.0f, 1.0f );
pglEnable( GL_TEXTURE_2D ); pglEnable( GL_TEXTURE_2D );
pglDisable( GL_BLEND ); pglDisable( GL_BLEND );
} }
@ -472,7 +448,6 @@ static const ref_interface_t gReffuncs =
R_DrawStretchRaw, R_DrawStretchRaw,
R_DrawStretchPic, R_DrawStretchPic,
CL_FillRGBA, CL_FillRGBA,
CL_FillRGBABlend,
R_WorldToScreen, R_WorldToScreen,
VID_ScreenShot, VID_ScreenShot,

View file

@ -115,7 +115,7 @@ static void R_DrawStretchPic( float x, float y, float w, float h, float s1, floa
; ;
} }
static void FillRGBA( float x, float y, float w, float h, int r, int g, int b, int a ) static void FillRGBA( int rendermode, float x, float y, float w, float h, byte r, byte g, byte b, byte a )
{ {
; ;
} }
@ -481,7 +481,6 @@ static const ref_interface_t gReffuncs =
.R_DrawStretchRaw = R_DrawStretchRaw, .R_DrawStretchRaw = R_DrawStretchRaw,
.R_DrawStretchPic = R_DrawStretchPic, .R_DrawStretchPic = R_DrawStretchPic,
.FillRGBA = FillRGBA, .FillRGBA = FillRGBA,
.FillRGBABlend = FillRGBA,
.WorldToScreen = WorldToScreen, .WorldToScreen = WorldToScreen,
.VID_ScreenShot = VID_ScreenShot, .VID_ScreenShot = VID_ScreenShot,

View file

@ -55,25 +55,13 @@ CL_FillRGBA
============= =============
*/ */
static void GAME_EXPORT CL_FillRGBA( float _x, float _y, float _w, float _h, int r, int g, int b, int a ) static void GAME_EXPORT CL_FillRGBA( int rendermode, float _x, float _y, float _w, float _h, byte r, byte g, byte b, byte a )
{ {
vid.rendermode = kRenderTransAdd; vid.rendermode = rendermode;
_TriColor4ub(r,g,b,a); _TriColor4ub(r,g,b,a);
Draw_Fill(_x,_y,_w,_h); Draw_Fill(_x,_y,_w,_h);
} }
/*
=============
pfnFillRGBABlend
=============
*/
static void GAME_EXPORT CL_FillRGBABlend( float _x, float _y, float _w, float _h, int r, int g, int b, int a )
{
vid.rendermode = kRenderTransAlpha;
_TriColor4ub(r,g,b,a);
Draw_Fill(_x,_y,_w,_h);
}
void Mod_UnloadTextures( model_t *mod ); void Mod_UnloadTextures( model_t *mod );
static qboolean GAME_EXPORT Mod_ProcessRenderData( model_t *mod, qboolean create, const byte *buf ) static qboolean GAME_EXPORT Mod_ProcessRenderData( model_t *mod, qboolean create, const byte *buf )
@ -467,7 +455,6 @@ static const ref_interface_t gReffuncs =
R_DrawStretchRaw, R_DrawStretchRaw,
R_DrawStretchPic, R_DrawStretchPic,
CL_FillRGBA, CL_FillRGBA,
CL_FillRGBABlend,
R_WorldToScreen, R_WorldToScreen,
VID_ScreenShot, VID_ScreenShot,