Browse Source

ref:Fix some clgame, world and renderapi usages, import renderapi funcs from engine

pull/2/head
mittorn 6 years ago
parent
commit
437ba6d7a2
  1. 52
      common/ref_api.h
  2. 31
      engine/client/ref_common.c
  3. 13
      engine/common/mod_bmodel.c
  4. 9
      engine/common/mod_local.h
  5. 18
      ref_gl/gl_backend.c
  6. 5
      ref_gl/gl_beams.c
  7. 1
      ref_gl/gl_context.c
  8. 1
      ref_gl/gl_dbghulls.c
  9. 8
      ref_gl/gl_decals.c
  10. 4
      ref_gl/gl_draw.c
  11. 1
      ref_gl/gl_frustum.c
  12. 1
      ref_gl/gl_image.c
  13. 13
      ref_gl/gl_local.h
  14. 1
      ref_gl/gl_refrag.c
  15. 75
      ref_gl/gl_rmain.c
  16. 1
      ref_gl/gl_rmisc.c
  17. 2
      ref_gl/gl_rpart.c
  18. 37
      ref_gl/gl_rsurf.c
  19. 1
      ref_gl/gl_sprite.c
  20. 8
      ref_gl/gl_triapi.c
  21. 4
      ref_gl/gl_vgui.c
  22. 18
      ref_gl/gl_warp.c

52
common/ref_api.h

@ -26,7 +26,6 @@ GNU General Public License for more details. @@ -26,7 +26,6 @@ GNU General Public License for more details.
#include "com_model.h"
#include "studio.h"
#include "r_efx.h"
#include "cvar.h"
#define REF_API_VERSION 1
@ -59,6 +58,12 @@ GNU General Public License for more details. @@ -59,6 +58,12 @@ GNU General Public License for more details.
#define FWORLD_WATERALPHA BIT( 2 )
#define FWORLD_HAS_DELUXEMAP BIT( 3 )
typedef struct
{
msurface_t *surf;
int cull;
} sortedface_t;
typedef struct ref_globals_s
{
qboolean developer;
@ -80,6 +85,14 @@ typedef struct ref_globals_s @@ -80,6 +85,14 @@ typedef struct ref_globals_s
model_t *currentmodel;
float fov_x, fov_y;
// todo: fill this without engine help
// move to local
// translucent sorted array
sortedface_t *draw_surfaces; // used for sorting translucent surfaces
int max_surfaces; // max surfaces per submodel (for all models)
size_t visbytes; // cluster size
} ref_globals_t;
enum
@ -118,8 +131,8 @@ typedef struct ref_api_s @@ -118,8 +131,8 @@ typedef struct ref_api_s
int (*GetViewEntIndex)( void ); // cl.viewentity
// cvar handlers
convar_t *(*pfnRegisterVariable)( const char *szName, const char *szValue, int flags, const char *description );
convar_t *(*pfnGetCvarPointer)( const char *name );
cvar_t *(*pfnRegisterVariable)( const char *szName, const char *szValue, int flags, const char *description );
cvar_t *(*pfnGetCvarPointer)( const char *name );
float (*pfnGetCvarFloat)( const char *szName );
const char *(*pfnGetCvarString)( const char *szName );
@ -208,6 +221,39 @@ typedef struct ref_api_s @@ -208,6 +221,39 @@ typedef struct ref_api_s
void (*GL_DestroyContext)( );
void *(*GL_GetProcAddress)( const char *name );
// renderapi
lightstyle_t* (*GetLightStyle)( int number );
dlight_t* (*GetDynamicLight)( int number );
dlight_t* (*GetEntityLight)( int number );
byte (*LightToTexGamma)( byte color ); // software gamma support
int (*R_FatPVS)( const float *org, float radius, byte *visbuffer, qboolean merge, qboolean fullvis );
void *(*AVI_LoadVideo)( const char *filename, qboolean load_audio );
int (*AVI_GetVideoInfo)( void *Avi, long *xres, long *yres, float *duration );
long (*AVI_GetVideoFrameNumber)( void *Avi, float time );
byte *(*AVI_GetVideoFrame)( void *Avi, long frame );
void (*AVI_FreeVideo)( void *Avi );
int (*AVI_IsActive)( void *Avi );
void (*AVI_StreamSound)( void *Avi, int entnum, float fvol, float attn, float synctime );
int (*SPR_LoadExt)( const char *szPicName, unsigned int texFlags ); // extended version of SPR_Load
const struct ref_overview_s *( *GetOverviewParms )( void );
const char *( *GetFileByIndex )( int fileindex );
void *(*pfnMemAlloc)( size_t cb, const char *filename, const int fileline );
void (*pfnMemFree)( void *mem, const char *filename, const int fileline );
char **(*pfnGetFilesList)( const char *pattern, int *numFiles, int gamedironly );
unsigned int (*pfnFileBufferCRC32)( const void *buffer, const int length );
int (*COM_CompareFileTime)( const char *filename1, const char *filename2, int *iCompare );
void* ( *pfnGetModel )( int modelindex );
float (*pfnTime)( void ); // Sys_DoubleTime
void (*Cvar_Set)( const char *name, const char *value );
void (*S_FadeMusicVolume)( float fadePercent ); // fade background track (0-100 percents)
void (*SetRandomSeed)( long lSeed ); // set custom seed for RANDOM_FLOAT\RANDOM_LONG for predictable random
// client exports
void (*pfnDrawNormalTriangles)( void );
void (*pfnDrawTransparentTriangles)( void );
int (*pfnGetRenderInterface)( int version, render_api_t *renderfuncs, render_interface_t *callback );
int (*CL_GetRenderParm)( int parm, int arg ); // generic
} ref_api_t;
struct mip_s;

31
engine/client/ref_common.c

@ -61,6 +61,37 @@ static void R_UnloadProgs( void ) @@ -61,6 +61,37 @@ static void R_UnloadProgs( void )
Cmd_Unlink( CMD_REFDLL );
}
static int CL_RenderGetParm( int parm, int arg )
{
switch( parm )
{
case PARM_BSP2_SUPPORTED:
#ifdef SUPPORT_BSP2_FORMAT
return 1;
#endif
return 0;
case PARM_SKY_SPHERE:
return FBitSet( world.flags, FWORLD_SKYSPHERE ) && !FBitSet( world.flags, FWORLD_CUSTOM_SKYBOX );
case PARAM_GAMEPAUSED:
return cl.paused;
case PARM_CLIENT_INGAME:
return CL_IsInGame();
case PARM_MAX_ENTITIES:
return clgame.maxEntities;
case PARM_FEATURES:
return host.features;
case PARM_MAP_HAS_DELUXE:
return FBitSet( world.flags, FWORLD_HAS_DELUXEMAP );
case PARM_CLIENT_ACTIVE:
return (cls.state == ca_active);
case PARM_DEDICATED_SERVER:
return (host.type == HOST_DEDICATED);
case PARM_WATER_ALPHA:
return FBitSet( world.flags, FWORLD_WATERALPHA );
}
return 0;
}
static void CL_FillTriAPIFromRef( triangleapi_t *dst, const ref_interface_t *src )
{
dst->version = TRI_API_VERSION;

13
engine/common/mod_bmodel.c

@ -23,7 +23,7 @@ GNU General Public License for more details. @@ -23,7 +23,7 @@ GNU General Public License for more details.
#include "enginefeatures.h"
#include "client.h"
#include "server.h" // LUMP_ error codes
#include "ref_common.h"
typedef struct wadlist_s
{
char wadnames[MAX_MAP_WADS][32];
@ -1472,8 +1472,8 @@ static void Mod_LoadSubmodels( dbspmodel_t *bmod ) @@ -1472,8 +1472,8 @@ static void Mod_LoadSubmodels( dbspmodel_t *bmod )
in = bmod->submodels;
if( bmod->isworld )
world.max_surfaces = 0;
oldmaxfaces = world.max_surfaces;
refState.max_surfaces = 0;
oldmaxfaces = refState.max_surfaces;
for( i = 0; i < bmod->numsubmodels; i++, in++, out++ )
{
@ -1504,10 +1504,10 @@ static void Mod_LoadSubmodels( dbspmodel_t *bmod ) @@ -1504,10 +1504,10 @@ static void Mod_LoadSubmodels( dbspmodel_t *bmod )
}
// these array used to sort translucent faces in bmodels
if( oldmaxfaces > world.max_surfaces )
if( oldmaxfaces > refState.max_surfaces )
{
world.draw_surfaces = (sortedface_t *)Z_Realloc( world.draw_surfaces, oldmaxfaces * sizeof( sortedface_t ));
world.max_surfaces = oldmaxfaces;
refState.draw_surfaces = (sortedface_t *)Z_Realloc( refState.draw_surfaces, oldmaxfaces * sizeof( sortedface_t ));
refState.max_surfaces = oldmaxfaces;
}
}
@ -2352,6 +2352,7 @@ static void Mod_LoadLeafs( dbspmodel_t *bmod ) @@ -2352,6 +2352,7 @@ static void Mod_LoadLeafs( dbspmodel_t *bmod )
visclusters = loadmodel->submodels[0].visleafs;
world.visbytes = (visclusters + 7) >> 3;
world.fatbytes = (visclusters + 31) >> 3;
refState.visbytes = world.visbytes;
}
for( i = 0; i < bmod->numleafs; i++, out++ )

9
engine/common/mod_local.h

@ -82,11 +82,6 @@ typedef struct @@ -82,11 +82,6 @@ typedef struct
uint num_polys;
} hull_model_t;
typedef struct
{
msurface_t *surf;
int cull;
} sortedface_t;
typedef struct world_static_s
{
@ -98,10 +93,6 @@ typedef struct world_static_s @@ -98,10 +93,6 @@ typedef struct world_static_s
char compiler[256]; // map compiler
char generator[256]; // map editor
// translucent sorted array
sortedface_t *draw_surfaces; // used for sorting translucent surfaces
int max_surfaces; // max surfaces per submodel (for all models)
hull_model_t *hull_models;
int num_hull_models;

18
ref_gl/gl_backend.c

@ -27,9 +27,9 @@ R_SpeedsMessage @@ -27,9 +27,9 @@ R_SpeedsMessage
*/
qboolean R_SpeedsMessage( char *out, size_t size )
{
if( clgame.drawFuncs.R_SpeedsMessage != NULL )
if( gRenderIface.R_SpeedsMessage != NULL )
{
if( clgame.drawFuncs.R_SpeedsMessage( out, size ))
if( gRenderIface.R_SpeedsMessage( out, size ))
return true;
// otherwise pass to default handler
}
@ -461,7 +461,7 @@ Create overview script file @@ -461,7 +461,7 @@ Create overview script file
*/
void VID_WriteOverviewScript( void )
{
ref_overview_t *ov = &clgame.overView;
ref_overview_t *ov = &gEngfuncs.GetOverviewParms();
string filename;
file_t *f;
@ -491,8 +491,8 @@ qboolean VID_ScreenShot( const char *filename, int shot_type ) @@ -491,8 +491,8 @@ qboolean VID_ScreenShot( const char *filename, int shot_type )
qboolean result;
r_shot = Mem_Calloc( r_temppool, sizeof( rgbdata_t ));
r_shot->width = (glState.width + 3) & ~3;
r_shot->height = (glState.height + 3) & ~3;
r_shot->width = (gpGlobals->width + 3) & ~3;
r_shot->height = (gpGlobals->height + 3) & ~3;
r_shot->flags = IMAGE_HAS_COLOR;
r_shot->type = PF_RGB_24;
r_shot->size = r_shot->width * r_shot->height * PFDesc[r_shot->type].bpp;
@ -566,7 +566,7 @@ qboolean VID_CubemapShot( const char *base, uint size, const float *vieworg, qbo @@ -566,7 +566,7 @@ qboolean VID_CubemapShot( const char *base, uint size, const float *vieworg, qbo
while( i < size ) i<<=1;
if( i != size ) return false;
if( size > glState.width || size > glState.height )
if( size > gpGlobals->width || size > gpGlobals->height )
return false;
// setup refdef
@ -675,8 +675,8 @@ rebuild_page: @@ -675,8 +675,8 @@ rebuild_page:
end = total * gl_showtextures->value;
if( end > MAX_TEXTURES ) end = MAX_TEXTURES;
w = glState.width / base_w;
h = glState.height / base_h;
w = gpGlobals->width / base_w;
h = gpGlobals->height / base_h;
Con_DrawStringLen( NULL, NULL, &charHeight );
@ -815,7 +815,7 @@ void R_ShowTree_r( mnode_t *node, float x, float y, float scale, int shownodes ) @@ -815,7 +815,7 @@ void R_ShowTree_r( mnode_t *node, float x, float y, float scale, int shownodes )
void R_ShowTree( void )
{
float x = (float)((glState.width - (int)POINT_SIZE) >> 1);
float x = (float)((gpGlobals->width - (int)POINT_SIZE) >> 1);
float y = NODE_INTERVAL_Y(1.0);
if( !WORLDMODEL || !CVAR_TO_BOOL( r_showtree ))

5
ref_gl/gl_beams.c

@ -13,7 +13,6 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -13,7 +13,6 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#include "common.h"
#include "gl_local.h"
#include "r_efx.h"
#include "event_flags.h"
@ -165,7 +164,7 @@ void CL_AddCustomBeam( cl_entity_t *pEnvBeam ) @@ -165,7 +164,7 @@ void CL_AddCustomBeam( cl_entity_t *pEnvBeam )
{
if( tr.draw_list->num_beam_entities >= MAX_VISIBLE_PACKET )
{
Con_Printf( S_ERROR "Too many beams %d!\n", tr.draw_list->num_beam_entities );
gEngfuncs.Con_Printf( S_ERROR "Too many beams %d!\n", tr.draw_list->num_beam_entities );
return;
}
@ -865,7 +864,7 @@ static qboolean R_BeamComputePoint( int beamEnt, vec3_t pt ) @@ -865,7 +864,7 @@ static qboolean R_BeamComputePoint( int beamEnt, vec3_t pt )
if( !ent )
{
Con_DPrintf( S_ERROR "R_BeamComputePoint: invalid entity %i\n", BEAMENT_ENTITY( beamEnt ));
gEngfuncs.Con_DPrintf( S_ERROR "R_BeamComputePoint: invalid entity %i\n", BEAMENT_ENTITY( beamEnt ));
VectorClear( pt );
return false;
}

1
ref_gl/gl_context.c

@ -13,7 +13,6 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -13,7 +13,6 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#include "common.h"
#include "gl_local.h"
#include "gl_export.h"

1
ref_gl/gl_dbghulls.c

@ -15,7 +15,6 @@ GNU General Public License for more details. @@ -15,7 +15,6 @@ GNU General Public License for more details.
#include "gl_local.h"
#include "mod_local.h"
#define list_entry( ptr, type, member ) \
((type *)((char *)(ptr) - (size_t)(&((type *)0)->member)))

8
ref_gl/gl_decals.c

@ -1193,9 +1193,9 @@ int R_CreateDecalList( decallist_t *pList ) @@ -1193,9 +1193,9 @@ int R_CreateDecalList( decallist_t *pList )
total = DecalListAdd( pList, total );
}
if( clgame.drawFuncs.R_CreateStudioDecalList )
if( gRenderIface.R_CreateStudioDecalList )
{
total += clgame.drawFuncs.R_CreateStudioDecalList( pList, total );
total += gRenderIface.R_CreateStudioDecalList( pList, total );
}
}
@ -1277,8 +1277,8 @@ void R_ClearAllDecals( void ) @@ -1277,8 +1277,8 @@ void R_ClearAllDecals( void )
R_DecalUnlink( pdecal );
}
if( clgame.drawFuncs.R_ClearStudioDecals )
if( gRenderIface.R_ClearStudioDecals )
{
clgame.drawFuncs.R_ClearStudioDecals();
gRenderIface.R_ClearStudioDecals();
}
}

4
ref_gl/gl_draw.c

@ -246,10 +246,10 @@ void R_Set2DMode( qboolean enable ) @@ -246,10 +246,10 @@ void R_Set2DMode( qboolean enable )
return;
// set 2D virtual screen size
pglViewport( 0, 0, glState.width, glState.height );
pglViewport( 0, 0, gpGlobals->width, gpGlobals->height );
pglMatrixMode( GL_PROJECTION );
pglLoadIdentity();
pglOrtho( 0, glState.width, glState.height, 0, -99999, 99999 );
pglOrtho( 0, gpGlobals->width, gpGlobals->height, 0, -99999, 99999 );
pglMatrixMode( GL_MODELVIEW );
pglLoadIdentity();

1
ref_gl/gl_frustum.c

@ -13,7 +13,6 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -13,7 +13,6 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#include "common.h"
#include "gl_local.h"
#include "mathlib.h"

1
ref_gl/gl_image.c

@ -13,7 +13,6 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -13,7 +13,6 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#include "common.h"
#include "gl_local.h"
#define TEXTURES_HASH_SIZE (MAX_TEXTURES >> 2)

13
ref_gl/gl_local.h

@ -32,7 +32,9 @@ GNU General Public License for more details. @@ -32,7 +32,9 @@ GNU General Public License for more details.
#include "enginefeatures.h"
#include "com_strings.h"
#include "pm_movevars.h"
#define offsetof(s,m) (size_t)&(((s *)0)->m)
typedef cvar_t convar_t;
void CL_DrawEFX(double, double);
void *CL_ModelHandle(int);
void *GL_GetProcAddress(char *);
@ -46,6 +48,11 @@ extern convar_t cvstub; @@ -46,6 +48,11 @@ extern convar_t cvstub;
#define Cmd_RemoveCommand(...)
#define FS_FreeImage(...)
#define Host_Error(...)
#define ASSERT(x)
#define Assert(x)
#include <stdio.h>
#define Con_Reportf gEngfuncs.Con_DPrintf
#define CVAR_DEFINE( cv, cvname, cvstr, cvflags, cvdesc ) convar_t cv = { cvname, cvstr, cvflags, 0.0f, (void *)CVAR_SENTINEL, cvdesc }
#define CVAR_DEFINE_AUTO( cv, cvstr, cvflags, cvdesc ) convar_t cv = { #cv, cvstr, cvflags, 0.0f, (void *)CVAR_SENTINEL, cvdesc }
@ -54,6 +61,10 @@ extern convar_t cvstub; @@ -54,6 +61,10 @@ extern convar_t cvstub;
#define WORLD (gEngfuncs.GetWorld())
#define WORLDMODEL (gEngfuncs.pfnGetModelByIndex( 1 ))
#define MOVEVARS (gEngfuncs.pfnGetMoveVars())
extern render_interface_t gRenderIface;
// make mod_ref.h?
#define LM_SAMPLE_SIZE 16
extern byte *r_temppool;
@ -245,6 +256,8 @@ typedef struct @@ -245,6 +256,8 @@ typedef struct
// cull info
vec3_t modelorg; // relative to viewpoint
qboolean fCustomSkybox;
} gl_globals_t;
typedef struct

1
ref_gl/gl_refrag.c

@ -14,7 +14,6 @@ GNU General Public License for more details. @@ -14,7 +14,6 @@ GNU General Public License for more details.
*/
#include "gl_local.h"
#include "mod_local.h"
#include "entity_types.h"
#include "studio.h"

75
ref_gl/gl_rmain.c

@ -327,7 +327,7 @@ R_SetupFrustum @@ -327,7 +327,7 @@ R_SetupFrustum
*/
void R_SetupFrustum( void )
{
ref_overview_t *ov = &clgame.overView;
ref_overview_t *ov = gEngfuncs.GetOverviewParms();
if( RP_NORMALPASS() && ( cl.local.waterlevel >= 3 ))
{
@ -362,7 +362,7 @@ static void R_SetupProjectionMatrix( matrix4x4 m ) @@ -362,7 +362,7 @@ static void R_SetupProjectionMatrix( matrix4x4 m )
if( RI.drawOrtho )
{
ref_overview_t *ov = &clgame.overView;
ref_overview_t *ov = gEngfuncs.GetOverviewParms();
Matrix4x4_CreateOrtho( m, ov->xLeft, ov->xRight, ov->yTop, ov->yBottom, ov->zNear, ov->zFar );
return;
}
@ -518,10 +518,10 @@ void R_SetupGL( qboolean set_gl_state ) @@ -518,10 +518,10 @@ void R_SetupGL( qboolean set_gl_state )
int x, x2, y, y2;
// set up viewport (main, playersetup)
x = floor( RI.viewport[0] * glState.width / glState.width );
x2 = ceil(( RI.viewport[0] + RI.viewport[2] ) * glState.width / glState.width );
y = floor( glState.height - RI.viewport[1] * glState.height / glState.height );
y2 = ceil( glState.height - ( RI.viewport[1] + RI.viewport[3] ) * glState.height / glState.height );
x = floor( RI.viewport[0] * gpGlobals->width / gpGlobals->width );
x2 = ceil(( RI.viewport[0] + RI.viewport[2] ) * gpGlobals->width / gpGlobals->width );
y = floor( gpGlobals->height - RI.viewport[1] * gpGlobals->height / gpGlobals->height );
y2 = ceil( gpGlobals->height - ( RI.viewport[1] + RI.viewport[3] ) * gpGlobals->height / gpGlobals->height );
pglViewport( x, y2, x2 - x, y - y2 );
}
@ -858,7 +858,7 @@ void R_DrawEntitiesOnList( void ) @@ -858,7 +858,7 @@ void R_DrawEntitiesOnList( void )
GL_CheckForErrors();
if( RI.drawWorld )
clgame.dllFuncs.pfnDrawNormalTriangles();
gEngfuncs.pfnDrawNormalTriangles();
GL_CheckForErrors();
@ -902,7 +902,7 @@ void R_DrawEntitiesOnList( void ) @@ -902,7 +902,7 @@ void R_DrawEntitiesOnList( void )
if( RI.drawWorld )
{
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
clgame.dllFuncs.pfnDrawTransparentTriangles ();
gEngfuncs.pfnDrawTransparentTriangles ();
}
GL_CheckForErrors();
@ -1109,11 +1109,11 @@ void R_RenderFrame( const ref_viewpass_t *rvp ) @@ -1109,11 +1109,11 @@ void R_RenderFrame( const ref_viewpass_t *rvp )
}
// completely override rendering
if( clgame.drawFuncs.GL_RenderFrame != NULL )
if( gRenderIface.GL_RenderFrame != NULL )
{
tr.fCustomRendering = true;
if( clgame.drawFuncs.GL_RenderFrame( rvp ))
if( gRenderIface.GL_RenderFrame( rvp ))
{
R_GatherPlayerLight();
tr.realframecount++;
@ -1204,11 +1204,6 @@ static int GL_RenderGetParm( int parm, int arg ) @@ -1204,11 +1204,6 @@ static int GL_RenderGetParm( int parm, int arg )
case PARM_TEX_DEPTH:
glt = R_GetTexture( arg );
return glt->depth;
case PARM_BSP2_SUPPORTED:
#ifdef SUPPORT_BSP2_FORMAT
return 1;
#endif
return 0;
case PARM_TEX_SKYBOX:
Assert( arg >= 0 && arg < 6 );
return tr.skyboxTextures[arg];
@ -1217,22 +1212,14 @@ static int GL_RenderGetParm( int parm, int arg ) @@ -1217,22 +1212,14 @@ static int GL_RenderGetParm( int parm, int arg )
case PARM_TEX_LIGHTMAP:
arg = bound( 0, arg, MAX_LIGHTMAPS - 1 );
return tr.lightmapTextures[arg];
case PARM_SKY_SPHERE:
return FBitSet( WORLDMODEL->flags, FWORLD_SKYSPHERE ) && !FBitSet( WORLDMODEL->flags, FWORLD_CUSTOM_SKYBOX );
case PARAM_GAMEPAUSED:
return cl.paused;
case PARM_WIDESCREEN:
return glState.wideScreen;
return gpGlobals->wideScreen;
case PARM_FULLSCREEN:
return glState.fullScreen;
return gpGlobals->fullScreen;
case PARM_SCREEN_WIDTH:
return glState.width;
return gpGlobals->width;
case PARM_SCREEN_HEIGHT:
return glState.height;
case PARM_CLIENT_INGAME:
return CL_IsInGame();
case PARM_MAX_ENTITIES:
return clgame.maxEntities;
return gpGlobals->height;
case PARM_TEX_TARGET:
glt = R_GetTexture( arg );
return glt->target;
@ -1249,16 +1236,10 @@ static int GL_RenderGetParm( int parm, int arg ) @@ -1249,16 +1236,10 @@ static int GL_RenderGetParm( int parm, int arg )
case PARM_LIGHTSTYLEVALUE:
arg = bound( 0, arg, MAX_LIGHTSTYLES - 1 );
return tr.lightstylevalue[arg];
case PARM_MAP_HAS_DELUXE:
return FBitSet( WORLDMODEL->flags, FWORLD_HAS_DELUXEMAP );
case PARM_MAX_IMAGE_UNITS:
return GL_MaxTextureUnits();
case PARM_CLIENT_ACTIVE:
return (cls.state == ca_active);
case PARM_REBUILD_GAMMA:
return glConfig.softwareGammaUpdate;
case PARM_DEDICATED_SERVER:
return (host.type == HOST_DEDICATED);
case PARM_SURF_SAMPLESIZE:
if( arg >= 0 && arg < WORLDMODEL->numsurfaces )
return gEngfuncs.Mod_SampleSizeForFace( &WORLDMODEL->surfaces[arg] );
@ -1269,8 +1250,10 @@ static int GL_RenderGetParm( int parm, int arg ) @@ -1269,8 +1250,10 @@ static int GL_RenderGetParm( int parm, int arg )
return glConfig.wrapper;
case PARM_STENCIL_ACTIVE:
return glState.stencilEnabled;
case PARM_WATER_ALPHA:
return FBitSet( WORLDMODEL->flags, FWORLD_WATERALPHA );
case PARM_SKY_SPHERE:
return gEngfuncs.CL_GetRenderParm( parm, arg ) && !tr.fCustomSkybox;
default:
return gEngfuncs.CL_GetRenderParm( parm, arg );
}
return 0;
}
@ -1358,22 +1341,16 @@ Initialize client external rendering @@ -1358,22 +1341,16 @@ Initialize client external rendering
qboolean R_InitRenderAPI( void )
{
// make sure what render functions is cleared
memset( &clgame.drawFuncs, 0, sizeof( clgame.drawFuncs ));
memset( &gRenderIface, 0, sizeof( gRenderIface ));
if( clgame.dllFuncs.pfnGetRenderInterface )
if( gEngfuncs.pfnGetRenderInterface( CL_RENDER_INTERFACE_VERSION, &gRenderAPI, &gRenderIface ))
{
if( clgame.dllFuncs.pfnGetRenderInterface( CL_RENDER_INTERFACE_VERSION, &gRenderAPI, &clgame.drawFuncs ))
{
Con_Reportf( "CL_LoadProgs: ^2initailized extended RenderAPI ^7ver. %i\n", CL_RENDER_INTERFACE_VERSION );
return true;
}
// make sure what render functions is cleared
memset( &clgame.drawFuncs, 0, sizeof( clgame.drawFuncs ));
return false; // just tell user about problems
Con_Reportf( "CL_LoadProgs: ^2initailized extended RenderAPI ^7ver. %i\n", CL_RENDER_INTERFACE_VERSION );
return true;
}
// render interface is missed
return true;
// make sure what render functions is cleared
memset( &gRenderIface, 0, sizeof( gRenderIface ));
return false; // just tell user about problems
}

1
ref_gl/gl_rmisc.c

@ -14,7 +14,6 @@ GNU General Public License for more details. @@ -14,7 +14,6 @@ GNU General Public License for more details.
*/
#include "gl_local.h"
#include "mod_local.h"
#include "shake.h"
#include "screenfade.h"
#include "cdll_int.h"

2
ref_gl/gl_rpart.c

@ -346,7 +346,7 @@ void CL_DrawParticlesExternal( const ref_viewpass_t *rvp, qboolean trans_pass, f @@ -346,7 +346,7 @@ void CL_DrawParticlesExternal( const ref_viewpass_t *rvp, qboolean trans_pass, f
R_SetupGL( false ); // don't touch GL-states
// setup PVS for frame
memcpy( RI.visbytes, tr.visbytes, WORLDMODEL->visbytes );
memcpy( RI.visbytes, tr.visbytes, gpGlobals->visbytes );
tr.frametime = frametime;
CL_DrawEFX( frametime, trans_pass );

37
ref_gl/gl_rsurf.c

@ -14,7 +14,6 @@ GNU General Public License for more details. @@ -14,7 +14,6 @@ GNU General Public License for more details.
*/
#include "gl_local.h"
#include "mod_local.h"
#include "mathlib.h"
typedef struct
@ -45,16 +44,16 @@ static void R_DrawVBO( qboolean drawlightmaps, qboolean drawtextures ); @@ -45,16 +44,16 @@ static void R_DrawVBO( qboolean drawlightmaps, qboolean drawtextures );
byte *Mod_GetCurrentVis( void )
{
if( clgame.drawFuncs.Mod_GetCurrentVis && tr.fCustomRendering )
return clgame.drawFuncs.Mod_GetCurrentVis();
if( gRenderIface.Mod_GetCurrentVis && tr.fCustomRendering )
return gRenderIface.Mod_GetCurrentVis();
return RI.visbytes;
}
void Mod_SetOrthoBounds( float *mins, float *maxs )
{
if( clgame.drawFuncs.GL_OrthoBounds )
if( gRenderIface.GL_OrthoBounds )
{
clgame.drawFuncs.GL_OrthoBounds( mins, maxs );
gRenderIface.GL_OrthoBounds( mins, maxs );
}
Vector2Average( maxs, mins, world_orthocenter );
@ -1270,7 +1269,7 @@ void R_DrawTextureChains( void ) @@ -1270,7 +1269,7 @@ void R_DrawTextureChains( void )
RI.currententity = gEngfuncs.GetEntityByIndex( 0 );
RI.currentmodel = RI.currententity->model;
if( FBitSet( WORLDMODEL->flags, FWORLD_SKYSPHERE ) && !FBitSet( WORLDMODEL->flags, FWORLD_CUSTOM_SKYBOX ))
if( gEngfuncs.CL)
{
pglDisable( GL_TEXTURE_2D );
pglColor3f( 1.0f, 1.0f, 1.0f );
@ -1280,7 +1279,7 @@ void R_DrawTextureChains( void ) @@ -1280,7 +1279,7 @@ void R_DrawTextureChains( void )
for( s = skychain; s != NULL; s = s->texturechain )
R_AddSkyBoxSurface( s );
if( FBitSet( WORLDMODEL->flags, FWORLD_SKYSPHERE ) && !FBitSet( WORLDMODEL->flags, FWORLD_CUSTOM_SKYBOX ))
if( FBitSet( WORLDMODEL->flags, FWORLD_SKYSPHERE ) && !tr.fCustomSkybox )
{
pglEnable( GL_TEXTURE_2D );
if( skychain )
@ -1608,22 +1607,22 @@ void R_DrawBrushModel( cl_entity_t *e ) @@ -1608,22 +1607,22 @@ void R_DrawBrushModel( cl_entity_t *e )
continue;
}
if( num_sorted < WORLDMODEL->max_surfaces )
if( num_sorted < gpGlobals->max_surfaces )
{
WORLDMODEL->draw_surfaces[num_sorted].surf = psurf;
WORLDMODEL->draw_surfaces[num_sorted].cull = cull_type;
gpGlobals->draw_surfaces[num_sorted].surf = psurf;
gpGlobals->draw_surfaces[num_sorted].cull = cull_type;
num_sorted++;
}
}
// sort faces if needs
if( !FBitSet( clmodel->flags, MODEL_LIQUID ) && e->curstate.rendermode == kRenderTransTexture && !CVAR_TO_BOOL( gl_nosort ))
qsort( WORLDMODEL->draw_surfaces, num_sorted, sizeof( sortedface_t ), R_SurfaceCompare );
qsort( gpGlobals->draw_surfaces, num_sorted, sizeof( sortedface_t ), R_SurfaceCompare );
// draw sorted translucent surfaces
for( i = 0; i < num_sorted; i++ )
if( !allow_vbo || !R_AddSurfToVBO( WORLDMODEL->draw_surfaces[i].surf, true ) )
R_RenderBrushPoly( WORLDMODEL->draw_surfaces[i].surf, WORLDMODEL->draw_surfaces[i].cull );
if( !allow_vbo || !R_AddSurfToVBO( gpGlobals->draw_surfaces[i].surf, true ) )
R_RenderBrushPoly( gpGlobals->draw_surfaces[i].surf, gpGlobals->draw_surfaces[i].cull );
R_DrawVBO( R_HasLightmap(), true );
if( e->curstate.rendermode == kRenderTransColor )
@ -3415,8 +3414,8 @@ void R_MarkLeaves( void ) @@ -3415,8 +3414,8 @@ void R_MarkLeaves( void )
if( r_novis->value || RI.drawOrtho || !RI.viewleaf || !WORLDMODEL->visdata )
novis = true;
Mod_FatPVS( RI.pvsorigin, REFPVS_RADIUS, RI.visbytes, WORLDMODEL->visbytes, FBitSet( RI.params, RP_OLDVIEWLEAF ), novis );
if( force && !novis ) Mod_FatPVS( test, REFPVS_RADIUS, RI.visbytes, WORLDMODEL->visbytes, true, novis );
Mod_FatPVS( RI.pvsorigin, REFPVS_RADIUS, RI.visbytes, gpGlobals->visbytes, FBitSet( RI.params, RP_OLDVIEWLEAF ), novis );
if( force && !novis ) Mod_FatPVS( test, REFPVS_RADIUS, RI.visbytes, gpGlobals->visbytes, true, novis );
for( i = 0; i < WORLDMODEL->numleafs; i++ )
{
@ -3523,10 +3522,10 @@ void GL_RebuildLightmaps( void ) @@ -3523,10 +3522,10 @@ void GL_RebuildLightmaps( void )
}
LM_UploadBlock( false );
if( clgame.drawFuncs.GL_BuildLightmaps )
if( gRenderIface.GL_BuildLightmaps )
{
// build lightmaps on the client-side
clgame.drawFuncs.GL_BuildLightmaps( );
gRenderIface.GL_BuildLightmaps( );
}
}
@ -3606,10 +3605,10 @@ void GL_BuildLightmaps( void ) @@ -3606,10 +3605,10 @@ void GL_BuildLightmaps( void )
LM_UploadBlock( false );
if( clgame.drawFuncs.GL_BuildLightmaps )
if( gRenderIface.GL_BuildLightmaps )
{
// build lightmaps on the client-side
clgame.drawFuncs.GL_BuildLightmaps( );
gRenderIface.GL_BuildLightmaps( );
}
// now gamma and brightness are valid

1
ref_gl/gl_sprite.c

@ -13,7 +13,6 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -13,7 +13,6 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
#include "common.h"
#include "gl_local.h"
#include "pm_local.h"
#include "sprite.h"

8
ref_gl/gl_triapi.c

@ -181,10 +181,10 @@ int TriWorldToScreen( float *world, float *screen ) @@ -181,10 +181,10 @@ int TriWorldToScreen( float *world, float *screen )
retval = R_WorldToScreen( world, screen );
screen[0] = 0.5f * screen[0] * (float)clgame.viewport[2];
screen[1] = -0.5f * screen[1] * (float)clgame.viewport[3];
screen[0] += 0.5f * (float)clgame.viewport[2];
screen[1] += 0.5f * (float)clgame.viewport[3];
screen[0] = 0.5f * screen[0] * (float)RI.viewport[2];
screen[1] = -0.5f * screen[1] * (float)RI.viewport[3];
screen[0] += 0.5f * (float)RI.viewport[2];
screen[1] += 0.5f * (float)RI.viewport[3];
return retval;
}

4
ref_gl/gl_vgui.c

@ -221,8 +221,8 @@ generic method to fill rectangle @@ -221,8 +221,8 @@ generic method to fill rectangle
*/
void GAME_EXPORT VGUI_DrawQuad( const vpoint_t *ul, const vpoint_t *lr )
{
float xscale = glState.width / (float)clgame.scrInfo.iWidth;
float yscale = glState.height / (float)clgame.scrInfo.iHeight;
float xscale = gpGlobals->width / (float)clgame.scrInfo.iWidth;
float yscale = gpGlobals->height / (float)clgame.scrInfo.iHeight;
ASSERT( ul != NULL && lr != NULL );

18
ref_gl/gl_warp.c

@ -310,7 +310,7 @@ void R_AddSkyBoxSurface( msurface_t *fa ) @@ -310,7 +310,7 @@ void R_AddSkyBoxSurface( msurface_t *fa )
float *v;
int i;
if( FBitSet( WORLDMODEL->flags, FWORLD_SKYSPHERE ) && fa->polys && !FBitSet( WORLDMODEL->flags, FWORLD_CUSTOM_SKYBOX ))
if( gEngfuncs.CL_GetRenderParm( PARM_SKY_SPHERE ) && fa->polys && !tr.fCustomSkybox )
{
glpoly_t *p = fa->polys;
@ -354,7 +354,7 @@ void R_UnloadSkybox( void ) @@ -354,7 +354,7 @@ void R_UnloadSkybox( void )
tr.skyboxbasenum = 5800; // set skybox base (to let some mods load hi-res skyboxes)
memset( tr.skyboxTextures, 0, sizeof( tr.skyboxTextures ));
ClearBits( WORLDMODEL->flags, FWORLD_CUSTOM_SKYBOX );
tr.fCustomSkybox = false;
}
/*
@ -411,8 +411,8 @@ R_SetupSky @@ -411,8 +411,8 @@ R_SetupSky
*/
void R_SetupSky( const char *skyboxname )
{
char loadname[MAX_QPATH];
char sidename[MAX_QPATH];
char loadname[MAX_STRING];
char sidename[MAX_STRING];
int i, result;
if( !COM_CheckString( skyboxname ))
@ -439,7 +439,7 @@ void R_SetupSky( const char *skyboxname ) @@ -439,7 +439,7 @@ void R_SetupSky( const char *skyboxname )
// release old skybox
R_UnloadSkybox();
Con_DPrintf( "SKY: " );
gEngfuncs.Con_DPrintf( "SKY: " );
for( i = 0; i < 6; i++ )
{
@ -449,17 +449,17 @@ void R_SetupSky( const char *skyboxname ) @@ -449,17 +449,17 @@ void R_SetupSky( const char *skyboxname )
tr.skyboxTextures[i] = GL_LoadTexture( sidename, NULL, 0, TF_CLAMP|TF_SKY );
if( !tr.skyboxTextures[i] ) break;
Con_DPrintf( "%s%s%s", skyboxname, r_skyBoxSuffix[i], i != 5 ? ", " : ". " );
gEngfuncs.Con_DPrintf( "%s%s%s", skyboxname, r_skyBoxSuffix[i], i != 5 ? ", " : ". " );
}
if( i == 6 )
{
SetBits( WORLDMODEL->flags, FWORLD_CUSTOM_SKYBOX );
Con_DPrintf( "done\n" );
tr.fCustomSkybox = true;
gEngfuncs.Con_DPrintf( "done\n" );
return; // loaded
}
Con_DPrintf( "^2failed\n" );
gEngfuncs.Con_DPrintf( "^2failed\n" );
R_UnloadSkybox();
}

Loading…
Cancel
Save