Skip to content

Commit

Permalink
add RSF_2D and make RegisterShaderFlags_t cummulative
Browse files Browse the repository at this point in the history
  • Loading branch information
illwieckz committed May 13, 2024
1 parent efc6463 commit a9463ea
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/engine/client/cg_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void trap_S_StartBackgroundTrack( const char *intro, const char *loop
void trap_R_LoadWorldMap( const char *mapname );
qhandle_t trap_R_RegisterModel( const char *name );
qhandle_t trap_R_RegisterSkin( const char *name );
qhandle_t trap_R_RegisterShader( const char *name, RegisterShaderFlags_t flags );
qhandle_t trap_R_RegisterShader( const char *name, int flags );

void trap_R_ClearScene();
void trap_R_AddRefEntityToScene( const refEntity_t *re );
Expand Down
2 changes: 1 addition & 1 deletion src/engine/client/cl_cgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,7 @@ void CGameVM::QVMSyscall(int syscallNum, Util::Reader& reader, IPC::Channel& cha

case CG_R_REGISTERSHADER:
IPC::HandleMsg<Render::RegisterShaderMsg>(channel, std::move(reader), [this] (const std::string& name, int flags, int& handle) {
handle = re.RegisterShader(name.c_str(), (RegisterShaderFlags_t) flags);
handle = re.RegisterShader(name.c_str(), flags);
});
break;

Expand Down
2 changes: 1 addition & 1 deletion src/engine/null/null_renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ qhandle_t RE_RegisterSkin( const char *name )
{
return FS_FOpenFileRead( name, nullptr );
}
qhandle_t RE_RegisterShader( const char *, RegisterShaderFlags_t )
qhandle_t RE_RegisterShader( const char *, int )
{
return 1;
}
Expand Down
5 changes: 2 additions & 3 deletions src/engine/renderer/tr_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -3266,12 +3266,11 @@ inline bool checkGLErrors()
====================================================================
*/
qhandle_t RE_RegisterShader( const char *name, RegisterShaderFlags_t flags );
qhandle_t RE_RegisterShader( const char *name, int flags );
qhandle_t RE_RegisterShaderFromImage( const char *name, image_t *image );
bool RE_LoadDynamicShader( const char *shadername, const char *shadertext );

shader_t *R_FindShader( const char *name, shaderType_t type,
RegisterShaderFlags_t flags );
shader_t *R_FindShader( const char *name, shaderType_t type, int flags );
shader_t *R_GetShaderByHandle( qhandle_t hShader );
shader_t *R_FindShaderByName( const char *name );
const char *RE_GetShaderNameFromHandle( qhandle_t shader );
Expand Down
3 changes: 1 addition & 2 deletions src/engine/renderer/tr_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ struct refexport_t
qhandle_t ( *RegisterModel )( const char *name );
//qhandle_t (*RegisterModelAllLODs) (const char *name);
qhandle_t ( *RegisterSkin )( const char *name );
qhandle_t ( *RegisterShader )( const char *name,
RegisterShaderFlags_t flags );
qhandle_t ( *RegisterShader )( const char *name, int flags );
fontInfo_t* ( *RegisterFont )( const char *fontName, int pointSize );
void ( *UnregisterFont )( fontInfo_t *font );
void ( *Glyph )( fontInfo_t *font, const char *str, glyphInfo_t *glyph );
Expand Down
9 changes: 3 additions & 6 deletions src/engine/renderer/tr_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6237,8 +6237,7 @@ the vertex rgba modulate values, as appropriate for misc_model
pre-lit surfaces.
===============
*/
shader_t *R_FindShader( const char *name, shaderType_t type,
RegisterShaderFlags_t flags )
shader_t *R_FindShader( const char *name, shaderType_t type, int flags )
{
char strippedName[ MAX_QPATH ];
char fileName[ MAX_QPATH ];
Expand Down Expand Up @@ -6366,9 +6365,7 @@ shader_t *R_FindShader( const char *name, shaderType_t type,

Log::Debug( "loading '%s' image as shader", fileName );

// choosing filter based on the NOMIP flag seems strange,
// we better introduce RSF_2D.
if( ( bits & RSF_NOMIP ) || ( bits & RSF_FITSCREEN ) )
if( bits & RSF_2D )
{
imageParams_t imageParams = {};
imageParams.bits = bits;
Expand Down Expand Up @@ -6524,7 +6521,7 @@ This should really only be used for explicit shaders, because there is no
way to ask for different implicit lighting modes (vertex, lightmap, etc)
====================
*/
qhandle_t RE_RegisterShader( const char *name, RegisterShaderFlags_t flags )
qhandle_t RE_RegisterShader( const char *name, int flags )
{
shader_t *sh;

Expand Down
11 changes: 6 additions & 5 deletions src/engine/renderer/tr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,12 @@ using glIndex_t = unsigned int;

enum RegisterShaderFlags_t {
RSF_DEFAULT = BIT( 0 ),
RSF_NOMIP = BIT( 1 ),
RSF_FITSCREEN = BIT( 2 ),
RSF_LIGHT_ATTENUATION = BIT( 3 ),
RSF_NOLIGHTSCALE = BIT( 4 ),
RSF_SPRITE = BIT( 5 ),
RSF_2D = BIT( 1 ),
RSF_NOMIP = BIT( 2 ),
RSF_FITSCREEN = BIT( 3 ),
RSF_LIGHT_ATTENUATION = BIT( 4 ),
RSF_NOLIGHTSCALE = BIT( 5 ),
RSF_SPRITE = BIT( 6 ),
};

struct polyVert_t
Expand Down
2 changes: 1 addition & 1 deletion src/shared/client/cg_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ qhandle_t trap_R_RegisterSkin( const char *name )
return handle;
}

qhandle_t trap_R_RegisterShader( const char *name, RegisterShaderFlags_t flags )
qhandle_t trap_R_RegisterShader( const char *name, int flags )
{
int handle;
VM::SendMsg<Render::RegisterShaderMsg>(name, flags, handle);
Expand Down

0 comments on commit a9463ea

Please sign in to comment.