From addd50467e1cc97b59fe2753aeb3f4d6fccae1c7 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 3 Nov 2024 02:24:01 +0300 Subject: [PATCH] engine: remove FillRGBABlend from RefAPI. FillRGBA now accepts rendermode parameter --- engine/client/cl_game.c | 50 ++++------------------------------ engine/client/cl_gameui.c | 6 ++-- engine/client/keys.c | 4 +-- engine/client/vgui/vgui_draw.c | 2 +- engine/ref_api.h | 4 +-- ref/gl/gl_context.c | 37 ++++--------------------- ref/null/r_context.c | 3 +- ref/soft/r_context.c | 17 ++---------- 8 files changed, 22 insertions(+), 101 deletions(-) diff --git a/engine/client/cl_game.c b/engine/client/cl_game.c index 7b540f84..52ebf7db 100644 --- a/engine/client/cl_game.c +++ b/engine/client/cl_game.c @@ -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 ) { - float _x = x, _y = y, _w = w, _h = h; + float x_ = x, y_ = y, w_ = w, h_ = h; r = bound( 0, r, 255 ); g = bound( 0, g, 255 ); b = bound( 0, b, 255 ); a = bound( 0, a, 255 ); - SPR_AdjustSize( &_x, &_y, &_w, &_h ); + SPR_AdjustSize( &x_, &y_, &w_, &h_ ); -#if 1 - 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 + ref.dllFuncs.FillRGBA( kRenderTransAdd, x_, y_, w_, h_, r, g, b, a ); } /* @@ -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 ) { - float _x = x, _y = y, _w = w, _h = h; + float x_ = x, y_ = y, w_ = w, h_ = h; r = bound( 0, r, 255 ); g = bound( 0, g, 255 ); b = bound( 0, b, 255 ); a = bound( 0, a, 255 ); - SPR_AdjustSize( &_x, &_y, &_w, &_h ); + SPR_AdjustSize( &x_, &y_, &w_, &h_ ); -#if 1 // REFTODO: - 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 + ref.dllFuncs.FillRGBA( kRenderTransTexture, x_, y_, w_, h_, r, g, b, a ); } /* diff --git a/engine/client/cl_gameui.c b/engine/client/cl_gameui.c index 4b4d8945..dd9f0122 100644 --- a/engine/client/cl_gameui.c +++ b/engine/client/cl_gameui.c @@ -679,10 +679,8 @@ static void GAME_EXPORT pfnFillRGBA( int x, int y, int width, int height, int r, g = bound( 0, g, 255 ); b = bound( 0, b, 255 ); a = bound( 0, a, 255 ); - ref.dllFuncs.Color4ub( r, g, b, a ); - ref.dllFuncs.GL_SetRenderMode( kRenderTransTexture ); - ref.dllFuncs.R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, R_GetBuiltinTexture( REF_WHITE_TEXTURE ) ); - ref.dllFuncs.Color4ub( 255, 255, 255, 255 ); + + ref.dllFuncs.FillRGBA( kRenderTransTexture, x, y, width, height, r, g, b, a ); } /* diff --git a/engine/client/keys.c b/engine/client/keys.c index 742eb932..168532b7 100644 --- a/engine/client/keys.c +++ b/engine/client/keys.c @@ -1144,7 +1144,7 @@ static void OSK_DrawSymbolButton( int symb, float x, float y, float width, float h = height * refState.height; 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 ) ) return; @@ -1191,7 +1191,7 @@ void OSK_Draw( void ) return; // 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, Y_STEP * MAX_OSK_LINES * refState.height, 100, 100, 100, 100 ); diff --git a/engine/client/vgui/vgui_draw.c b/engine/client/vgui/vgui_draw.c index 4d7d35a4..462560f3 100644 --- a/engine/client/vgui/vgui_draw.c +++ b/engine/client/vgui/vgui_draw.c @@ -191,7 +191,7 @@ static void GAME_EXPORT VGUI_DrawQuad( const vpoint_t *ul, const vpoint_t *lr ) } 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] ); } } diff --git a/engine/ref_api.h b/engine/ref_api.h index 8e5ec888..19e27e75 100644 --- a/engine/ref_api.h +++ b/engine/ref_api.h @@ -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. // CL_RunLightStyles now accepts lightstyles array. // Removed R_DrawTileClear. +// Removed FillRGBABlend. Now FillRGBA accepts rendermode parameter. #define REF_API_VERSION 9 #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_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 (*FillRGBA)( float x, float y, float w, float h, int r, int g, int b, int 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 + void (*FillRGBA)( int rendermode, float x, float y, float w, float h, byte r, byte g, byte b, byte a ); // in screen space int (*WorldToScreen)( const vec3_t world, vec3_t screen ); // Returns 1 if it's z clipped // screenshot, cubemapshot diff --git a/ref/gl/gl_context.c b/ref/gl/gl_context.c index cb72ac93..d2f2c016 100644 --- a/ref/gl/gl_context.c +++ b/ref/gl/gl_context.c @@ -59,13 +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 ); 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 ); + if( rendermode == kRenderTransAdd ) + pglBlendFunc( GL_SRC_ALPHA, GL_ONE ); + else + pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); + pglColor4ub( r, g, b, a ); pglBegin( GL_QUADS ); pglVertex2f( _x, _y ); @@ -74,33 +77,6 @@ static void CL_FillRGBA( float _x, float _y, float _w, float _h, int r, int g, i 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 ); - 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 ); } @@ -472,7 +448,6 @@ static const ref_interface_t gReffuncs = R_DrawStretchRaw, R_DrawStretchPic, CL_FillRGBA, - CL_FillRGBABlend, R_WorldToScreen, VID_ScreenShot, diff --git a/ref/null/r_context.c b/ref/null/r_context.c index 47bf1ac2..af4f4e97 100644 --- a/ref/null/r_context.c +++ b/ref/null/r_context.c @@ -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_DrawStretchPic = R_DrawStretchPic, .FillRGBA = FillRGBA, - .FillRGBABlend = FillRGBA, .WorldToScreen = WorldToScreen, .VID_ScreenShot = VID_ScreenShot, diff --git a/ref/soft/r_context.c b/ref/soft/r_context.c index a28dc692..acd30abe 100644 --- a/ref/soft/r_context.c +++ b/ref/soft/r_context.c @@ -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); 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 ); 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_DrawStretchPic, CL_FillRGBA, - CL_FillRGBABlend, R_WorldToScreen, VID_ScreenShot,