From f1f9ed744deec0348600e373e4e657f81761c335 Mon Sep 17 00:00:00 2001 From: OM Date: Sat, 27 May 2023 16:19:31 +0200 Subject: [PATCH] Updates --- code/cgame/tr_types.h | 245 +----------------------- code/client/cl_main.cpp | 33 +++- code/qcommon/cvar.c | 49 +++++ code/qcommon/q_shared.h | 35 ++-- code/qcommon/qcommon.h | 10 +- code/renderercommon/new/tr_public_new.h | 2 - code/renderercommon/new/tr_types_new.h | 50 +++++ code/renderercommon/tr_public.h | 8 + code/renderercommon/tr_types.h | 56 +++++- code/renderergl2/tr_init.c | 4 +- code/sys/sys_local.h | 8 + code/tools/stringify.cpp | 2 +- 12 files changed, 233 insertions(+), 269 deletions(-) create mode 100644 code/renderercommon/new/tr_types_new.h diff --git a/code/cgame/tr_types.h b/code/cgame/tr_types.h index 7da8997e..cf00e30d 100644 --- a/code/cgame/tr_types.h +++ b/code/cgame/tr_types.h @@ -25,247 +25,4 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #pragma once -#define MAX_DLIGHTS 32 // can't be increased, because bit flags are used on surfaces -#define MAX_ENTITIES 1023 // can't be increased without changing drawsurf bit packing -#define MAX_POINTS 32 -#define MAX_SPRITES 1024 - -// refdef flags -#define RDF_NOWORLDMODEL 1 // used for player configuration screen -#define RDF_FULLBRIGHT 2 // fullbright intensity -#define RDF_HYPERSPACE 4 // teleportation effect - -typedef struct - { - float pos[2]; - float size[2]; - } letterloc_t; - -typedef struct fontheader_s - { - int indirection[256]; - letterloc_t locations[256]; - char name[64]; - float height; - float aspectRatio; - void *shader; - int trhandle; // the last renderer handle this font used - } fontheader_t; - -typedef struct { - vec3_t xyz; - float st[2]; - byte modulate[4]; -} polyVert_t; - -typedef struct poly_s { - qhandle_t hShader; - int numVerts; - polyVert_t *verts; -} poly_t; - -typedef enum { - RT_MODEL, - RT_SPRITE, - RT_BEAM, - RT_PORTALSURFACE, // doesn't draw anything, just info for portals - - RT_MAX_REF_ENTITY_TYPE -} refEntityType_t; - -typedef enum { - lensflare = ( 1 << 0 ), - viewlensflare = ( 1 << 1 ), - additive = ( 1 << 2 ) -} dlighttype_t; - -struct tikiFrame_s; -struct dtiki_s; - -typedef struct { - refEntityType_t reType; - - int renderfx; - - qhandle_t hModel; // opaque type outside refresh - qhandle_t hOldModel; - - // most recent data - vec3_t lightingOrigin; // so multi-part models can be lit identically (RF_LIGHTING_ORIGIN) - int parentEntity; - - vec3_t axis[3]; // rotation vectors - qboolean nonNormalizedAxes; // axis are not normalized, i.e. they have scale - float origin[3]; // also used as MODEL_BEAM's "from" - frameInfo_t frameInfo[MAX_FRAMEINFOS]; - float actionWeight; - short wasframe; - float scale; // scale of the thing - - // previous data for frame interpolation - float oldorigin[3]; // also used as MODEL_BEAM's "to" - - // texturing - int skinNum; // inline skin index - qhandle_t customShader; // use one image for the entire thing - - // misc - byte shaderRGBA[4]; // colors used by colorSrc=vertex shaders - float shaderTexCoord[2]; // texture coordinates used by tcMod=vertex modifiers - float shaderTime; // subtracted from refdef time to control effect start times - - int entityNumber; // the real entity number - - byte surfaces[MAX_MODEL_SURFACES]; // the surface state of the entity - float shader_data[ 2 ]; // data passed in from shader manipulation - - int *bone_tag; - vec4_t *bone_quat; - - // renderer use only - struct tikiFrame_s *of, - *nf; - struct dtiki_s *tiki; - int bonestart; - int morphstart; - qboolean hasMorph; - - // extra sprite information - float radius; - float rotation; - -} refEntity_t; - -#define MAX_RENDER_STRINGS 8 -#define MAX_RENDER_STRING_LENGTH 32 - -typedef struct { - int x, y, width, height; - float fov_x, fov_y; - vec3_t vieworg; - vec3_t viewaxis[3]; // transformation matrix - - // time in milliseconds for shader effects and other time dependent rendering issues - int time; - - int rdflags; // RDF_NOWORLDMODEL, etc - - // 1 bits will prevent the associated area from rendering at all - byte areamask[MAX_MAP_AREA_BYTES]; - - // fog stuff - float farplane_distance; - vec3_t farplane_color; - qboolean farplane_cull; - - // sky portal stuff - qboolean sky_portal; - float sky_alpha; - vec3_t sky_origin; - vec3_t sky_axis[ 3 ]; - -} refdef_t; - - -typedef enum { - STEREO_CENTER, - STEREO_LEFT, - STEREO_RIGHT -} stereoFrame_t; - - -/* -** glconfig_t -** -** Contains variables specific to the OpenGL configuration -** being run right now. These are constant once the OpenGL -** subsystem is initialized. -*/ -typedef enum { - TC_NONE, - TC_S3TC, // this is for the GL_S3_s3tc extension. - TC_S3TC_ARB // this is for the GL_EXT_texture_compression_s3tc extension. -} textureCompression_t; - -typedef enum { - GLDRV_ICD, // driver is integrated with window system - // WARNING: there are tests that check for - // > GLDRV_ICD for minidriverness, so this - // should always be the lowest value in this - // enum set - GLDRV_STANDALONE, // driver is a non-3Dfx standalone driver - GLDRV_VOODOO, // driver is a 3Dfx standalone driver - // XreaL BEGIN - GLDRV_DEFAULT, // old OpenGL system - GLDRV_OPENGL3, // new driver system - GLDRV_MESA // crap - // XreaL END -} glDriverType_t; - -typedef enum { - GLHW_GENERIC, // where everthing works the way it should - GLHW_3DFX_2D3D, // Voodoo Banshee or Voodoo3, relevant since if this is - // the hardware type then there can NOT exist a secondary - // display adapter - GLHW_RIVA128, // where you can't interpolate alpha - GLHW_RAGEPRO, // where you can't modulate alpha on alpha textures - GLHW_PERMEDIA2, // where you don't have src*dst - // XreaL BEGIN - GLHW_ATI, // where you don't have proper GLSL support - GLHW_ATI_DX10, // ATI Radeon HD series DX10 hardware - GLHW_NV_DX10 // Geforce 8/9 class DX10 hardware - // XreaL END -} glHardwareType_t; - - -typedef struct { - char renderer_string[ MAX_STRING_CHARS ]; - char vendor_string[ MAX_STRING_CHARS ]; - char version_string[ MAX_STRING_CHARS ]; - char extensions_string[ MAX_STRING_CHARS * 2 ]; - - int maxTextureSize; // queried from GL - int maxActiveTextures; // multitexture ability - - int colorBits, depthBits, stencilBits; - - glDriverType_t driverType; - glHardwareType_t hardwareType; - - qboolean deviceSupportsGamma; - textureCompression_t textureCompression; - qboolean textureEnvAddAvailable; - - int vidWidth, vidHeight; - // aspect is the screen's physical width / height, which may be different - // than scrWidth / scrHeight if the pixels are non-square - // normal screens should be 4/3, but wide aspect monitors may be 16/9 - float windowAspect; - - int displayFrequency; - - // synonymous with "does rendering consume the entire screen?", therefore - // a Voodoo or Voodoo2 will have this set to TRUE, as will a Win32 ICD that - // used CDS. - qboolean isFullscreen; - qboolean stereoEnabled; - qboolean smpActive; // dual processor - int registerCombinerAvailable; - qboolean secondaryColorAvailable; - qboolean VAR; - qboolean fence; - // ioq3 - int numTextureUnits; -} glconfig_t; - -#if !defined _WIN32 - -#define _3DFX_DRIVER_NAME "libMesaVoodooGL.so.3.1" -#define OPENGL_DRIVER_NAME "libGL.so" - -#else - -#define _3DFX_DRIVER_NAME "3dfxvgl" -#define OPENGL_DRIVER_NAME "opengl32" - -#endif // !defined _WIN32 +#include "../renderercommon/tr_types.h" diff --git a/code/client/cl_main.cpp b/code/client/cl_main.cpp index 8f8e6ba8..d5cb4a6a 100644 --- a/code/client/cl_main.cpp +++ b/code/client/cl_main.cpp @@ -2708,7 +2708,10 @@ void CL_RefFS_WriteFile(const char* qpath, const void* buffer, int size) { } char** CL_RefFS_ListFiles(const char* name, const char* extension, int* numfilesfound) { - return FS_ListFiles(path, extension, qtrue, numfilesfound); + return FS_ListFiles(name, extension, qtrue, numfilesfound); +} + +void CL_RefCIN_UploadCinematic(int handle) { } /* @@ -2786,6 +2789,28 @@ void CL_InitRef( void ) { ri.newri.GetCentroidRadiusInternal = TIKI_GetCentroidRadiusInternal; ri.newri.GetFrameInternal = TIKI_GetFrameInternal; + // + // ioq3 stuff + // + ri.Cvar_CheckRange = Cvar_CheckRange; + ri.Cvar_SetDescription = Cvar_SetDescription; + ri.Cvar_VariableIntegerValue = Cvar_VariableIntegerValue; + + ri.CIN_UploadCinematic = CL_RefCIN_UploadCinematic; + ri.CIN_PlayCinematic = CIN_PlayCinematic; + ri.CIN_RunCinematic = CIN_RunCinematic; + ri.CL_WriteAVIVideoFrame = CL_WriteAVIVideoFrame; + + ri.IN_Init = IN_Init; + ri.IN_Shutdown = IN_Shutdown; + ri.IN_Restart = IN_Restart; + ri.ftol = Q_ftol; + + ri.Sys_SetEnv = Sys_SetEnv; + ri.Sys_GLimpSafeInit = Sys_GLimpSafeInit; + ri.Sys_GLimpInit = Sys_GLimpInit; + ri.Sys_LowPhysicalMemory = Sys_LowPhysicalMemory; + #ifdef USE_RENDERER_DLL // su44: load renderer dll cl_renderer = Cvar_Get("cl_renderer", "glom", CVAR_ARCHIVE); @@ -2843,7 +2868,7 @@ void CL_InitRef( void ) { qboolean CL_SetVidMode( int mode ) { qboolean ret; - ret = re.SetMode( mode, &cls.glconfig ); + ret = re.newre.SetMode( mode, &cls.glconfig ); if( cge ) { cge->CG_GetRendererConfig(); @@ -2854,7 +2879,7 @@ qboolean CL_SetVidMode( int mode ) { } void CL_SetFullscreen( qboolean fullscreen ) { - re.SetFullscreen( fullscreen ); + re.newre.SetFullscreen( fullscreen ); if( cge ) { cge->CG_GetRendererConfig(); @@ -2900,7 +2925,7 @@ void CL_TikiInfoCommand_f( void ) { COM_DefaultExtension( modelname, sizeof( modelname ), ".tik" ); hModel = re.RegisterModel( modelname ); - tiki = re.R_Model_GetHandle( hModel ); + tiki = re.newre.R_Model_GetHandle( hModel ); TIKI_ModelInfo( tiki ); } diff --git a/code/qcommon/cvar.c b/code/qcommon/cvar.c index 877c88d3..c655d499 100644 --- a/code/qcommon/cvar.c +++ b/code/qcommon/cvar.c @@ -1027,6 +1027,39 @@ void Cvar_InfoStringBuffer( int bit, char* buff, int buffsize ) { Q_strncpyz(buff,Cvar_InfoString(bit),buffsize); } +/* +===================== +Cvar_CheckRange +===================== +*/ +void Cvar_CheckRange( cvar_t *var, float min, float max, qboolean integral ) +{ + var->validate = qtrue; + var->min = min; + var->max = max; + var->integral = integral; + + // Force an initial range check + Cvar_Set( var->name, var->string ); +} + +/* +===================== +Cvar_SetDescription +===================== +*/ +void Cvar_SetDescription( cvar_t *var, const char *var_description ) +{ + if( var_description && var_description[0] != '\0' ) + { + if( var->description != NULL ) + { + Z_Free( var->description ); + } + var->description = CopyString( var_description ); + } +} + /* ===================== Cvar_Register @@ -1090,6 +1123,22 @@ void Cvar_Update( vmCvar_t *vmCvar ) { vmCvar->integer = cv->integer; } +/* +================== +Cvar_CompleteCvarName +================== +*/ +void Cvar_CompleteCvarName( const char *args, int argNum ) +{ + if( argNum == 2 ) + { + // Skip " " + char *p = Com_SkipTokens( args, 1, " " ); + + if( p > args ) + Field_CompleteCommand( p, qfalse, qtrue ); + } +} /* ============ diff --git a/code/qcommon/q_shared.h b/code/qcommon/q_shared.h index d31196af..c4a4f872 100644 --- a/code/qcommon/q_shared.h +++ b/code/qcommon/q_shared.h @@ -1284,19 +1284,30 @@ default values. #define CVAR_NONEXISTENT 0xFFFFFFFF // Cvar doesn't exist. // nothing outside the Cvar_*() functions should modify these fields! -typedef struct cvar_s { - char *name; - char *string; - char *resetString; // cvar_restart will reset to this value - char *latchedString; // for CVAR_LATCH vars - int flags; +typedef struct cvar_s cvar_t; + +struct cvar_s { + char *name; + char *string; + char *resetString; // cvar_restart will reset to this value + char *latchedString; // for CVAR_LATCH vars + int flags; qboolean modified; // set each time the cvar is changed - int modificationCount; // incremented each time the cvar is changed - float value; // atof( string ) - int integer; // atoi( string ) - struct cvar_s *next; - struct cvar_s *hashNext; -} cvar_t; + int modificationCount; // incremented each time the cvar is changed + float value; // atof( string ) + int integer; // atoi( string ) + qboolean validate; + qboolean integral; + float min; + float max; + char *description; + + cvar_t *next; + cvar_t *prev; + cvar_t *hashNext; + cvar_t *hashPrev; + int hashIndex; +}; #define MAX_CVAR_VALUE_STRING 256 diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h index ce9f383c..9c2f4129 100644 --- a/code/qcommon/qcommon.h +++ b/code/qcommon/qcommon.h @@ -608,10 +608,14 @@ char *Cvar_InfoString_Big( int bit ); // returns an info string containing all the cvars that have the given bit set // in their flags ( CVAR_USERINFO, CVAR_SERVERINFO, CVAR_SYSTEMINFO, etc ) void Cvar_InfoStringBuffer( int bit, char *buff, int buffsize ); +void Cvar_CheckRange( cvar_t *cv, float minVal, float maxVal, qboolean shouldBeIntegral ); +void Cvar_SetDescription( cvar_t *var, const char *var_description ); void Cvar_Restart_f( void ); void Cvar_SaveGameRestart_f( void ); +void Cvar_CompleteCvarName(const char* args, int argNum); + extern int cvar_modifiedFlags; extern qboolean cvar_global_force; // whenever a cvar is modifed, its flags will be OR'd into this, so @@ -1136,7 +1140,7 @@ qboolean SV_GameCommand( void ); // // input interface // -void IN_Init(void); +void IN_Init(void *windowData); void IN_Frame(void); void IN_Shutdown(void); void IN_Restart(void); @@ -1272,7 +1276,9 @@ void Sys_EndStreamedFile(fileHandle_t f); int Sys_StreamedRead(void* buffer, int size, int count, fileHandle_t f); void Sys_StreamSeek(fileHandle_t f, int offset, int origin); -qboolean Sys_LowPhysicalMemory( void ); +qboolean Sys_LowPhysicalMemory(void); + +void Sys_SetEnv(const char* name, const char* value); void SetNormalThreadPriority( void ); void SetBelowNormalThreadPriority( void ); diff --git a/code/renderercommon/new/tr_public_new.h b/code/renderercommon/new/tr_public_new.h index 29203400..3b0493a6 100644 --- a/code/renderercommon/new/tr_public_new.h +++ b/code/renderercommon/new/tr_public_new.h @@ -20,8 +20,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#include "../../cgame/tr_types.h" - #ifdef __cplusplus extern "C" { #endif diff --git a/code/renderercommon/new/tr_types_new.h b/code/renderercommon/new/tr_types_new.h new file mode 100644 index 00000000..c63e046e --- /dev/null +++ b/code/renderercommon/new/tr_types_new.h @@ -0,0 +1,50 @@ +/* +=========================================================================== +Copyright (C) 2023 the OpenMoHAA team + +This file is part of OpenMoHAA source code. + +OpenMoHAA source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +OpenMoHAA source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with OpenMoHAA source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#define MAX_ENTITIES 1023 // can't be increased without changing drawsurf bit packing +#define MAX_POINTS 32 +#define MAX_SPRITES 1024 + +#define RDF_FULLBRIGHT 2 // fullbright intensity + +typedef struct +{ + float pos[2]; + float size[2]; +} letterloc_t; + +typedef struct fontheader_s +{ + int indirection[256]; + letterloc_t locations[256]; + char name[64]; + float height; + float aspectRatio; + void* shader; + int trhandle; // the last renderer handle this font used +} fontheader_t; + +typedef enum { + lensflare = (1 << 0), + viewlensflare = (1 << 1), + additive = (1 << 2) +} dlighttype_t; diff --git a/code/renderercommon/tr_public.h b/code/renderercommon/tr_public.h index f280fce1..7044e1db 100644 --- a/code/renderercommon/tr_public.h +++ b/code/renderercommon/tr_public.h @@ -25,6 +25,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "tr_types.h" #include "new/tr_public_new.h" +#ifdef __cplusplus +extern "C" { +#endif + #define REF_API_VERSION 8 // @@ -197,4 +201,8 @@ typedef refexport_t* (QDECL *GetRefAPI_t) (int apiVersion, refimport_t * rimp); refexport_t*GetRefAPI( int apiVersion, refimport_t *rimp ); #endif +#ifdef __cplusplus +} +#endif + #endif // __TR_PUBLIC_H diff --git a/code/renderercommon/tr_types.h b/code/renderercommon/tr_types.h index 445a6da2..3be5b1ac 100644 --- a/code/renderercommon/tr_types.h +++ b/code/renderercommon/tr_types.h @@ -84,6 +84,9 @@ typedef enum { RT_MAX_REF_ENTITY_TYPE } refEntityType_t; +struct tikiFrame_s; +struct dtiki_s; + typedef struct { refEntityType_t reType; int renderfx; @@ -117,6 +120,34 @@ typedef struct { // extra sprite information float radius; float rotation; + + // + // Non-IOQ3 stuff + // + + int parentEntity; + + frameInfo_t frameInfo[MAX_FRAMEINFOS]; + float actionWeight; + short wasframe; + float scale; // scale of the thing + + qhandle_t hOldModel; + int entityNumber; // the real entity number + + byte surfaces[MAX_MODEL_SURFACES]; // the surface state of the entity + float shader_data[ 2 ]; // data passed in from shader manipulation + + int *bone_tag; + vec4_t *bone_quat; + + // renderer use only + struct tikiFrame_s *of, + *nf; + struct dtiki_s *tiki; + int bonestart; + int morphstart; + qboolean hasMorph; } refEntity_t; @@ -138,7 +169,22 @@ typedef struct { byte areamask[MAX_MAP_AREA_BYTES]; // text messages for deform text shaders - char text[MAX_RENDER_STRINGS][MAX_RENDER_STRING_LENGTH]; + char text[MAX_RENDER_STRINGS][MAX_RENDER_STRING_LENGTH]; + + // + // Non-IOQ3 stuff + // + + // fog stuff + float farplane_distance; + vec3_t farplane_color; + qboolean farplane_cull; + + // sky portal stuff + qboolean sky_portal; + float sky_alpha; + vec3_t sky_origin; + vec3_t sky_axis[3]; } refdef_t; @@ -213,7 +259,13 @@ typedef struct { // used CDS. qboolean isFullscreen; qboolean stereoEnabled; - qboolean smpActive; // UNUSED, present for compatibility + qboolean smpActive; // UNUSED, present for compatibility + int registerCombinerAvailable; + qboolean secondaryColorAvailable; + qboolean VAR; + qboolean fence; } glconfig_t; +#include "new/tr_types_new.h" + #endif // __TR_TYPES_H diff --git a/code/renderergl2/tr_init.c b/code/renderergl2/tr_init.c index 0edfe6be..763be0ff 100644 --- a/code/renderergl2/tr_init.c +++ b/code/renderergl2/tr_init.c @@ -1425,8 +1425,8 @@ void R_Init( void ) { Com_Memset( &backEnd, 0, sizeof( backEnd ) ); Com_Memset( &tess, 0, sizeof( tess ) ); - if(sizeof(glconfig_t) != 11332) - ri.Error( ERR_FATAL, "Mod ABI incompatible: sizeof(glconfig_t) == %u != 11332", (unsigned int) sizeof(glconfig_t)); + //if(sizeof(glconfig_t) != 11332) + // ri.Error( ERR_FATAL, "Mod ABI incompatible: sizeof(glconfig_t) == %u != 11332", (unsigned int) sizeof(glconfig_t)); // Swap_Init(); diff --git a/code/sys/sys_local.h b/code/sys/sys_local.h index 653cd818..31d39cd0 100644 --- a/code/sys/sys_local.h +++ b/code/sys/sys_local.h @@ -23,6 +23,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "../qcommon/q_shared.h" #include "../qcommon/qcommon.h" +#ifdef __cplusplus +extern "C" { +#endif + #ifndef DEDICATED #ifdef USE_LOCAL_HEADERS # include "SDL_version.h" @@ -71,3 +75,7 @@ char *Sys_ParseProtocolUri( const char *uri ); #endif #include "new/sys_local_new.h" + +#ifdef __cplusplus +} +#endif diff --git a/code/tools/stringify.cpp b/code/tools/stringify.cpp index f52c3b2f..e8061eea 100644 --- a/code/tools/stringify.cpp +++ b/code/tools/stringify.cpp @@ -39,7 +39,7 @@ int main(int argc, const char** argv) while (std::getline(ifp, buffer)) { // Strip trailing whitespace from line - const char* end = buffer.c_str() + buffer.length() - 1; + const char* end = buffer.c_str() + buffer.length(); while (end >= buffer.c_str() && isspace(*end)) { end--; }