Add support to compile renderergl2 (currently unimplemented)

This commit is contained in:
smallmodel 2024-12-01 19:21:07 +01:00
parent 4ea598d76b
commit 4f699f3b58
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512
14 changed files with 83 additions and 49 deletions

View file

@ -183,13 +183,9 @@ if (NOT BUILD_NO_CLIENT)
add_subdirectory("code/client")
add_subdirectory("code/renderergl1")
#add_subdirectory("code/renderergl2")
add_subdirectory("code/sdl")
#include("code/renderergl2/glsl/shaders.cmake")
#file(GLOB_RECURSE SOURCES_RENDERER "code/sdl/*.c" "code/renderercommon/*.c" "code/renderergl2/*.c" "code/renderergl2/*.cpp")
#list(FILTER SOURCES_RENDERER EXCLUDE REGEX "code/renderergl2/tr_subs.c")
#list(FILTER SOURCES_RENDERER EXCLUDE REGEX "code/renderergl2/tr_model.c")
add_executable(openmohaa "misc/dummy.c")
target_link_libraries(openmohaa PRIVATE syslib)
target_link_libraries(openmohaa PRIVATE omohserver)

View file

@ -3727,6 +3727,7 @@ void CL_FillUIImports(void)
uii.Rend_Scissor = re.Scissor;
uii.Rend_Set2D = re.Set2DWindow;
uii.Rend_SetColor = re.SetColor;
uii.Rend_ImageExists = re.ImageExists;
uii.Cmd_Stuff = Cbuf_AddText;
uii.Cvar_GetString = CvarGetForUI;
@ -5537,7 +5538,7 @@ qboolean UI_IsResourceLoaded(const char *name)
case 107:
return S_IsSoundRegistered(name + 1);
case 110:
return R_ImageExists(name + 1);
return uii.Rend_ImageExists(name + 1);
default:
return qfalse;
}

View file

@ -18,6 +18,7 @@ set(SOURCES_SHARED
"${CMAKE_SOURCE_DIR}/code/qcommon/lz77.cpp"
"${CMAKE_SOURCE_DIR}/code/qcommon/mem_blockalloc.cpp"
"${CMAKE_SOURCE_DIR}/code/qcommon/mem_tempalloc.cpp"
"${CMAKE_SOURCE_DIR}/code/qcommon/puff.c"
"${CMAKE_SOURCE_DIR}/code/qcommon/q_math.c"
"${CMAKE_SOURCE_DIR}/code/qcommon/q_shared.c"
"${CMAKE_SOURCE_DIR}/code/qcommon/script.cpp"

View file

@ -25,6 +25,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "q_shared.h"
#include "qcommon.h"
#ifdef STANDALONE
# include "../client/client.h"
#endif
#define ZONEID 0x7331
#define ZONEID_CONST 0xC057
@ -349,8 +353,13 @@ void Z_Meminfo_f( void )
Com_Printf( "\n%.2f Kbytes in %zu blocks in all memory pools\n", ( float )totalBytes / 1024.0f, totalBlocks );
Com_Printf( "\n%.2f megabytes in 'new' system memory\n", 1.024f );
Com_Printf( "\n%.2f megabytes in texture memory\n", ( float )R_CountTextureMemory() / 1024.0f );
Com_Printf( "\n%.1f megabytes in total allocations\n", ( float )R_CountTextureMemory() + totalBytes - 1 / 1024.0f );
#ifdef STANDALONE
if (re.CountTextureMemory) {
Com_Printf( "\n%.2f megabytes in texture memory\n", ( float )re.CountTextureMemory() / 1024.0f );
Com_Printf( "\n%.1f megabytes in total allocations\n", ( float )re.CountTextureMemory() + totalBytes - 1 / 1024.0f );
}
#endif
}
/*

View file

@ -134,22 +134,9 @@ qboolean R_GetModeInfo( int *width, int *height, float *windowAspect, int mode )
float R_NoiseGet4f( float x, float y, float z, double t );
void R_NoiseInit( void );
image_t *R_FindImageFile(const char* name, qboolean mipmap, qboolean allowPicmip, qboolean force32bit, int glWrapClampModeX, int glWrapClampModeY);
image_t *R_RefreshImageFile(const char* name, qboolean mipmap, qboolean allowPicmip, qboolean force32bit, int glWrapClampModeX, int glWrapClampModeY);
image_t* R_CreateImage(
const char* name,
byte* pic,
int width,
int height,
int numMipmaps,
int iMipmapsAvailable,
qboolean allowPicmip,
qboolean force32bit,
qboolean hasAlpha,
int glCompressMode,
int glWrapClampModeX,
int glWrapClampModeY
);
image_t *R_FindImageFile( const char *name, imgType_t type, imgFlags_t flags );
image_t *R_RefreshImageFile( const char *name, imgType_t type, imgFlags_t flags );
image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgType_t type, imgFlags_t flags, int internalFormat );
void R_IssuePendingRenderCommands( void );
qhandle_t RE_RegisterShaderLightMap( const char *name, int lightmapIndex );

View file

@ -172,6 +172,9 @@ typedef struct {
orientation_t (*TIKI_Orientation)(refEntity_t* model, int tagNum);
qboolean (*TIKI_IsOnGround)(refEntity_t* model, int tagNum, float threshold);
void (*SetFrameNumber)(int frameNumber);
qboolean (*ImageExists)(const char* name);
int (*CountTextureMemory)();
} refexport_t;
//

View file

@ -255,7 +255,7 @@ static void R_LoadLightmaps(gamelump_t* l) {
image[j*4+3] = 255;
}
}
tr.lightmaps[i] = R_CreateImage(va("*lightmap%d", i), image,
tr.lightmaps[i] = R_CreateImageOld(va("*lightmap%d", i), image,
LIGHTMAP_SIZE, LIGHTMAP_SIZE, 0, 1, qfalse, qfalse, qfalse, qfalse, GL_CLAMP, GL_CLAMP);
}

View file

@ -833,7 +833,7 @@ R_CreateImage
This is the only way any image_t are created
================
*/
image_t* R_CreateImage(
image_t* R_CreateImageOld(
const char* name,
byte* pic,
int width,
@ -2477,7 +2477,7 @@ Finds or loads the given image.
Returns NULL if it fails, not a default image.
==============
*/
image_t* R_FindImageFile(const char* name, qboolean mipmap, qboolean allowPicmip, qboolean force32bit, int glWrapClampModeX, int glWrapClampModeY) {
image_t* R_FindImageFileOld(const char* name, qboolean mipmap, qboolean allowPicmip, qboolean force32bit, int glWrapClampModeX, int glWrapClampModeY) {
image_t *image;
int width, height;
byte *pic;
@ -2528,7 +2528,7 @@ image_t* R_FindImageFile(const char* name, qboolean mipmap, qboolean allowPicmip
return NULL;
}
image = R_CreateImage(
image = R_CreateImageOld(
name,
pic,
width,
@ -2556,7 +2556,7 @@ image_t* R_FindImageFile(const char* name, qboolean mipmap, qboolean allowPicmip
R_RefreshImageFile
================
*/
image_t* R_RefreshImageFile(const char* name, qboolean mipmap, qboolean allowPicmip, qboolean force32bit, int glWrapClampModeX, int glWrapClampModeY) {
image_t* R_RefreshImageFileOld(const char* name, qboolean mipmap, qboolean allowPicmip, qboolean force32bit, int glWrapClampModeX, int glWrapClampModeY) {
char imagename[64];
image_t* image;
long hash;
@ -2575,7 +2575,7 @@ image_t* R_RefreshImageFile(const char* name, qboolean mipmap, qboolean allowPic
{
image = image->next;
if (!image) {
return R_FindImageFile(
return R_FindImageFileOld(
imagename,
mipmap,
allowPicmip,
@ -2589,7 +2589,7 @@ image_t* R_RefreshImageFile(const char* name, qboolean mipmap, qboolean allowPic
R_FreeImage(image);
}
return R_FindImageFile(
return R_FindImageFileOld(
imagename,
mipmap,
allowPicmip,
@ -2657,7 +2657,7 @@ static void R_CreateDlightImage( void ) {
data[y][x][3] = 255;
}
}
tr.dlightImage = R_CreateImage("*dlight", (byte *)data, DLIGHT_SIZE, DLIGHT_SIZE, 0, 1, qfalse, qfalse, qfalse, qfalse, GL_CLAMP, GL_CLAMP);
tr.dlightImage = R_CreateImageOld("*dlight", (byte *)data, DLIGHT_SIZE, DLIGHT_SIZE, 0, 1, qfalse, qfalse, qfalse, qfalse, GL_CLAMP, GL_CLAMP);
tr.dlightImage->r_sequence = -1;
}
@ -2694,7 +2694,7 @@ static void R_CreateDefaultImage( void ) {
data[x][DEFAULT_SIZE-1][2] =
data[x][DEFAULT_SIZE-1][3] = 255;
}
tr.defaultImage = R_CreateImage("*default", (byte *)data, DEFAULT_SIZE, DEFAULT_SIZE, 1, 1, qfalse, qfalse, qfalse, qfalse, GL_REPEAT, GL_REPEAT);
tr.defaultImage = R_CreateImageOld("*default", (byte *)data, DEFAULT_SIZE, DEFAULT_SIZE, 1, 1, qfalse, qfalse, qfalse, qfalse, GL_REPEAT, GL_REPEAT);
tr.defaultImage->r_sequence = -1;
}
@ -2713,7 +2713,7 @@ void R_CreateBuiltinImages(void) {
// we use a solid white image instead of disabling texturing
Com_Memset( data, 255, sizeof( data ) );
tr.whiteImage = R_CreateImage("*white", (byte *)data, 8, 8, 0, 1, qfalse, qfalse, qfalse, qfalse, GL_REPEAT, GL_REPEAT);
tr.whiteImage = R_CreateImageOld("*white", (byte *)data, 8, 8, 0, 1, qfalse, qfalse, qfalse, qfalse, GL_REPEAT, GL_REPEAT);
tr.whiteImage->r_sequence = -1;
// with overbright bits active, we need an image which is some fraction of full color,
@ -2732,14 +2732,14 @@ void R_CreateBuiltinImages(void) {
char filename[64];
Com_sprintf(filename, sizeof(filename), "*lightmapD%i", i);
tr.dlightImages[i] = R_CreateImage(filename, lightmap_buffer, LIGHTMAP_SIZE, LIGHTMAP_SIZE, 0, 1, qfalse, qfalse, qfalse, 0, GL_CLAMP, GL_CLAMP);
tr.dlightImages[i] = R_CreateImageOld(filename, lightmap_buffer, LIGHTMAP_SIZE, LIGHTMAP_SIZE, 0, 1, qfalse, qfalse, qfalse, 0, GL_CLAMP, GL_CLAMP);
tr.dlightImages[i]->r_sequence = -1;
}
tr.identityLightImage = R_CreateImage("*identityLight", (byte *)data, 8, 8, 0, 1, qfalse, qfalse, qfalse, qfalse, GL_REPEAT, GL_REPEAT);
tr.identityLightImage = R_CreateImageOld("*identityLight", (byte *)data, 8, 8, 0, 1, qfalse, qfalse, qfalse, qfalse, GL_REPEAT, GL_REPEAT);
tr.identityLightImage->r_sequence = -1;
tr.scratchImage = R_CreateImage("*scratch", (byte*)data, DEFAULT_SIZE, DEFAULT_SIZE, 0, 1, qtrue, qfalse, qfalse, qfalse, GL_CLAMP, GL_CLAMP);
tr.scratchImage = R_CreateImageOld("*scratch", (byte*)data, DEFAULT_SIZE, DEFAULT_SIZE, 0, 1, qtrue, qfalse, qfalse, qfalse, GL_CLAMP, GL_CLAMP);
tr.scratchImage->r_sequence = -1;
R_CreateDlightImage();

View file

@ -1931,5 +1931,8 @@ refexport_t *GetRefAPI ( int apiVersion, refimport_t *rimp ) {
re.TIKI_IsOnGround = RE_TIKI_IsOnGround;
re.SetFrameNumber = RE_SetFrameNumber;
re.ImageExists = R_ImageExists;
re.CountTextureMemory = R_CountTextureMemory;
return &re;
}

View file

@ -1778,6 +1778,27 @@ model_t *R_AllocModel( void );
void R_Init( void );
image_t *R_FindImageFileOld(const char* name, qboolean mipmap, qboolean allowPicmip, qboolean force32bit, int glWrapClampModeX, int glWrapClampModeY);
image_t *R_RefreshImageFileOld(const char* name, qboolean mipmap, qboolean allowPicmip, qboolean force32bit, int glWrapClampModeX, int glWrapClampModeY);
image_t* R_CreateImageOld(
const char* name,
byte* pic,
int width,
int height,
int numMipmaps,
int iMipmapsAvailable,
qboolean allowPicmip,
qboolean force32bit,
qboolean hasAlpha,
int glCompressMode,
int glWrapClampModeX,
int glWrapClampModeY
);
qboolean R_ImageExists(const char* name);
int R_CountTextureMemory();
qboolean R_GetModeInfo( int *width, int *height, float *windowAspect, int mode );
void R_SetColorMappings( void );

View file

@ -243,8 +243,6 @@ typedef struct {
// returned.
refexport_t*GetRefAPI( int apiVersion, refimport_t *rimp );
qboolean R_ImageExists(const char* name);
#ifdef __cplusplus
}
#endif

View file

@ -878,7 +878,7 @@ static qboolean ParseStage(shaderStage_t* stage, char** text, qboolean picmip)
}
else
{
stage->bundle[cntBundle].image[0] = R_FindImageFile(token, !stage->noMipMaps, (!stage->noPicMip ? picmip : 0), stage->force32bit, GL_REPEAT, GL_REPEAT);
stage->bundle[cntBundle].image[0] = R_FindImageFileOld(token, !stage->noMipMaps, (!stage->noPicMip ? picmip : 0), stage->force32bit, GL_REPEAT, GL_REPEAT);
if (!stage->bundle[cntBundle].image[0])
{
ri.Printf(PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name);
@ -937,7 +937,7 @@ static qboolean ParseStage(shaderStage_t* stage, char** text, qboolean picmip)
return qfalse;
}
stage->bundle[cntBundle].image[0] = R_FindImageFile(token, !stage->noMipMaps, (!stage->noPicMip ? picmip : 0), stage->force32bit, clampx, clampy);
stage->bundle[cntBundle].image[0] = R_FindImageFileOld(token, !stage->noMipMaps, (!stage->noPicMip ? picmip : 0), stage->force32bit, clampx, clampy);
if (!stage->bundle[cntBundle].image[0])
{
ri.Printf(PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name);
@ -989,7 +989,7 @@ static qboolean ParseStage(shaderStage_t* stage, char** text, qboolean picmip)
}
num = stage->bundle[cntBundle].numImageAnimations;
if ( num < MAX_IMAGE_ANIMATIONS ) {
stage->bundle[cntBundle].image[num] = R_FindImageFile(token, !stage->noMipMaps, (!stage->noPicMip ? picmip : 0), stage->force32bit, GL_REPEAT, GL_REPEAT );
stage->bundle[cntBundle].image[num] = R_FindImageFileOld(token, !stage->noMipMaps, (!stage->noPicMip ? picmip : 0), stage->force32bit, GL_REPEAT, GL_REPEAT );
if ( !stage->bundle[cntBundle].image[num] )
{
ri.Printf( PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name );
@ -1012,7 +1012,7 @@ static qboolean ParseStage(shaderStage_t* stage, char** text, qboolean picmip)
return qfalse;
}
stage->normalMap = R_FindImageFile(token, !stage->noMipMaps, (!stage->noPicMip ? picmip : 0), stage->force32bit, GL_REPEAT, GL_REPEAT);
stage->normalMap = R_FindImageFileOld(token, !stage->noMipMaps, (!stage->noPicMip ? picmip : 0), stage->force32bit, GL_REPEAT, GL_REPEAT);
if (!stage->normalMap)
{
ri.Printf(PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name);
@ -1981,10 +1981,10 @@ static void ParseSkyParms( char **text ) {
Com_sprintf( pathname, sizeof(pathname), "%s_%s.tga"
, token, suf[i] );
if (!haveClampToEdge) {
shader.sky.outerbox[i] = R_FindImageFile((char*)pathname, qtrue, qtrue, shader_force32bit, GL_CLAMP, GL_CLAMP);
shader.sky.outerbox[i] = R_FindImageFileOld((char*)pathname, qtrue, qtrue, shader_force32bit, GL_CLAMP, GL_CLAMP);
}
else {
shader.sky.outerbox[i] = R_FindImageFile((char*)pathname, qtrue, qtrue, shader_force32bit, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);
shader.sky.outerbox[i] = R_FindImageFileOld((char*)pathname, qtrue, qtrue, shader_force32bit, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);
}
if ( !shader.sky.outerbox[i] ) {
shader.sky.outerbox[i] = tr.defaultImage;
@ -2015,7 +2015,7 @@ static void ParseSkyParms( char **text ) {
for (i=0 ; i<6 ; i++) {
Com_sprintf( pathname, sizeof(pathname), "%s_%s.tga"
, token, suf[i] );
shader.sky.outerbox[i] = R_FindImageFile( ( char * ) pathname, qtrue, qtrue, shader_force32bit, GL_REPEAT, GL_REPEAT );
shader.sky.outerbox[i] = R_FindImageFileOld( ( char * ) pathname, qtrue, qtrue, shader_force32bit, GL_REPEAT, GL_REPEAT );
if ( !shader.sky.innerbox[i] ) {
shader.sky.innerbox[i] = tr.defaultImage;
}
@ -3364,10 +3364,10 @@ shader_t* R_FindShader(const char* name, int lightmapIndex, qboolean mipRawImage
Q_strncpyz( fileName, name, sizeof( fileName ) );
COM_DefaultExtension( fileName, sizeof( fileName ), ".tga" );
if (!haveClampToEdge) {
image = R_FindImageFile(fileName, mipRawImage, picmip, qfalse, wrapx ? GL_REPEAT : GL_CLAMP, wrapy ? GL_REPEAT : GL_CLAMP);
image = R_FindImageFileOld(fileName, mipRawImage, picmip, qfalse, wrapx ? GL_REPEAT : GL_CLAMP, wrapy ? GL_REPEAT : GL_CLAMP);
}
else {
image = R_FindImageFile(fileName, mipRawImage, picmip, qfalse, wrapx ? GL_REPEAT : GL_CLAMP_TO_EDGE, wrapy ? GL_REPEAT : GL_CLAMP_TO_EDGE);
image = R_FindImageFileOld(fileName, mipRawImage, picmip, qfalse, wrapx ? GL_REPEAT : GL_CLAMP_TO_EDGE, wrapy ? GL_REPEAT : GL_CLAMP_TO_EDGE);
}
if ( !image ) {
@ -3517,7 +3517,7 @@ qhandle_t RE_RefreshShaderNoMip(const char* name) {
currentShader = NULL;
if (image) {
sh->unfoggedStages[0]->bundle[0].image[0] = R_RefreshImageFile(
sh->unfoggedStages[0]->bundle[0].image[0] = R_RefreshImageFileOld(
image->imgName,
image->numMipmaps,
image->allowPicmip,

View file

@ -0,0 +1,14 @@
file(GLOB_RECURSE SHADER_GLSL_SRCS "*.glsl")
add_executable(stringify "../tools/stringify.cpp")
foreach (shader ${SHADER_GLSL_SRCS})
get_filename_component(shaderfile ${shader} NAME_WE)
list(APPEND SHADER_SRCS ${CMAKE_CURRENT_BINARY_DIR}/${shaderfile}.c)
set_source_files_properties(${shaderfile}.c PROPERTIES GENERATED TRUE)
add_custom_command(OUTPUT ${shaderfile}.c
DEPENDS stringify ${shader}
COMMAND stringify ${shader} ${CMAKE_CURRENT_BINARY_DIR}/${shaderfile}.c
COMMENT "Generate c source for ${shader}: ${shaderfile}.c"
)
endforeach()

View file

@ -84,6 +84,7 @@ typedef struct uiimport_s {
void( *Rend_DrawBox )( float x, float y, float w, float h );
int( *Rend_GetShaderWidth )( qhandle_t hShader );
int( *Rend_GetShaderHeight )( qhandle_t hShader );
qboolean ( *Rend_ImageExists )( const char* name );
#ifdef __cplusplus
void ( *File_PickFile )( const char *name, Listener *obj, Event& event );
#else