ref: render code moved out of engine, doesn't compile, first API prototype

This commit is contained in:
Alibek Omarov 2019-02-18 21:25:26 +03:00
parent bccc0e63d5
commit 99bd7c81da
79 changed files with 2320 additions and 3467 deletions

View File

@ -150,6 +150,10 @@ Default build-depended cvar and constant values
#define DEFAULT_FULLSCREEN 1
#endif
#ifndef DEFAULT_RENDERER
#define DEFAULT_RENDERER "ref_gl"
#endif
#if TARGET_OS_IPHONE
#define DEFAULT_CON_MAXFRAC "0.5"
#else

209
common/ref_api.h Normal file
View File

@ -0,0 +1,209 @@
/*
ref_api.h - Xash3D render dll API
Copyright (C) 2019 a1batross
This program 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 3 of the License, or
(at your option) any later version.
This program 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.
*/
#pragma once
#ifndef REF_API
#define REF_API
#include "vgui_api.h"
#include "render_api.h"
#include "triangleapi.h"
#include "const.h"
#include "cl_entity.h"
#include "com_model.h"
#include "studio.h"
#include "r_efx.h"
#define REF_API_VERSION 1
typedef struct ref_globals_s
{
qboolean developer;
// viewport width and height
int width;
int height;
qboolean fullScreen;
qboolean wideScreen;
vec3_t vieworg;
vec3_t viewangles;
vec3_t vforward, vright, vup;
cl_entity_t *currententity;
model_t *currentmodel;
float fov_x, fov_y;
} ref_globals_t;
enum
{
GL_KEEP_UNIT = -1,
XASH_TEXTURE0 = 0,
XASH_TEXTURE1,
XASH_TEXTURE2,
XASH_TEXTURE3, // g-cont. 4 units should be enough
XASH_TEXTURE4, // mittorn. bump+detail needs 5 for single-pass
MAX_TEXTURE_UNITS = 32 // can't access to all over units without GLSL or cg
};
enum // r_speeds counters
{
RS_ACTIVE_TENTS = 0,
};
enum ref_shared_texture_e
{
REF_DEFAULT_TEXTURE,
REF_GRAY_TEXTURE,
REF_WHITE_TEXTURE,
REF_SOLIDSKY_TEXTURE,
REF_ALPHASKY_TEXTURE,
};
typedef struct ref_api_s
{
// TriApi helper
int (*TriGetRenderMode)( void );
} ref_api_t;
struct mip_s;
// render callbacks
typedef struct ref_interface_s
{
// construct, destruct
qboolean (*R_Init)( qboolean context ); // context is true if you need context management
const char *(*R_GetInitError)( void );
void (*R_Shutdown)( void );
//
void (*GL_InitExtensions)( void );
void (*GL_ClearExtensions)( void );
void (*R_BeginFrame)( qboolean clearScene );
void (*R_RenderScene)( void );
// void (*R_RenderFrame)( struct ref_viewpass_s *rvp ); part of RenderInterface
void (*R_EndFrame)( void );
void (*R_PushScene)( void );
void (*R_PopScene)( void );
// void (*R_ClearScene)( void ); part of RenderInterface
void (*GL_BackendStartFrame)( void );
void (*GL_BackendEndFrame)( void );
void (*R_ClearScreen)( void ); // clears color buffer on GL
void (*R_AllowFog)( qboolean allow );
void (*GL_SetRenderMode)( int renderMode );
int (*R_AddEntity)( int entityType, cl_entity_t *ent );
// view info
qboolean (*IsNormalPass)( void );
// debug
void (*R_ShowTextures)( void );
void (*R_ShowTree)( void );
void (*R_IncrementSpeedsCounter)( int counterType );
// texture management
const byte *(*GL_TextureData)( unsigned int texnum );
const char *(*R_GetTextureName)( int idx );
const byte *(*R_GetTextureOriginalBuffer)( int idx ); // not always available
int (*GL_LoadTextureFromBuffer)( const char *name, rgbdata_t *pic, texFlags_t flags, qboolean update );
int (*R_GetBuiltinTexture)( enum ref_shared_texture_e type );
void (*R_FreeSharedTexture)( enum ref_shared_texture_e type );
void (*GL_ProcessTexture)( int texnum, float gamma, int topColor, int bottomColor );
void (*R_SetupSky)( const char *skyname );
// 2D
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 (*R_DrawTileClear)( int x, int y, int w, int h );
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
// screenshot, cubemapshot
qboolean (*VID_ScreenShot)( const char *filename, int shot_type );
qboolean (*VID_CubemapShot)( const char *base, uint size, const float *vieworg, qboolean skyshot );
// light
colorVec (*R_LightPoint)( const float *p );
void (*R_AddEfrags)( struct cl_entity_s *ent );
void (*R_RemoveEfrags)( struct cl_entity_s *ent );
// decals
// Shoots a decal onto the surface of the BSP. position is the center of the decal in world coords
void (*R_DecalShoot)( int textureIndex, int entityIndex, int modelIndex, vec3_t pos, int flags, float scale );
void (*R_DecalRemoveAll)( int texture );
int (*R_CreateDecalList)( struct decallist_s *pList );
void (*R_ClearAllDecals)( void );
// studio interface
float (*R_StudioEstimateFrame)( cl_entity_t *e, mstudioseqdesc_t *pseqdesc );
void (*R_StudioLerpMovement)( cl_entity_t *e, double time, vec3_t origin, vec3_t angles );
// bmodel
void (*R_InitSkyClouds)( struct mip_s *mt, struct texture_s *tx, qboolean custom_palette );
void (*GL_SubdivideSurface)( msurface_t *fa );
// sprites
void (*R_GetSpriteParms)( int *frameWidth, int *frameHeight, int *numFrames, int currentFrame, const model_t *pSprite );
// model management
// flags ignored for everything except spritemodels
void (*Mod_LoadModel)( modtype_t desiredType, model_t *mod, const byte *buf, qboolean *loaded, int flags );
void (*Mod_LoadMapSprite)( struct model_s *mod, const void *buffer, size_t size, qboolean *loaded );
void (*Mod_UnloadModel)( model_t *mod );
void (*Mod_StudioLoadTextures)( model_t *mod, void *data );
void (*Mod_StudioUnloadTextures)( void *data );
// particle renderer
void (*CL_Particle)( const vec3_t origin, int color, float life, int zpos, int zvel ); // debug thing
// Xash3D Render Interface
render_api_t *RenderAPI; // partial RenderAPI implementation
render_interface_t *RenderIface; // compatible RenderInterface implementation: renderer should call client RenderInterface by itself
// TriAPI Interface
// NOTE: implementation isn't required to be compatible
void (*TriRenderMode)( int mode );
void (*Begin)( int primitiveCode );
void (*End)( void );
void (*Color4f)( float r, float g, float b, float a );
void (*Color4ub)( unsigned char r, unsigned char g, unsigned char b, unsigned char a );
void (*TexCoord2f)( float u, float v );
void (*Vertex3fv)( const float *worldPnt );
void (*Vertex3f)( float x, float y, float z );
int (*SpriteTexture)( struct model_s *pSpriteModel, int frame );
int (*WorldToScreen)( const float *world, float *screen ); // Returns 1 if it's z clipped
void (*Fog)( float flFogColor[3], float flStart, float flEnd, int bOn ); //Works just like GL_FOG, flFogColor is r/g/b.
void (*ScreenToWorld)( const float *screen, float *world );
void (*GetMatrix)( const int pname, float *matrix );
void (*FogParams)( float flDensity, int iFogSkybox );
void (*CullFace)( TRICULLSTYLE mode );
// vgui drawing implementation
vguiapi_t *VGuiAPI;
// efx api
efx_api_t *EfxAPI;
} ref_interface_t;
typedef int (*REFAPI)( int version, ref_interface_t *pFunctionTable, ref_api_t* engfuncs, ref_globals_t *pGlobals );
#endif // REF_API

View File

@ -254,7 +254,7 @@ typedef struct render_interface_s
// clear decals by engine request (e.g. for demo recording or vid_restart)
void (*R_ClearStudioDecals)( void );
// grab r_speeds message
qboolean (*R_SpeedsMessage)( char *out, size_t size );
qboolean (*R_SpeedsMessage)( char *out, size_t size );
// alloc or destroy model custom data
void (*Mod_ProcessUserData)( struct model_s *mod, qboolean create, const byte *buffer );
// alloc or destroy entity custom data

View File

@ -16,7 +16,6 @@ GNU General Public License for more details.
#ifdef _WIN32
#include "common.h"
#include "client.h"
#include "gl_local.h"
#include <vfw.h> // video for windows
// msvfw32.dll exports

View File

@ -15,7 +15,6 @@ GNU General Public License for more details.
#include "common.h"
#include "client.h"
#include "gl_local.h"
/*
====================
@ -344,7 +343,7 @@ void CL_LevelShot_f( void )
// check for exist
if( cls.demoplayback && ( cls.demonum != -1 ))
{
Q_sprintf( cls.shotname, "levelshots/%s_%s.bmp", cls.demoname, glState.wideScreen ? "16x9" : "4x3" );
Q_sprintf( cls.shotname, "levelshots/%s_%s.bmp", cls.demoname, refState.wideScreen ? "16x9" : "4x3" );
Q_snprintf( filename, sizeof( filename ), "%s.dem", cls.demoname );
// make sure what levelshot is newer than demo
@ -353,7 +352,7 @@ void CL_LevelShot_f( void )
}
else
{
Q_sprintf( cls.shotname, "levelshots/%s_%s.bmp", clgame.mapname, glState.wideScreen ? "16x9" : "4x3" );
Q_sprintf( cls.shotname, "levelshots/%s_%s.bmp", clgame.mapname, refState.wideScreen ? "16x9" : "4x3" );
// make sure what levelshot is newer than bsp
ft1 = FS_FileTime( cl.worldmodel->name, false );
@ -424,53 +423,7 @@ void CL_SetSky_f( void )
return;
}
R_SetupSky( Cmd_Argv( 1 ));
}
/*
================
SCR_TimeRefresh_f
timerefresh [noflip]
================
*/
void SCR_TimeRefresh_f( void )
{
int i;
double start, stop;
double time;
if( cls.state != ca_active )
return;
start = Sys_DoubleTime();
// run without page flipping like GoldSrc
if( Cmd_Argc() == 1 )
{
pglDrawBuffer( GL_FRONT );
for( i = 0; i < 128; i++ )
{
RI.viewangles[1] = i / 128.0 * 360.0f;
R_RenderScene();
}
pglFinish();
R_EndFrame();
}
else
{
for( i = 0; i < 128; i++ )
{
R_BeginFrame( true );
RI.viewangles[1] = i / 128.0 * 360.0f;
R_RenderScene();
R_EndFrame();
}
}
stop = Sys_DoubleTime ();
time = (stop - start);
Con_Printf( "%f seconds (%f fps)\n", time, 128 / time );
ref.dllFuncs.R_SetupSky( Cmd_Argv( 1 ));
}
/*
@ -482,6 +435,6 @@ viewpos (level-designer helper)
*/
void SCR_Viewpos_f( void )
{
Con_Printf( "org ( %g %g %g )\n", RI.vieworg[0], RI.vieworg[1], RI.vieworg[2] );
Con_Printf( "ang ( %g %g %g )\n", RI.viewangles[0], RI.viewangles[1], RI.viewangles[2] );
}
Con_Printf( "org ( %g %g %g )\n", refState.vieworg[0], refState.vieworg[1], refState.vieworg[2] );
Con_Printf( "ang ( %g %g %g )\n", refState.viewangles[0], refState.viewangles[1], refState.viewangles[2] );
}

View File

@ -17,7 +17,6 @@ GNU General Public License for more details.
#include "client.h"
#include "net_encode.h"
#include "particledef.h"
#include "gl_local.h"
#include "cl_tent.h"
#include "shake.h"
#include "hltv.h"
@ -239,4 +238,4 @@ void CL_WriteMessageHistory( void )
if( host_developer.value >= DEV_EXTENDED )
CL_WriteErrorMessage( MSG_GetNumBytesRead( msg ) - 1, msg );
cls_message_debug.parsing = false;
}
}

View File

@ -15,7 +15,6 @@ GNU General Public License for more details.
#include "common.h"
#include "client.h"
#include "gl_local.h"
#include "net_encode.h"
#define dem_unknown 0 // unknown command
@ -500,7 +499,7 @@ void CL_DrawDemoRecording( void )
Q_memprint( pos ), (int)(cls.demotime / 60.0f ), (int)fmod( cls.demotime, 60.0f ));
Con_DrawStringLen( string, &len, NULL );
Con_DrawString(( glState.width - len ) >> 1, glState.height >> 4, string, color );
Con_DrawString(( refState.width - len ) >> 1, refState.height >> 4, string, color );
}
/*

View File

@ -17,7 +17,6 @@ GNU General Public License for more details.
#include "client.h"
#include "net_encode.h"
#include "entity_types.h"
#include "gl_local.h"
#include "pm_local.h"
#include "cl_tent.h"
#include "studio.h"
@ -226,6 +225,33 @@ void CL_UpdateLatchedVars( cl_entity_t *ent )
memcpy( ent->latched.prevblending, ent->prevstate.blending, sizeof( ent->latched.prevblending ));
}
/*
====================
CL_GetStudioEstimatedFrame
====================
*/
float CL_GetStudioEstimatedFrame( cl_entity_t *ent )
{
studiohdr_t *pstudiohdr;
mstudioseqdesc_t *pseqdesc;
int sequence;
if( ent->model != NULL && ent->model->type == mod_studio )
{
pstudiohdr = (studiohdr_t *)Mod_StudioExtradata( ent->model );
if( pstudiohdr )
{
sequence = bound( 0, ent->curstate.sequence, pstudiohdr->numseq - 1 );
pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + sequence;
return ref.dllFuncs.R_StudioEstimateFrame( ent, pseqdesc );
}
}
return 0;
}
/*
====================
CL_ResetLatchedVars
@ -942,7 +968,7 @@ qboolean CL_AddVisibleEntity( cl_entity_t *ent, int entityType )
CL_AddCustomBeam( ent );
return true;
}
else if( !R_AddEntity( ent, entityType ))
else if( !ref.dllFuncs.R_AddEntity( ent, entityType ))
{
return false;
}
@ -1191,7 +1217,7 @@ void CL_LinkPacketEntities( frame_t *frame )
if( ent->model->type == mod_studio )
{
if( interpolate && FBitSet( host.features, ENGINE_COMPUTE_STUDIO_LERP ))
R_StudioLerpMovement( ent, cl.time, ent->origin, ent->angles );
ref.dllFuncs.R_StudioLerpMovement( ent, cl.time, ent->origin, ent->angles );
}
}
@ -1262,7 +1288,7 @@ void CL_EmitEntities( void )
{
if( cl.paused ) return; // don't waste time
R_ClearScene ();
RefRenderIface->R_ClearScene ();
// not in server yet, no entities to redraw
if( cls.state != ca_active || !cl.validsequence )
@ -1330,7 +1356,7 @@ qboolean CL_GetEntitySpatialization( channel_t *ch )
if(( ch->entnum - 1 ) == cl.playernum )
{
VectorCopy( RI.vieworg, ch->origin );
VectorCopy( refState.vieworg, ch->origin );
return true;
}

View File

@ -25,7 +25,6 @@ GNU General Public License for more details.
#include "input.h"
#include "shake.h"
#include "sprite.h"
#include "gl_local.h"
#include "library.h"
#include "vgui_draw.h"
#include "sound.h" // SND_STOP_LOOPING
@ -278,18 +277,18 @@ static int CL_AdjustXPos( float x, int width, int totalWidth )
if( x == -1 )
{
xPos = ( glState.width - width ) * 0.5f;
xPos = ( refState.width - width ) * 0.5f;
}
else
{
if ( x < 0 )
xPos = (1.0f + x) * glState.width - totalWidth; // Alight right
xPos = (1.0f + x) * refState.width - totalWidth; // Alight right
else // align left
xPos = x * glState.width;
xPos = x * refState.width;
}
if( xPos + width > glState.width )
xPos = glState.width - width;
if( xPos + width > refState.width )
xPos = refState.width - width;
else if( xPos < 0 )
xPos = 0;
@ -309,19 +308,19 @@ static int CL_AdjustYPos( float y, int height )
if( y == -1 ) // centered?
{
yPos = ( glState.height - height ) * 0.5f;
yPos = ( refState.height - height ) * 0.5f;
}
else
{
// Alight bottom?
if( y < 0 )
yPos = (1.0f + y) * glState.height - height; // Alight bottom
yPos = (1.0f + y) * refState.height - height; // Alight bottom
else // align top
yPos = y * glState.height;
yPos = y * refState.height;
}
if( yPos + height > glState.height )
yPos = glState.height - height;
if( yPos + height > refState.height )
yPos = refState.height - height;
else if( yPos < 0 )
yPos = 0;
@ -383,8 +382,8 @@ static void SPR_AdjustSize( float *x, float *y, float *w, float *h )
if( !x && !y && !w && !h ) return;
// scale for screen sizes
xscale = glState.width / (float)clgame.scrInfo.iWidth;
yscale = glState.height / (float)clgame.scrInfo.iHeight;
xscale = refState.width / (float)clgame.scrInfo.iWidth;
yscale = refState.height / (float)clgame.scrInfo.iHeight;
if( x ) *x *= xscale;
if( y ) *y *= yscale;
@ -407,8 +406,8 @@ void PicAdjustSize( float *x, float *y, float *w, float *h )
if( !x && !y && !w && !h ) return;
// scale for screen sizes
xscale = glState.width / (float)clgame.scrInfo.iWidth;
yscale = glState.height / (float)clgame.scrInfo.iHeight;
xscale = refState.width / (float)clgame.scrInfo.iWidth;
yscale = refState.height / (float)clgame.scrInfo.iHeight;
if( x ) *x *= xscale;
if( y ) *y *= yscale;
@ -482,7 +481,7 @@ static void SPR_DrawGeneric( int frame, float x, float y, float width, float hei
int w, h;
// assume we get sizes from image
R_GetSpriteParms( &w, &h, NULL, frame, clgame.ds.pSprite );
ref.dllFuncs.R_GetSpriteParms( &w, &h, NULL, frame, clgame.ds.pSprite );
width = w;
height = h;
@ -520,10 +519,9 @@ static void SPR_DrawGeneric( int frame, float x, float y, float width, float hei
// scale for screen sizes
SPR_AdjustSize( &x, &y, &width, &height );
texnum = R_GetSpriteTexture( clgame.ds.pSprite, frame );
pglColor4ubv( clgame.ds.spriteColor );
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
R_DrawStretchPic( x, y, width, height, s1, t1, s2, t2, texnum );
texnum = ref.dllFuncs.SpriteTexture( clgame.ds.pSprite, frame );
ref.dllFuncs.Color4ub( clgame.ds.spriteColor[0], clgame.ds.spriteColor[1], clgame.ds.spriteColor[2], clgame.ds.spriteColor[3] );
ref.dllFuncs.R_DrawStretchPic( x, y, width, height, s1, t1, s2, t2, texnum );
}
/*
@ -581,7 +579,7 @@ void CL_DrawCenterPrint( void )
for( j = 0; j < lineLength; j++ )
{
if( x >= 0 && y >= 0 && x <= glState.width )
if( x >= 0 && y >= 0 && x <= refState.width )
x += Con_DrawCharacter( x, y, line[j], colorDefault );
}
y += charHeight;
@ -629,13 +627,14 @@ void CL_DrawScreenFade( void )
iFadeAlpha = bound( 0, iFadeAlpha, sf->fadealpha );
}
pglColor4ub( sf->fader, sf->fadeg, sf->fadeb, iFadeAlpha );
ref.dllFuncs.Color4ub( sf->fader, sf->fadeg, sf->fadeb, iFadeAlpha );
if( sf->fadeFlags & FFADE_MODULATE )
GL_SetRenderMode( kRenderTransAdd );
else GL_SetRenderMode( kRenderTransTexture );
R_DrawStretchPic( 0, 0, glState.width, glState.height, 0, 0, 1, 1, tr.whiteTexture );
pglColor4ub( 255, 255, 255, 255 );
ref.dllFuncs.GL_SetRenderMode( kRenderTransAdd );
else ref.dllFuncs.GL_SetRenderMode( kRenderTransTexture );
ref.dllFuncs.R_DrawStretchPic( 0, 0, refState.width, refState.height, 0, 0, 1, 1,
ref.dllFuncs.R_GetBuiltinTexture( REF_WHITE_TEXTURE ));
ref.dllFuncs.Color4ub( 255, 255, 255, 255 );
}
/*
@ -913,10 +912,10 @@ void CL_DrawCrosshair( void )
vec3_t forward;
vec3_t point, screen;
VectorAdd( RI.viewangles, cl.crosshairangle, angles );
VectorAdd( refState.viewangles, cl.crosshairangle, angles );
AngleVectors( angles, forward, NULL, NULL );
VectorAdd( RI.vieworg, forward, point );
R_WorldToScreen( point, screen );
VectorAdd( refState.vieworg, forward, point );
ref.dllFuncs.WorldToScreen( point, screen );
x += ( clgame.viewport[2] >> 1 ) * screen[0] + 0.5f;
y += ( clgame.viewport[3] >> 1 ) * screen[1] + 0.5f;
@ -950,8 +949,8 @@ static void CL_DrawLoading( float percent )
x = ( clgame.scrInfo.iWidth - width ) >> 1;
y = ( clgame.scrInfo.iHeight - height) >> 1;
xscale = glState.width / (float)clgame.scrInfo.iWidth;
yscale = glState.height / (float)clgame.scrInfo.iHeight;
xscale = refState.width / (float)clgame.scrInfo.iWidth;
yscale = refState.height / (float)clgame.scrInfo.iHeight;
x *= xscale;
y *= yscale;
@ -959,26 +958,26 @@ static void CL_DrawLoading( float percent )
height *= yscale;
if( cl_allow_levelshots->value )
{
pglColor4ub( 128, 128, 128, 255 );
GL_SetRenderMode( kRenderTransTexture );
R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, cls.loadingBar );
{
ref.dllFuncs.Color4ub( 128, 128, 128, 255 );
ref.dllFuncs.GL_SetRenderMode( kRenderTransTexture );
ref.dllFuncs.R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, cls.loadingBar );
step = (float)width / 100.0f;
right = (int)ceil( percent * step );
s2 = (float)right / width;
width = right;
pglColor4ub( 208, 152, 0, 255 );
GL_SetRenderMode( kRenderTransTexture );
R_DrawStretchPic( x, y, width, height, 0, 0, s2, 1, cls.loadingBar );
pglColor4ub( 255, 255, 255, 255 );
ref.dllFuncs.Color4ub( 208, 152, 0, 255 );
ref.dllFuncs.GL_SetRenderMode( kRenderTransTexture );
ref.dllFuncs.R_DrawStretchPic( x, y, width, height, 0, 0, s2, 1, cls.loadingBar );
ref.dllFuncs.Color4ub( 255, 255, 255, 255 );
}
else
{
pglColor4ub( 255, 255, 255, 255 );
GL_SetRenderMode( kRenderTransTexture );
R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, cls.loadingBar );
ref.dllFuncs.Color4ub( 255, 255, 255, 255 );
ref.dllFuncs.GL_SetRenderMode( kRenderTransTexture );
ref.dllFuncs.R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, cls.loadingBar );
}
}
@ -998,17 +997,17 @@ static void CL_DrawPause( void )
x = ( clgame.scrInfo.iWidth - width ) >> 1;
y = ( clgame.scrInfo.iHeight - height) >> 1;
xscale = glState.width / (float)clgame.scrInfo.iWidth;
yscale = glState.height / (float)clgame.scrInfo.iHeight;
xscale = refState.width / (float)clgame.scrInfo.iWidth;
yscale = refState.height / (float)clgame.scrInfo.iHeight;
x *= xscale;
y *= yscale;
width *= xscale;
height *= yscale;
pglColor4ub( 255, 255, 255, 255 );
GL_SetRenderMode( kRenderTransTexture );
R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, cls.pauseIcon );
ref.dllFuncs.Color4ub( 255, 255, 255, 255 );
ref.dllFuncs.GL_SetRenderMode( kRenderTransTexture );
ref.dllFuncs.R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, cls.pauseIcon );
}
void CL_DrawHUD( int state )
@ -1097,7 +1096,7 @@ void CL_LinkUserMessage( char *pszName, const int svc_num, int iSize )
void CL_FreeEntity( cl_entity_t *pEdict )
{
Assert( pEdict != NULL );
R_RemoveEfrags( pEdict );
ref.dllFuncs.R_RemoveEfrags( pEdict );
CL_KillDeadBeams( pEdict );
}
@ -1112,7 +1111,7 @@ void CL_ClearWorld( void )
world->model = cl.worldmodel;
world->index = 0;
clgame.ds.cullMode = GL_FRONT;
clgame.ds.cullMode = TRI_FRONT;
clgame.numStatics = 0;
}
@ -1227,7 +1226,7 @@ static qboolean CL_LoadHudSprite( const char *szSpriteName, model_t *m_pSprite,
else
{
Con_Reportf( S_ERROR "Could not load HUD sprite %s\n", szSpriteName );
Mod_UnloadSpriteModel( m_pSprite );
ref.dllFuncs.Mod_UnloadModel( m_pSprite );
return false;
}
}
@ -1236,14 +1235,14 @@ static qboolean CL_LoadHudSprite( const char *szSpriteName, model_t *m_pSprite,
ASSERT( buf != NULL );
if( type == SPR_MAPSPRITE )
Mod_LoadMapSprite( m_pSprite, buf, size, &loaded );
else Mod_LoadSpriteModel( m_pSprite, buf, &loaded, texFlags );
ref.dllFuncs.Mod_LoadMapSprite( m_pSprite, buf, size, &loaded );
else ref.dllFuncs.Mod_LoadModel( mod_sprite, m_pSprite, buf, &loaded, texFlags );
Mem_Free( buf );
if( !loaded )
{
Mod_UnloadSpriteModel( m_pSprite );
ref.dllFuncs.Mod_UnloadModel( m_pSprite );
return false;
}
@ -1399,7 +1398,7 @@ static int pfnSPR_Frames( HSPRITE hPic )
{
int numFrames;
R_GetSpriteParms( NULL, NULL, &numFrames, 0, CL_GetSpritePointer( hPic ));
ref.dllFuncs.R_GetSpriteParms( NULL, NULL, &numFrames, 0, CL_GetSpritePointer( hPic ));
return numFrames;
}
@ -1414,7 +1413,7 @@ static int pfnSPR_Height( HSPRITE hPic, int frame )
{
int sprHeight;
R_GetSpriteParms( NULL, &sprHeight, NULL, frame, CL_GetSpritePointer( hPic ));
ref.dllFuncs.R_GetSpriteParms( NULL, &sprHeight, NULL, frame, CL_GetSpritePointer( hPic ));
return sprHeight;
}
@ -1429,7 +1428,7 @@ static int pfnSPR_Width( HSPRITE hPic, int frame )
{
int sprWidth;
R_GetSpriteParms( &sprWidth, NULL, NULL, frame, CL_GetSpritePointer( hPic ));
ref.dllFuncs.R_GetSpriteParms( &sprWidth, NULL, NULL, frame, CL_GetSpritePointer( hPic ));
return sprWidth;
}
@ -1457,8 +1456,7 @@ pfnSPR_Draw
*/
static void pfnSPR_Draw( int frame, int x, int y, const wrect_t *prc )
{
pglDisable( GL_BLEND );
ref.dllFuncs.GL_SetRenderMode( kRenderNormal );
SPR_DrawGeneric( frame, x, y, -1, -1, prc );
}
@ -1470,14 +1468,21 @@ pfnSPR_DrawHoles
*/
static void pfnSPR_DrawHoles( int frame, int x, int y, const wrect_t *prc )
{
#if 1 // REFTODO
ref.dllFuncs.GL_SetRenderMode( kRenderTransColor );
#else
pglEnable( GL_ALPHA_TEST );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
pglEnable( GL_BLEND );
#endif
SPR_DrawGeneric( frame, x, y, -1, -1, prc );
#if 1
ref.dllFuncs.GL_SetRenderMode( kRenderNormal );
#else
pglDisable( GL_ALPHA_TEST );
pglDisable( GL_BLEND );
#endif
}
/*
@ -1488,12 +1493,20 @@ pfnSPR_DrawAdditive
*/
static void pfnSPR_DrawAdditive( int frame, int x, int y, const wrect_t *prc )
{
#if 1 // REFTODO
ref.dllFuncs.GL_SetRenderMode( kRenderTransAdd );
#else
pglEnable( GL_BLEND );
pglBlendFunc( GL_ONE, GL_ONE );
#endif
SPR_DrawGeneric( frame, x, y, -1, -1, prc );
#if 1 // REFTODO
ref.dllFuncs.GL_SetRenderMode( kRenderNormal );
#else
pglDisable( GL_BLEND );
#endif
}
/*
@ -1603,6 +1616,9 @@ void CL_FillRGBA( int x, int y, int w, int h, int r, int g, int b, int a )
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 );
@ -1619,6 +1635,7 @@ void CL_FillRGBA( int x, int y, int w, int h, int r, int g, int b, int a )
pglColor3f( 1.0f, 1.0f, 1.0f );
pglEnable( GL_TEXTURE_2D );
pglDisable( GL_BLEND );
#endif
}
/*
@ -1638,14 +1655,14 @@ int CL_GetScreenInfo( SCREENINFO *pscrinfo )
if( scale_factor && scale_factor != 1.0f)
{
clgame.scrInfo.iWidth = (float)glState.width / scale_factor;
clgame.scrInfo.iHeight = (float)glState.height / scale_factor;
clgame.scrInfo.iWidth = (float)refState.width / scale_factor;
clgame.scrInfo.iHeight = (float)refState.height / scale_factor;
clgame.scrInfo.iFlags |= SCRINFO_STRETCHED;
}
else
{
clgame.scrInfo.iWidth = glState.width;
clgame.scrInfo.iHeight = glState.height;
clgame.scrInfo.iWidth = refState.width;
clgame.scrInfo.iHeight = refState.height;
clgame.scrInfo.iFlags &= ~SCRINFO_STRETCHED;
}
@ -2848,8 +2865,10 @@ pfnSPR_DrawGeneric
*/
static void GAME_EXPORT pfnSPR_DrawGeneric( int frame, int x, int y, const wrect_t *prc, int blendsrc, int blenddst, int width, int height )
{
#if 0 // REFTODO:
pglEnable( GL_BLEND );
pglBlendFunc( blendsrc, blenddst ); // g-cont. are params is valid?
#endif
SPR_DrawGeneric( frame, x, y, width, height, prc );
}
@ -3018,6 +3037,9 @@ void GAME_EXPORT CL_FillRGBABlend( int x, int y, int w, int h, int r, int g, int
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 );
@ -3034,6 +3056,7 @@ void GAME_EXPORT CL_FillRGBABlend( int x, int y, int w, int h, int r, int g, int
pglColor3f( 1.0f, 1.0f, 1.0f );
pglEnable( GL_TEXTURE_2D );
pglDisable( GL_BLEND );
#endif
}
/*
@ -3078,111 +3101,31 @@ char *pfnParseFile( char *data, char *token )
/*
=================
TriApi implementation
TriAPI implementation
=================
*/
/*
=============
=================
TriRenderMode
set rendermode
=============
=================
*/
void TriRenderMode( int mode )
{
switch( mode )
{
case kRenderNormal:
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
pglDisable( GL_BLEND );
pglDepthMask( GL_TRUE );
break;
case kRenderTransAlpha:
pglEnable( GL_BLEND );
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
pglDepthMask( GL_FALSE );
break;
case kRenderTransColor:
case kRenderTransTexture:
pglEnable( GL_BLEND );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
break;
case kRenderGlow:
case kRenderTransAdd:
pglBlendFunc( GL_SRC_ALPHA, GL_ONE );
pglEnable( GL_BLEND );
pglDepthMask( GL_FALSE );
break;
}
clgame.ds.renderMode = mode;
ref.dllFuncs.TriRenderMode( mode );
}
/*
=============
TriBegin
begin triangle sequence
=============
*/
void TriBegin( int mode )
{
switch( mode )
{
case TRI_POINTS:
mode = GL_POINTS;
break;
case TRI_TRIANGLES:
mode = GL_TRIANGLES;
break;
case TRI_TRIANGLE_FAN:
mode = GL_TRIANGLE_FAN;
break;
case TRI_QUADS:
mode = GL_QUADS;
break;
case TRI_LINES:
mode = GL_LINES;
break;
case TRI_TRIANGLE_STRIP:
mode = GL_TRIANGLE_STRIP;
break;
case TRI_QUAD_STRIP:
mode = GL_QUAD_STRIP;
break;
case TRI_POLYGON:
default: mode = GL_POLYGON;
break;
}
pglBegin( mode );
}
/*
=============
TriEnd
draw triangle sequence
=============
*/
void TriEnd( void )
{
pglEnd();
}
/*
=============
=================
TriColor4f
=============
=================
*/
void TriColor4f( float r, float g, float b, float a )
{
if( clgame.ds.renderMode == kRenderTransAlpha )
pglColor4ub( r * 255.9f, g * 255.9f, b * 255.9f, a * 255.0f );
else pglColor4f( r * a, g * a, b * a, 1.0 );
ref.dllFuncs.Color4ub( r * 255.9f, g * 255.9f, b * 255.9f, a * 255.0f );
else ref.dllFuncs.Color4f( r * a, g * a, b * a, 1.0 );
clgame.ds.triRGBA[0] = r;
clgame.ds.triRGBA[1] = g;
@ -3193,7 +3136,6 @@ void TriColor4f( float r, float g, float b, float a )
/*
=============
TriColor4ub
=============
*/
void TriColor4ub( byte r, byte g, byte b, byte a )
@ -3203,46 +3145,12 @@ void TriColor4ub( byte r, byte g, byte b, byte a )
clgame.ds.triRGBA[2] = b * (1.0f / 255.0f);
clgame.ds.triRGBA[3] = a * (1.0f / 255.0f);
pglColor4f( clgame.ds.triRGBA[0], clgame.ds.triRGBA[1], clgame.ds.triRGBA[2], 1.0f );
}
/*
=============
TriTexCoord2f
=============
*/
void TriTexCoord2f( float u, float v )
{
pglTexCoord2f( u, v );
}
/*
=============
TriVertex3fv
=============
*/
void TriVertex3fv( const float *v )
{
pglVertex3fv( v );
}
/*
=============
TriVertex3f
=============
*/
void TriVertex3f( float x, float y, float z )
{
pglVertex3f( x, y, z );
ref.dllFuncs.Color4f( clgame.ds.triRGBA[0], clgame.ds.triRGBA[1], clgame.ds.triRGBA[2], 1.0f );
}
/*
=============
TriBrightness
=============
*/
void TriBrightness( float brightness )
@ -3253,56 +3161,23 @@ void TriBrightness( float brightness )
g = clgame.ds.triRGBA[1] * clgame.ds.triRGBA[3] * brightness;
b = clgame.ds.triRGBA[2] * clgame.ds.triRGBA[3] * brightness;
pglColor4f( r, g, b, 1.0f );
ref.dllFuncs.Color4f( r, g, b, 1.0f );
}
/*
=============
TriCullFace
=============
*/
void TriCullFace( TRICULLSTYLE mode )
void TriCullFace( TRICULLSTYLE style )
{
switch( mode )
{
case TRI_FRONT:
clgame.ds.cullMode = GL_FRONT;
break;
default:
clgame.ds.cullMode = GL_NONE;
break;
}
GL_Cull( clgame.ds.cullMode );
}
/*
=============
TriSpriteTexture
bind current texture
=============
*/
int TriSpriteTexture( model_t *pSpriteModel, int frame )
{
int gl_texturenum;
if(( gl_texturenum = R_GetSpriteTexture( pSpriteModel, frame )) == 0 )
return 0;
if( gl_texturenum <= 0 || gl_texturenum > MAX_TEXTURES )
gl_texturenum = tr.defaultTexture;
GL_Bind( XASH_TEXTURE0, gl_texturenum );
return 1;
clgame.ds.cullMode = style;
ref.dllFuncs.CullFace( style );
}
/*
=============
TriWorldToScreen
convert world coordinates (x,y,z) into screen (x, y)
=============
*/
@ -3310,7 +3185,7 @@ int TriWorldToScreen( float *world, float *screen )
{
int retval;
retval = R_WorldToScreen( world, screen );
retval = ref.dllFuncs.WorldToScreen( world, screen );
screen[0] = 0.5f * screen[0] * (float)clgame.viewport[2];
screen[1] = -0.5f * screen[1] * (float)clgame.viewport[3];
@ -3320,60 +3195,6 @@ int TriWorldToScreen( float *world, float *screen )
return retval;
}
/*
=============
TriFog
enables global fog on the level
=============
*/
void TriFog( float flFogColor[3], float flStart, float flEnd, int bOn )
{
// overrided by internal fog
if( RI.fogEnabled ) return;
RI.fogCustom = bOn;
// check for invalid parms
if( flEnd <= flStart )
{
RI.fogCustom = false;
pglDisable( GL_FOG );
return;
}
if( RI.fogCustom )
pglEnable( GL_FOG );
else pglDisable( GL_FOG );
// copy fog params
RI.fogColor[0] = flFogColor[0] / 255.0f;
RI.fogColor[1] = flFogColor[1] / 255.0f;
RI.fogColor[2] = flFogColor[2] / 255.0f;
RI.fogStart = flStart;
RI.fogColor[3] = 1.0f;
RI.fogDensity = 0.0f;
RI.fogSkybox = true;
RI.fogEnd = flEnd;
pglFogi( GL_FOG_MODE, GL_LINEAR );
pglFogfv( GL_FOG_COLOR, RI.fogColor );
pglFogf( GL_FOG_START, RI.fogStart );
pglFogf( GL_FOG_END, RI.fogEnd );
pglHint( GL_FOG_HINT, GL_NICEST );
}
/*
=============
TriGetMatrix
very strange export
=============
*/
void TriGetMatrix( const int pname, float *matrix )
{
pglGetFloatv( pname, matrix );
}
/*
=============
TriBoxInPVS
@ -3383,13 +3204,12 @@ check box in pvs (absmin, absmax)
*/
int TriBoxInPVS( float *mins, float *maxs )
{
return Mod_BoxVisible( mins, maxs, Mod_GetCurrentVis( ));
return Mod_BoxVisible( mins, maxs, RefRenderIface->Mod_GetCurrentVis( ));
}
/*
=============
TriLightAtPoint
NOTE: dlights are ignored
=============
*/
@ -3399,7 +3219,7 @@ void TriLightAtPoint( float *pos, float *value )
if( !pos || !value ) return;
vLightColor = R_LightPoint( pos );
vLightColor = ref.dllFuncs.R_LightPoint( pos );
value[0] = vLightColor.r;
value[1] = vLightColor.g;
@ -3409,7 +3229,6 @@ void TriLightAtPoint( float *pos, float *value )
/*
=============
TriColor4fRendermode
Heavy legacy of Quake...
=============
*/
@ -3418,23 +3237,19 @@ void TriColor4fRendermode( float r, float g, float b, float a, int rendermode )
if( clgame.ds.renderMode == kRenderTransAlpha )
{
clgame.ds.triRGBA[3] = a / 255.0f;
pglColor4f( r, g, b, a );
ref.dllFuncs.Color4f( r, g, b, a );
}
else pglColor4f( r * a, g * a, b * a, 1.0f );
else ref.dllFuncs.Color4f( r * a, g * a, b * a, 1.0f );
}
/*
=============
TriForParams
=============
*/
void TriFogParams( float flDensity, int iFogSkybox )
int TriSpriteTexture( model_t *pSpriteModel, int frame )
{
RI.fogDensity = flDensity;
RI.fogSkybox = iFogSkybox;
if( ref.dllFuncs.SpriteTexture( pSpriteModel, frame ))
return 1;
return 0;
}
/*
=================
DemoApi implementation
@ -3788,35 +3603,14 @@ float Voice_GetControlFloat( VoiceTweakControl iControl )
{
return 1.0f;
}
static void GAME_EXPORT VGui_ViewportPaintBackground( int extents[4] )
{
// stub
}
// shared between client and server
triangleapi_t gTriApi =
{
TRI_API_VERSION,
TriRenderMode,
TriBegin,
TriEnd,
TriColor4f,
TriColor4ub,
TriTexCoord2f,
TriVertex3fv,
TriVertex3f,
TriBrightness,
TriCullFace,
TriSpriteTexture,
R_WorldToScreen, // NOTE: XPROJECT, YPROJECT should be done in client.dll
TriFog,
R_ScreenToWorld,
TriGetMatrix,
TriBoxInPVS,
TriLightAtPoint,
TriColor4fRendermode,
TriFogParams,
};
triangleapi_t gTriApi;
static efx_api_t gEfxApi =
{
@ -4234,8 +4028,10 @@ qboolean CL_LoadProgs( const char *name )
CL_InitViewBeams ();
CL_InitTempEnts ();
#if 0 // REFTODO:
if( !R_InitRenderAPI()) // Xash3D extension
Con_Reportf( S_WARN "CL_LoadProgs: couldn't get render API\n" );
#endif
if( !Mobile_Init() ) // Xash3D FWGS extension: mobile interface
Con_Reportf( S_WARN "CL_LoadProgs: couldn't get mobility API\n" );

View File

@ -16,10 +16,10 @@ GNU General Public License for more details.
#include "common.h"
#include "client.h"
#include "const.h"
#include "gl_local.h"
#include "library.h"
#include "input.h"
#include "server.h" // !!svgame.hInstance
#include "vid_common.h"
static MENUAPI GetMenuAPI;
static ADDTOUCHBUTTONTOLIST pfnAddTouchButtonToList;
@ -203,7 +203,7 @@ static void UI_DrawLogo( const char *filename, float x, float y, float width, fl
redraw = true;
}
R_DrawStretchRaw( x, y, width, height, gameui.logo_xres, gameui.logo_yres, cin_data, redraw );
ref.dllFuncs.R_DrawStretchRaw( x, y, width, height, gameui.logo_xres, gameui.logo_yres, cin_data, redraw );
}
static int UI_GetLogoWidth( void )
@ -360,8 +360,8 @@ static void PIC_DrawGeneric( float x, float y, float width, float height, const
return;
PicAdjustSize( &x, &y, &width, &height );
R_DrawStretchPic( x, y, width, height, s1, t1, s2, t2, gameui.ds.gl_texturenum );
pglColor4ub( 255, 255, 255, 255 );
ref.dllFuncs.R_DrawStretchPic( x, y, width, height, s1, t1, s2, t2, gameui.ds.gl_texturenum );
ref.dllFuncs.Color4ub( 255, 255, 255, 255 );
}
/*
@ -390,7 +390,7 @@ static HIMAGE pfnPIC_Load( const char *szPicName, const byte *image_buf, int ima
SetBits( flags, TF_IMAGE );
Image_SetForceFlags( IL_LOAD_DECAL ); // allow decal images for menu
tx = GL_LoadTexture( szPicName, image_buf, image_size, flags );
tx = RefRenderAPI->GL_LoadTexture( szPicName, image_buf, image_size, flags );
Image_ClearForceFlags();
return tx;
@ -439,7 +439,7 @@ void pfnPIC_Set( HIMAGE hPic, int r, int g, int b, int a )
g = bound( 0, g, 255 );
b = bound( 0, b, 255 );
a = bound( 0, a, 255 );
pglColor4ub( r, g, b, a );
ref.dllFuncs.Color4ub( r, g, b, a );
}
/*
@ -450,7 +450,7 @@ pfnPIC_Draw
*/
void pfnPIC_Draw( int x, int y, int width, int height, const wrect_t *prc )
{
GL_SetRenderMode( kRenderNormal );
ref.dllFuncs.GL_SetRenderMode( kRenderNormal );
PIC_DrawGeneric( x, y, width, height, prc );
}
@ -462,7 +462,7 @@ pfnPIC_DrawTrans
*/
void pfnPIC_DrawTrans( int x, int y, int width, int height, const wrect_t *prc )
{
GL_SetRenderMode( kRenderTransTexture );
ref.dllFuncs.GL_SetRenderMode( kRenderTransTexture );
PIC_DrawGeneric( x, y, width, height, prc );
}
@ -474,7 +474,7 @@ pfnPIC_DrawHoles
*/
void pfnPIC_DrawHoles( int x, int y, int width, int height, const wrect_t *prc )
{
GL_SetRenderMode( kRenderTransAlpha );
ref.dllFuncs.GL_SetRenderMode( kRenderTransAlpha );
PIC_DrawGeneric( x, y, width, height, prc );
}
@ -486,7 +486,7 @@ pfnPIC_DrawAdditive
*/
void pfnPIC_DrawAdditive( int x, int y, int width, int height, const wrect_t *prc )
{
GL_SetRenderMode( kRenderTransAdd );
ref.dllFuncs.GL_SetRenderMode( kRenderTransAdd );
PIC_DrawGeneric( x, y, width, height, prc );
}
@ -553,10 +553,10 @@ static void pfnFillRGBA( int x, int y, int width, int height, int r, int g, int
g = bound( 0, g, 255 );
b = bound( 0, b, 255 );
a = bound( 0, a, 255 );
pglColor4ub( r, g, b, a );
GL_SetRenderMode( kRenderTransTexture );
R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, tr.whiteTexture );
pglColor4ub( 255, 255, 255, 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, ref.dllFuncs.R_GetBuiltinTexture( REF_WHITE_TEXTURE ) );
ref.dllFuncs.Color4ub( 255, 255, 255, 255 );
}
/*
@ -614,7 +614,7 @@ static void pfnDrawCharacter( int ix, int iy, int iwidth, int iheight, int ch, i
color[0] = (ulRGBA & 0xFF0000) >> 16;
color[1] = (ulRGBA & 0xFF00) >> 8;
color[2] = (ulRGBA & 0xFF) >> 0;
pglColor4ubv( color );
ref.dllFuncs.Color4ub( color[0], color[1], color[2], color[3] );
col = (ch & 15) * 0.0625f + (0.5f / 256.0f);
row = (ch >> 4) * 0.0625f + (0.5f / 256.0f);
@ -629,9 +629,9 @@ static void pfnDrawCharacter( int ix, int iy, int iwidth, int iheight, int ch, i
if( gameui.ds.scissor_test && !PIC_Scissor( &x, &y, &width, &height, &s1, &t1, &s2, &t2 ))
return;
GL_SetRenderMode( kRenderTransTexture );
R_DrawStretchPic( x, y, width, height, s1, t1, s2, t2, hFont );
pglColor4ub( 255, 255, 255, 255 );
ref.dllFuncs.GL_SetRenderMode( kRenderTransTexture );
ref.dllFuncs.R_DrawStretchPic( x, y, width, height, s1, t1, s2, t2, hFont );
ref.dllFuncs.Color4ub( 255, 255, 255, 255 );
}
/*
@ -702,8 +702,8 @@ for drawing playermodel previews
*/
static void pfnClearScene( void )
{
R_PushScene();
R_ClearScene();
ref.dllFuncs.R_PushScene();
RefRenderIface->R_ClearScene();
}
/*
@ -726,10 +726,10 @@ static void pfnRenderScene( const ref_viewpass_t *rvp )
// don't allow special modes from menu
copy.flags = 0;
R_Set2DMode( false );
R_RenderFrame( &copy );
R_Set2DMode( true );
R_PopScene();
ref.dllFuncs.R_Set2DMode( false );
RefRenderIface->GL_RenderFrame( &copy );
ref.dllFuncs.R_Set2DMode( true );
ref.dllFuncs.R_PopScene();
}
/*
@ -741,7 +741,7 @@ adding player model into visible list
*/
static int pfnAddEntity( int entityType, cl_entity_t *ent )
{
if( !R_AddEntity( ent, entityType ))
if( !ref.dllFuncs.R_AddEntity( ent, entityType ))
return false;
return true;
}
@ -946,6 +946,11 @@ static void pfnStartBackgroundTrack( const char *introTrack, const char *mainTra
S_StartBackgroundTrack( introTrack, mainTrack, 0, false );
}
static void GL_ProcessTexture( int texnum, float gamma, int topColor, int bottomColor )
{
ref.dllFuncs.GL_ProcessTexture( texnum, gamma, topColor, bottomColor );
}
// engine callbacks
static ui_enginefuncs_t gEngfuncs =
{

View File

@ -17,11 +17,11 @@ GNU General Public License for more details.
#include "client.h"
#include "net_encode.h"
#include "cl_tent.h"
#include "gl_local.h"
#include "input.h"
#include "kbutton.h"
#include "vgui_draw.h"
#include "library.h"
#include "vid_common.h"
#define MAX_TOTAL_CMDS 32
#define MAX_CMD_BUFFER 8000
@ -1779,7 +1779,7 @@ void CL_SetupOverviewParams( void )
// calculate nearest aspect
mapAspect = world.size[!ov->rotated] / world.size[ov->rotated];
screenAspect = (float)glState.width / (float)glState.height;
screenAspect = (float)refState.width / (float)refState.height;
aspect = Q_max( mapAspect, screenAspect );
ov->zNear = world.maxs[2];
@ -2936,7 +2936,7 @@ void CL_Init( void )
// unreliable buffer. unsed for unreliable commands and voice stream
MSG_Init( &cls.datagram, "cls.datagram", cls.datagram_buf, sizeof( cls.datagram_buf ));
IN_TouchInit();
// IN_TouchInit();
Con_LoadHistory();
if( !CL_LoadProgs( va( "%s/%s", GI->dll_path, SI.clientlib)))
@ -2968,7 +2968,7 @@ void CL_Shutdown( void )
Host_WriteVideoConfig ();
}
IN_TouchShutdown ();
// IN_TouchShutdown ();
Joy_Shutdown ();
CL_CloseDemoHeader ();
IN_Shutdown ();

View File

@ -19,7 +19,6 @@ GNU General Public License for more details.
#include "client.h"
#include "mobility_int.h"
#include "library.h"
#include "gl_local.h"
#include "input.h"
#include "platform/platform.h"
@ -101,12 +100,12 @@ static mobile_engfuncs_t gpMobileEngfuncs =
MOBILITY_API_VERSION,
pfnVibrate,
pfnEnableTextInput,
IN_TouchAddClientButton,
IN_TouchAddDefaultButton,
(void*)IN_TouchHideButtons,
IN_TouchRemoveButton,
(void*)IN_TouchSetClientOnly,
IN_TouchResetDefaultButtons,
NULL, // IN_TouchAddClientButton,
NULL, // IN_TouchAddDefaultButton,
NULL, // (void*)IN_TouchHideButtons,
NULL, // IN_TouchRemoveButton,
NULL, // (void*)IN_TouchSetClientOnly,
NULL, // IN_TouchResetDefaultButtons,
pfnDrawScaledCharacter,
Sys_Warn,
pfnGetNativeObject,

View File

@ -15,7 +15,6 @@ GNU General Public License for more details.
#include "common.h"
#include "client.h"
#include "gl_local.h"
#define NET_TIMINGS 1024
#define NET_TIMINGS_MASK (NET_TIMINGS - 1)
@ -75,12 +74,12 @@ NetGraph_FillRGBA shortcut
*/
static void NetGraph_DrawRect( wrect_t *rect, byte colors[4] )
{
pglColor4ubv( colors ); // color for this quad
ref.dllFuncs.Color4ub( colors[0], colors[1], colors[2], colors[3] ); // color for this quad
pglVertex2f( rect->left, rect->top );
pglVertex2f( rect->left + rect->right, rect->top );
pglVertex2f( rect->left + rect->right, rect->top + rect->bottom );
pglVertex2f( rect->left, rect->top + rect->bottom );
ref.dllFuncs.Vertex3f( rect->left, rect->top, 0 );
ref.dllFuncs.Vertex3f( rect->left + rect->right, rect->top, 0 );
ref.dllFuncs.Vertex3f( rect->left + rect->right, rect->top + rect->bottom, 0 );
ref.dllFuncs.Vertex3f( rect->left, rect->top + rect->bottom, 0 );
}
/*
@ -595,8 +594,8 @@ NetGraph_GetScreenPos
void NetGraph_GetScreenPos( wrect_t *rect, int *w, int *x, int *y )
{
rect->left = rect->top = 0;
rect->right = glState.width;
rect->bottom = glState.height;
rect->right = refState.width;
rect->bottom = refState.height;
*w = Q_min( NET_TIMINGS, net_graphwidth->value );
if( rect->right < *w + 10 )
@ -652,20 +651,17 @@ void SCR_DrawNetGraph( void )
if( net_graph->value < 3 )
{
pglEnable( GL_BLEND );
pglDisable( GL_TEXTURE_2D );
pglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE );
pglBegin( GL_QUADS ); // draw all the fills as a long solid sequence of quads for speedup reasons
ref.dllFuncs.GL_SetRenderMode( kRenderTransAdd );
ref.dllFuncs.Begin( TRI_QUADS ); // draw all the fills as a long solid sequence of quads for speedup reasons
// NOTE: fill colors without texture at this point
NetGraph_DrawDataUsage( x, y, w );
NetGraph_DrawTimes( rect, x, w );
pglEnd();
pglColor4ub( 255, 255, 255, 255 );
pglEnable( GL_TEXTURE_2D );
pglDisable( GL_BLEND );
ref.dllFuncs.End();
ref.dllFuncs.Color4ub( 255, 255, 255, 255 );
ref.dllFuncs.GL_SetRenderMode( kRenderNormal );
}
}
@ -680,4 +676,4 @@ void CL_InitNetgraph( void )
packet_loss = packet_choke = 0.0;
NetGraph_InitColors();
}
}

View File

@ -17,7 +17,6 @@ GNU General Public License for more details.
#include "client.h"
#include "net_encode.h"
#include "particledef.h"
#include "gl_local.h"
#include "cl_tent.h"
#include "shake.h"
#include "hltv.h"
@ -250,7 +249,7 @@ void CL_ParseMovevars( sizebuf_t *msg )
// update sky if changed
if( Q_strcmp( clgame.oldmovevars.skyName, clgame.movevars.skyName ) && cl.video_prepped )
R_SetupSky( clgame.movevars.skyName );
ref.dllFuncs.R_SetupSky( clgame.movevars.skyName );
memcpy( &clgame.oldmovevars, &clgame.movevars, sizeof( movevars_t ));
clgame.entities->curstate.scale = clgame.movevars.waveHeight;
@ -350,7 +349,7 @@ void CL_ParseStaticEntity( sizebuf_t *msg )
}
}
R_AddEfrags( ent ); // add link
ref.dllFuncs.R_AddEfrags( ent ); // add link
}
@ -658,7 +657,7 @@ void CL_RemoveCustomization( int nPlayerNum, customization_t *pRemove )
if( pList->resource.type == t_decal )
{
if( cls.state == ca_active )
R_DecalRemoveAll( pList->nUserData1 );
ref.dllFuncs.R_DecalRemoveAll( pList->nUserData1 );
FS_FreeImage( pList->pInfo );
}
}
@ -960,8 +959,8 @@ void CL_ParseServerData( sizebuf_t *msg )
// get splash name
if( cls.demoplayback && ( cls.demonum != -1 ))
Cvar_Set( "cl_levelshot_name", va( "levelshots/%s_%s", cls.demoname, glState.wideScreen ? "16x9" : "4x3" ));
else Cvar_Set( "cl_levelshot_name", va( "levelshots/%s_%s", clgame.mapname, glState.wideScreen ? "16x9" : "4x3" ));
Cvar_Set( "cl_levelshot_name", va( "levelshots/%s_%s", cls.demoname, refState.wideScreen ? "16x9" : "4x3" ));
else Cvar_Set( "cl_levelshot_name", va( "levelshots/%s_%s", clgame.mapname, refState.wideScreen ? "16x9" : "4x3" ));
Cvar_SetValue( "scr_loading", 0.0f ); // reset progress bar
if(( cl_allow_levelshots->value && !cls.changelevel ) || cl.background )
@ -1548,7 +1547,7 @@ void CL_RegisterResources( sizebuf_t *msg )
CL_ClearWorld ();
// tell rendering system we have a new set of models.
R_NewMap ();
RefRenderIface->R_NewMap ();
CL_SetupOverviewParams();
@ -1559,7 +1558,7 @@ void CL_RegisterResources( sizebuf_t *msg )
for( i = 1, mod = clgame.sprites; i < MAX_CLIENT_SPRITES; i++, mod++ )
{
if( mod->needload == NL_UNREFERENCED && COM_CheckString( mod->name ))
Mod_UnloadSpriteModel( mod );
ref.dllFuncs.Mod_UnloadModel( mod );
}
Mod_FreeUnused ();
@ -2466,8 +2465,8 @@ void CL_ParseLegacyServerData( sizebuf_t *msg )
// get splash name
if( cls.demoplayback && ( cls.demonum != -1 ))
Cvar_Set( "cl_levelshot_name", va( "levelshots/%s_%s", cls.demoname, glState.wideScreen ? "16x9" : "4x3" ));
else Cvar_Set( "cl_levelshot_name", va( "levelshots/%s_%s", clgame.mapname, glState.wideScreen ? "16x9" : "4x3" ));
Cvar_Set( "cl_levelshot_name", va( "levelshots/%s_%s", cls.demoname, refState.wideScreen ? "16x9" : "4x3" ));
else Cvar_Set( "cl_levelshot_name", va( "levelshots/%s_%s", clgame.mapname, refState.wideScreen ? "16x9" : "4x3" ));
Cvar_SetValue( "scr_loading", 0.0f ); // reset progress bar
if(( cl_allow_levelshots->value && !cls.changelevel ) || cl.background )
@ -2560,7 +2559,7 @@ void CL_LegacyParseStaticEntity( sizebuf_t *msg )
}
}
R_AddEfrags( ent ); // add link
ref.dllFuncs.R_AddEfrags( ent ); // add link
}
@ -3132,7 +3131,7 @@ void CL_LegacyPrecache_f( void )
clgame.entities->model = cl.worldmodel;
// tell rendering system we have a new set of models.
R_NewMap ();
RefRenderIface->R_NewMap ();
CL_SetupOverviewParams();
@ -3143,7 +3142,7 @@ void CL_LegacyPrecache_f( void )
for( i = 1, mod = clgame.sprites; i < MAX_CLIENT_SPRITES; i++, mod++ )
{
if( mod->needload == NL_UNREFERENCED && COM_CheckString( mod->name ))
Mod_UnloadSpriteModel( mod );
ref.dllFuncs.Mod_UnloadModel( mod );
}
// Mod_FreeUnused ();

View File

@ -989,7 +989,7 @@ void CL_InitClientMove( void )
// common utilities
clgame.pmove->PM_Info_ValueForKey = Info_ValueForKey;
clgame.pmove->PM_Particle = CL_Particle;
clgame.pmove->PM_Particle = ref.dllFuncs.CL_Particle; // ref should be initialized here already
clgame.pmove->PM_TestPlayerPosition = pfnTestPlayerPosition;
clgame.pmove->Con_NPrintf = Con_NPrintf;
clgame.pmove->Con_DPrintf = Con_DPrintf;

View File

@ -17,7 +17,6 @@ GNU General Public License for more details.
#include "client.h"
#include "net_encode.h"
#include "particledef.h"
#include "gl_local.h"
#include "cl_tent.h"
#include "shake.h"
#include "hltv.h"
@ -303,8 +302,8 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg )
// get splash name
if( cls.demoplayback && ( cls.demonum != -1 ))
Cvar_Set( "cl_levelshot_name", va( "levelshots/%s_%s", cls.demoname, glState.wideScreen ? "16x9" : "4x3" ));
else Cvar_Set( "cl_levelshot_name", va( "levelshots/%s_%s", clgame.mapname, glState.wideScreen ? "16x9" : "4x3" ));
Cvar_Set( "cl_levelshot_name", va( "levelshots/%s_%s", cls.demoname, refState.wideScreen ? "16x9" : "4x3" ));
else Cvar_Set( "cl_levelshot_name", va( "levelshots/%s_%s", clgame.mapname, refState.wideScreen ? "16x9" : "4x3" ));
Cvar_SetValue( "scr_loading", 0.0f ); // reset progress bar
if(( cl_allow_levelshots->value && !cls.changelevel ) || cl.background )
@ -684,7 +683,7 @@ static void CL_ParseQuakeStaticEntity( sizebuf_t *msg )
}
}
R_AddEfrags( ent ); // add link
ref.dllFuncs.R_AddEfrags( ent ); // add link
}
/*

View File

@ -15,7 +15,6 @@ GNU General Public License for more details.
#include "common.h"
#include "client.h"
#include "gl_local.h"
#include "studio.h"
/*
@ -101,7 +100,7 @@ Dupliacte texture with remap pixels
*/
void CL_DuplicateTexture( mstudiotexture_t *ptexture, int topcolor, int bottomcolor )
{
gl_texture_t *glt;
const char *name;
texture_t *tx = NULL;
char texname[128];
int i, index;
@ -111,13 +110,13 @@ void CL_DuplicateTexture( mstudiotexture_t *ptexture, int topcolor, int bottomco
// save off the real texture index
index = ptexture->index;
glt = R_GetTexture( index );
Q_snprintf( texname, sizeof( texname ), "#%i_%s", RI.currententity->curstate.number, glt->name + 1 );
name = ref.dllFuncs.R_GetTextureName( index );
Q_snprintf( texname, sizeof( texname ), "#%i_%s", refState.currententity->curstate.number, name + 1 );
// search for pixels
for( i = 0; i < RI.currentmodel->numtextures; i++ )
for( i = 0; i < refState.currentmodel->numtextures; i++ )
{
tx = RI.currentmodel->textures[i];
tx = refState.currentmodel->textures[i];
if( tx->gl_texturenum == index )
break; // found
}
@ -129,7 +128,7 @@ void CL_DuplicateTexture( mstudiotexture_t *ptexture, int topcolor, int bottomco
memcpy( paletteBackup, pal, 768 );
raw = CL_CreateRawTextureFromPixels( tx, &size, topcolor, bottomcolor );
ptexture->index = GL_LoadTexture( texname, raw, size, TF_FORCE_COLOR ); // do copy
ptexture->index = RefRenderAPI->GL_LoadTexture( texname, raw, size, TF_FORCE_COLOR ); // do copy
// restore original palette
memcpy( pal, paletteBackup, 768 );
@ -144,31 +143,31 @@ Update texture top and bottom colors
*/
void CL_UpdateStudioTexture( mstudiotexture_t *ptexture, int topcolor, int bottomcolor )
{
gl_texture_t *glt;
rgbdata_t *pic;
texture_t *tx = NULL;
char texname[128], name[128], mdlname[128];
const char *origtexname;
int i, index;
size_t size;
byte paletteBackup[768];
byte *raw, *pal;
// save off the real texture index
glt = R_GetTexture( ptexture->index );
origtexname = ref.dllFuncs.R_GetTextureName( ptexture->index );
// build name of original texture
Q_strncpy( mdlname, RI.currentmodel->name, sizeof( mdlname ));
Q_strncpy( mdlname, refState.currentmodel->name, sizeof( mdlname ));
COM_FileBase( ptexture->name, name );
COM_StripExtension( mdlname );
Q_snprintf( texname, sizeof( texname ), "#%s/%s.mdl", mdlname, name );
index = GL_FindTexture( texname );
index = RefRenderAPI->GL_FindTexture( texname );
if( !index ) return; // couldn't find texture
// search for pixels
for( i = 0; i < RI.currentmodel->numtextures; i++ )
for( i = 0; i < refState.currentmodel->numtextures; i++ )
{
tx = RI.currentmodel->textures[i];
tx = refState.currentmodel->textures[i];
if( tx->gl_texturenum == index )
break; // found
}
@ -180,14 +179,14 @@ void CL_UpdateStudioTexture( mstudiotexture_t *ptexture, int topcolor, int botto
memcpy( paletteBackup, pal, 768 );
raw = CL_CreateRawTextureFromPixels( tx, &size, topcolor, bottomcolor );
pic = FS_LoadImage( glt->name, raw, size );
pic = FS_LoadImage( origtexname, raw, size );
if( !pic )
{
Con_DPrintf( S_ERROR "Couldn't update texture %s\n", glt->name );
Con_DPrintf( S_ERROR "Couldn't update texture %s\n", origtexname );
return;
}
index = GL_UpdateTextureInternal( glt->name, pic, 0 );
index = GL_UpdateTextureInternal( origtexname, pic, 0 );
FS_FreeImage( pic );
// restore original palette
@ -209,15 +208,15 @@ void CL_UpdateAliasTexture( unsigned short *texture, int skinnum, int topcolor,
rgbdata_t skin, *pic;
texture_t *tx;
if( !texture || !RI.currentmodel->textures )
if( !texture || !refState.currentmodel->textures )
return; // no remapinfo in model
tx = RI.currentmodel->textures[skinnum];
tx = refState.currentmodel->textures[skinnum];
if( !tx ) return; // missing texture ?
if( *texture == 0 )
{
Q_snprintf( texname, sizeof( texname ), "%s:remap%i_%i", RI.currentmodel->name, skinnum, RI.currententity->index );
Q_snprintf( texname, sizeof( texname ), "%s:remap%i_%i", refState.currentmodel->name, skinnum, refState.currententity->index );
skin.width = tx->width;
skin.height = tx->height;
skin.depth = skin.numMips = 1;
@ -232,7 +231,7 @@ void CL_UpdateAliasTexture( unsigned short *texture, int skinnum, int topcolor,
}
// and now we can remap with internal routines
GL_ProcessTexture( *texture, -1.0f, topcolor, bottomcolor );
ref.dllFuncs.GL_ProcessTexture( *texture, -1.0f, topcolor, bottomcolor );
}
/*
@ -251,10 +250,10 @@ void CL_AllocRemapInfo( int topcolor, int bottomcolor )
mstudiotexture_t *src, *dst;
int i, size;
if( !RI.currententity ) return;
i = ( RI.currententity == &clgame.viewent ) ? clgame.maxEntities : RI.currententity->curstate.number;
if( !refState.currententity ) return;
i = ( refState.currententity == &clgame.viewent ) ? clgame.maxEntities : refState.currententity->curstate.number;
if( !RI.currentmodel || ( RI.currentmodel->type != mod_alias && RI.currentmodel->type != mod_studio ))
if( !refState.currentmodel || ( refState.currentmodel->type != mod_alias && refState.currentmodel->type != mod_studio ))
{
// entity has changed model by another type, release remap info
if( clgame.remap_info[i] )
@ -266,7 +265,7 @@ void CL_AllocRemapInfo( int topcolor, int bottomcolor )
}
// model doesn't contains remap textures
if( RI.currentmodel->numtextures <= 0 )
if( refState.currentmodel->numtextures <= 0 )
{
// entity has changed model with no remap textures
if( clgame.remap_info[i] )
@ -277,16 +276,16 @@ void CL_AllocRemapInfo( int topcolor, int bottomcolor )
return;
}
if( RI.currentmodel->type == mod_studio )
if( refState.currentmodel->type == mod_studio )
{
phdr = (studiohdr_t *)Mod_StudioExtradata( RI.currentmodel );
phdr = (studiohdr_t *)Mod_StudioExtradata( refState.currentmodel );
if( !phdr ) return; // bad model?
src = (mstudiotexture_t *)(((byte *)phdr) + phdr->textureindex);
dst = (clgame.remap_info[i] ? clgame.remap_info[i]->ptexture : NULL);
// NOTE: we must copy all the structures 'mstudiotexture_t' for easy access when model is rendering
if( !CL_CmpStudioTextures( phdr->numtextures, src, dst ) || clgame.remap_info[i]->model != RI.currentmodel )
if( !CL_CmpStudioTextures( phdr->numtextures, src, dst ) || clgame.remap_info[i]->model != refState.currentmodel )
{
// this code catches studiomodel change with another studiomodel with remap textures
// e.g. playermodel 'barney' with playermodel 'gordon'
@ -318,13 +317,13 @@ void CL_AllocRemapInfo( int topcolor, int bottomcolor )
CL_DuplicateTexture( &dst[i], topcolor, bottomcolor );
}
}
else if( RI.currentmodel->type == mod_alias )
else if( refState.currentmodel->type == mod_alias )
{
ahdr = (aliashdr_t *)Mod_AliasExtradata( RI.currentmodel );
ahdr = (aliashdr_t *)Mod_AliasExtradata( refState.currentmodel );
if( !ahdr ) return; // bad model?
// NOTE: we must copy all the structures 'mstudiotexture_t' for easy access when model is rendering
if( !clgame.remap_info[i] || clgame.remap_info[i]->model != RI.currentmodel )
if( !clgame.remap_info[i] || clgame.remap_info[i]->model != refState.currentmodel )
{
// this code catches studiomodel change with another studiomodel with remap textures
// e.g. playermodel 'barney' with playermodel 'gordon'
@ -337,7 +336,7 @@ void CL_AllocRemapInfo( int topcolor, int bottomcolor )
return;
}
info->numtextures = RI.currentmodel->numtextures;
info->numtextures = refState.currentmodel->numtextures;
// alias remapping is easy
CL_UpdateRemapInfo( topcolor, bottomcolor );
@ -348,7 +347,7 @@ void CL_AllocRemapInfo( int topcolor, int bottomcolor )
return;
}
info->model = RI.currentmodel;
info->model = refState.currentmodel;
}
/*
@ -363,7 +362,7 @@ void CL_UpdateRemapInfo( int topcolor, int bottomcolor )
remap_info_t *info;
int i;
i = ( RI.currententity == &clgame.viewent ) ? clgame.maxEntities : RI.currententity->curstate.number;
i = ( refState.currententity == &clgame.viewent ) ? clgame.maxEntities : refState.currententity->curstate.number;
info = clgame.remap_info[i];
if( !info ) return; // no remap info
@ -403,11 +402,11 @@ void CL_FreeRemapInfo( remap_info_t *info )
if( info->ptexture != NULL )
{
if( FBitSet( info->ptexture[i].flags, STUDIO_NF_COLORMAP ))
GL_FreeTexture( info->ptexture[i].index );
RefRenderAPI->GL_FreeTexture( info->ptexture[i].index );
}
if( info->textures[i] != 0 )
GL_FreeTexture( info->textures[i] );
RefRenderAPI->GL_FreeTexture( info->textures[i] );
}
Mem_Free( info ); // release struct

View File

@ -15,7 +15,6 @@ GNU General Public License for more details.
#include "common.h"
#include "client.h"
#include "gl_local.h"
#include "vgui_draw.h"
#include "qfont.h"
#include "input.h"
@ -99,7 +98,7 @@ void SCR_DrawFPS( int height )
}
Con_DrawStringLen( fpsstring, &offset, NULL );
Con_DrawString( glState.width - offset - 4, height, fpsstring, color );
Con_DrawString( refState.width - offset - 4, height, fpsstring, color );
}
/*
@ -148,7 +147,7 @@ void SCR_NetSpeeds( void )
Q_snprintf( msg, sizeof( msg ), "sv fps: ^1%4i min, ^3%4i cur, ^2%4i max\ncl fps: ^1%4i min, ^3%4i cur, ^2%4i max\nGame Time: %02d:%02d\nTotal received from server: %s\nTotal sent to server: %s\n",
min_svfps, cur_svfps, max_svfps, min_clfps, cur_clfps, max_clfps, (int)(time / 60.0f ), (int)fmod( time, 60.0f ), Q_memprint( cls.netchan.total_received ), Q_memprint( cls.netchan.total_sended ));
x = glState.width - 320;
x = refState.width - 320;
y = 384;
Con_DrawStringLen( NULL, NULL, &height );
@ -181,13 +180,13 @@ void SCR_RSpeeds( void )
if( !host.allow_console )
return;
if( R_SpeedsMessage( msg, sizeof( msg )))
if( RefRenderIface->R_SpeedsMessage( msg, sizeof( msg )))
{
int x, y, height;
char *p, *start, *end;
rgba_t color;
x = glState.width - 340;
x = refState.width - 340;
y = 64;
Con_DrawStringLen( NULL, NULL, &height );
@ -246,25 +245,25 @@ void SCR_MakeScreenShot( void )
switch( cls.scrshot_action )
{
case scrshot_normal:
iRet = VID_ScreenShot( cls.shotname, VID_SCREENSHOT );
iRet = ref.dllFuncs.VID_ScreenShot( cls.shotname, VID_SCREENSHOT );
break;
case scrshot_snapshot:
iRet = VID_ScreenShot( cls.shotname, VID_SNAPSHOT );
iRet = ref.dllFuncs.VID_ScreenShot( cls.shotname, VID_SNAPSHOT );
break;
case scrshot_plaque:
iRet = VID_ScreenShot( cls.shotname, VID_LEVELSHOT );
iRet = ref.dllFuncs.VID_ScreenShot( cls.shotname, VID_LEVELSHOT );
break;
case scrshot_savegame:
iRet = VID_ScreenShot( cls.shotname, VID_MINISHOT );
iRet = ref.dllFuncs.VID_ScreenShot( cls.shotname, VID_MINISHOT );
break;
case scrshot_envshot:
iRet = VID_CubemapShot( cls.shotname, viewsize, cls.envshot_vieworg, false );
iRet = ref.dllFuncs.VID_CubemapShot( cls.shotname, viewsize, cls.envshot_vieworg, false );
break;
case scrshot_skyshot:
iRet = VID_CubemapShot( cls.shotname, viewsize, cls.envshot_vieworg, true );
iRet = ref.dllFuncs.VID_CubemapShot( cls.shotname, viewsize, cls.envshot_vieworg, true );
break;
case scrshot_mapshot:
iRet = VID_ScreenShot( cls.shotname, VID_MAPSHOT );
iRet = ref.dllFuncs.VID_ScreenShot( cls.shotname, VID_MAPSHOT );
break;
case scrshot_inactive:
return;
@ -295,9 +294,9 @@ void SCR_DrawPlaque( void )
{
if(( cl_allow_levelshots->value && !cls.changelevel ) || cl.background )
{
int levelshot = GL_LoadTexture( cl_levelshot_name->string, NULL, 0, TF_IMAGE );
GL_SetRenderMode( kRenderNormal );
R_DrawStretchPic( 0, 0, glState.width, glState.height, 0, 0, 1, 1, levelshot );
int levelshot = RefRenderAPI->GL_LoadTexture( cl_levelshot_name->string, NULL, 0, TF_IMAGE );
ref.dllFuncs.GL_SetRenderMode( kRenderNormal );
ref.dllFuncs.R_DrawStretchPic( 0, 0, refState.width, refState.height, 0, 0, 1, 1, levelshot );
if( !cl.background ) CL_DrawHUD( CL_LOADING );
}
}
@ -367,7 +366,7 @@ SCR_DirtyScreen
void SCR_DirtyScreen( void )
{
SCR_AddDirtyPoint( 0, 0 );
SCR_AddDirtyPoint( glState.width - 1, glState.height - 1 );
SCR_AddDirtyPoint( refState.width - 1, refState.height - 1 );
}
/*
@ -419,7 +418,7 @@ void SCR_TileClear( void )
{
// clear above view screen
i = clear.y2 < top-1 ? clear.y2 : top - 1;
R_DrawTileClear( clear.x1, clear.y1, clear.x2 - clear.x1 + 1, i - clear.y1 + 1 );
ref.dllFuncs.R_DrawTileClear( clear.x1, clear.y1, clear.x2 - clear.x1 + 1, i - clear.y1 + 1 );
clear.y1 = top;
}
@ -427,7 +426,7 @@ void SCR_TileClear( void )
{
// clear below view screen
i = clear.y1 > bottom + 1 ? clear.y1 : bottom + 1;
R_DrawTileClear( clear.x1, i, clear.x2 - clear.x1 + 1, clear.y2 - i + 1 );
ref.dllFuncs.R_DrawTileClear( clear.x1, i, clear.x2 - clear.x1 + 1, clear.y2 - i + 1 );
clear.y2 = bottom;
}
@ -435,7 +434,7 @@ void SCR_TileClear( void )
{
// clear left of view screen
i = clear.x2 < left - 1 ? clear.x2 : left - 1;
R_DrawTileClear( clear.x1, clear.y1, i - clear.x1 + 1, clear.y2 - clear.y1 + 1 );
ref.dllFuncs.R_DrawTileClear( clear.x1, clear.y1, i - clear.x1 + 1, clear.y2 - clear.y1 + 1 );
clear.x1 = left;
}
@ -443,7 +442,7 @@ void SCR_TileClear( void )
{
// clear left of view screen
i = clear.x1 > right + 1 ? clear.x1 : right + 1;
R_DrawTileClear( i, clear.y1, clear.x2 - i + 1, clear.y2 - clear.y1 + 1 );
ref.dllFuncs.R_DrawTileClear( i, clear.y1, clear.x2 - i + 1, clear.y2 - clear.y1 + 1 );
clear.x2 = right;
}
}
@ -495,7 +494,7 @@ qboolean SCR_LoadFixedWidthFont( const char *fontname )
if( !FS_FileExists( fontname, false ))
return false;
cls.creditsFont.hFontTexture = GL_LoadTexture( fontname, NULL, 0, TF_IMAGE|TF_KEEP_SOURCE );
cls.creditsFont.hFontTexture = RefRenderAPI->GL_LoadTexture( fontname, NULL, 0, TF_IMAGE|TF_KEEP_SOURCE );
R_GetTextureParms( &fontWidth, NULL, cls.creditsFont.hFontTexture );
cls.creditsFont.charHeight = clgame.scrInfo.iCharHeight = fontWidth / 16;
cls.creditsFont.type = FONT_FIXED;
@ -527,7 +526,7 @@ qboolean SCR_LoadVariableWidthFont( const char *fontname )
if( !FS_FileExists( fontname, false ))
return false;
cls.creditsFont.hFontTexture = GL_LoadTexture( fontname, NULL, 0, TF_IMAGE );
cls.creditsFont.hFontTexture = RefRenderAPI->GL_LoadTexture( fontname, NULL, 0, TF_IMAGE );
R_GetTextureParms( &fontWidth, NULL, cls.creditsFont.hFontTexture );
// half-life font with variable chars witdh
@ -636,24 +635,24 @@ void SCR_RegisterTextures( void )
// register gfx.wad images
if( FS_FileExists( "gfx/paused.lmp", false ))
cls.pauseIcon = GL_LoadTexture( "gfx/paused.lmp", NULL, 0, TF_IMAGE );
cls.pauseIcon = RefRenderAPI->GL_LoadTexture( "gfx/paused.lmp", NULL, 0, TF_IMAGE );
else if( FS_FileExists( "gfx/pause.lmp", false ))
cls.pauseIcon = GL_LoadTexture( "gfx/pause.lmp", NULL, 0, TF_IMAGE );
cls.pauseIcon = RefRenderAPI->GL_LoadTexture( "gfx/pause.lmp", NULL, 0, TF_IMAGE );
if( FS_FileExists( "gfx/lambda.lmp", false ))
{
if( cl_allow_levelshots->value )
cls.loadingBar = GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE );
else cls.loadingBar = GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE );
cls.loadingBar = RefRenderAPI->GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE );
else cls.loadingBar = RefRenderAPI->GL_LoadTexture( "gfx/lambda.lmp", NULL, 0, TF_IMAGE );
}
else if( FS_FileExists( "gfx/loading.lmp", false ))
{
if( cl_allow_levelshots->value )
cls.loadingBar = GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE );
else cls.loadingBar = GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE );
cls.loadingBar = RefRenderAPI->GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE|TF_LUMINANCE );
else cls.loadingBar = RefRenderAPI->GL_LoadTexture( "gfx/loading.lmp", NULL, 0, TF_IMAGE );
}
cls.tileImage = GL_LoadTexture( "gfx/backtile.lmp", NULL, 0, TF_NOMIPMAP );
cls.tileImage = RefRenderAPI->GL_LoadTexture( "gfx/backtile.lmp", NULL, 0, TF_NOMIPMAP );
}
/*
@ -695,11 +694,11 @@ void SCR_VidInit( void )
// update screen sizes for menu
if( gameui.globals )
{
gameui.globals->scrWidth = glState.width;
gameui.globals->scrHeight = glState.height;
gameui.globals->scrWidth = refState.width;
gameui.globals->scrHeight = refState.height;
}
VGui_Startup( glState.width, glState.height );
VGui_Startup( refState.width, refState.height );
CL_ClearSpriteTextures(); // now all hud sprites are invalid

View File

@ -20,7 +20,6 @@ GNU General Public License for more details.
#include "triangleapi.h"
#include "cl_tent.h"
#include "pm_local.h"
#include "gl_local.h"
#include "studio.h"
#include "wadfile.h" // acess decal size
#include "sound.h"
@ -225,7 +224,7 @@ int CL_FxBlend( cl_entity_t *e )
blend = e->curstate.renderamt + 0x10 * sin( cl.time * 8 + offset );
break;
case kRenderFxFadeSlow:
if( RP_NORMALPASS( ))
if( ref.dllFuncs.IsNormalPass( ))
{
if( e->curstate.renderamt > 0 )
e->curstate.renderamt -= 1;
@ -234,7 +233,7 @@ int CL_FxBlend( cl_entity_t *e )
blend = e->curstate.renderamt;
break;
case kRenderFxFadeFast:
if( RP_NORMALPASS( ))
if( ref.dllFuncs.IsNormalPass( ))
{
if( e->curstate.renderamt > 3 )
e->curstate.renderamt -= 4;
@ -243,7 +242,7 @@ int CL_FxBlend( cl_entity_t *e )
blend = e->curstate.renderamt;
break;
case kRenderFxSolidSlow:
if( RP_NORMALPASS( ))
if( ref.dllFuncs.IsNormalPass( ))
{
if( e->curstate.renderamt < 255 )
e->curstate.renderamt += 1;
@ -252,7 +251,7 @@ int CL_FxBlend( cl_entity_t *e )
blend = e->curstate.renderamt;
break;
case kRenderFxSolidFast:
if( RP_NORMALPASS( ))
if( ref.dllFuncs.IsNormalPass( ))
{
if( e->curstate.renderamt < 252 )
e->curstate.renderamt += 4;
@ -288,8 +287,8 @@ int CL_FxBlend( cl_entity_t *e )
case kRenderFxHologram:
case kRenderFxDistort:
VectorCopy( e->origin, tmp );
VectorSubtract( tmp, RI.vieworg, tmp );
dist = DotProduct( tmp, RI.vforward );
VectorSubtract( tmp, refState.vieworg, tmp );
dist = DotProduct( tmp, refState.vforward );
// turn off distance fade
if( e->curstate.renderfx == kRenderFxDistort )
@ -522,7 +521,7 @@ int CL_TempEntAddEntity( cl_entity_t *pEntity )
// add to list
if( CL_AddVisibleEntity( pEntity, ET_TEMPENTITY ))
r_stats.c_active_tents_count++;
ref.dllFuncs.R_IncrementSpeedsCounter( RS_ACTIVE_TENTS );
return 1;
}
@ -2958,8 +2957,8 @@ void CL_TestLights( void )
r = 64 * ((i % 4) - 1.5f );
f = 64 * ( i / 4) + 128;
for( j = 0; j < 3; j++ )
dl->origin[j] = RI.vieworg[j] + RI.vforward[j] * f + RI.vright[j] * r;
VectorMAM( f, refState.vforward, r, refState.vright, dl->origin );
VectorAdd( dl->origin, refState.vieworg, dl->origin );
dl->color.r = ((((i % 6) + 1) & 1)>>0) * 255;
dl->color.g = ((((i % 6) + 1) & 2)>>1) * 255;
@ -2976,18 +2975,6 @@ DECAL MANAGEMENT
==============================================================
*/
/*
===============
CL_DecalShoot
normal temporary decal
===============
*/
void CL_DecalShoot( int textureIndex, int entityIndex, int modelIndex, float *pos, int flags )
{
R_DecalShoot( textureIndex, entityIndex, modelIndex, pos, flags, 1.0f );
}
/*
===============
CL_FireCustomDecal
@ -2997,7 +2984,19 @@ custom temporary decal
*/
void CL_FireCustomDecal( int textureIndex, int entityIndex, int modelIndex, float *pos, int flags, float scale )
{
R_DecalShoot( textureIndex, entityIndex, modelIndex, pos, flags, scale );
ref.dllFuncs.R_DecalShoot( textureIndex, entityIndex, modelIndex, pos, flags, scale );
}
/*
===============
CL_DecalShoot
normal temporary decal
===============
*/
void CL_DecalShoot( int textureIndex, int entityIndex, int modelIndex, float *pos, int flags )
{
CL_FireCustomDecal( textureIndex, entityIndex, modelIndex, pos, flags, 1.0f );
}
/*
@ -3028,7 +3027,7 @@ void CL_PlayerDecal( int playernum, int customIndex, int entityIndex, float *pos
}
}
R_DecalShoot( textureIndex, entityIndex, 0, pos, FDECAL_CUSTOM, 1.0f );
CL_DecalShoot( textureIndex, entityIndex, 0, pos, FDECAL_CUSTOM );
}
/*
@ -3068,7 +3067,7 @@ int CL_DecalIndex( int id )
if( cl.decal_index[id] == 0 )
{
Image_SetForceFlags( IL_LOAD_DECAL );
cl.decal_index[id] = GL_LoadTexture( host.draw_decals[id], NULL, 0, TF_DECAL );
cl.decal_index[id] = RefRenderAPI->GL_LoadTexture( host.draw_decals[id], NULL, 0, TF_DECAL );
Image_ClearForceFlags();
}
@ -3085,7 +3084,7 @@ remove all decals with specified texture
void CL_DecalRemoveAll( int textureIndex )
{
int id = bound( 0, textureIndex, MAX_DECALS - 1 );
R_DecalRemoveAll( cl.decal_index[id] );
ref.dllFuncs.R_DecalRemoveAll( cl.decal_index[id] );
}
/*
@ -3114,6 +3113,29 @@ void CL_ClearEfrags( void )
clgame.free_efrags[i].entnext = &clgame.free_efrags[i+1];
clgame.free_efrags[i].entnext = NULL;
}
/*
=======================
R_ClearStaticEntities
e.g. by demo request
=======================
*/
void CL_ClearStaticEntities( void )
{
int i;
if( host.type == HOST_DEDICATED )
return;
// clear out efrags in case the level hasn't been reloaded
for( i = 0; i < cl.worldmodel->numleafs; i++ )
cl.worldmodel->leafs[i+1].efrags = NULL;
clgame.numStatics = 0;
CL_ClearEfrags ();
}
/*
==============

View File

@ -101,20 +101,16 @@ void R_BeamKill( int deadEntity );
// TriAPI
void TriBegin( int mode );
void TriTexCoord2f( float u, float v );
void TriVertex3fv( const float *v );
void TriVertex3f( float x, float y, float z );
int TriBoxInPVS( float *mins, float *maxs );
void TriRenderMode( int mode );
void TriColor4f( float r, float g, float b, float a );
int TriSpriteTexture( model_t *pSpriteModel, int frame );
void TriColor4fRendermode( float r, float g, float b, float a, int rendermode );
int TriWorldToScreen( float *world, float *screen );
void TriColor4ub( byte r, byte g, byte b, byte a );
void TriBrightness( float brightness );
void TriRenderMode( int mode );
void TriCullFace( TRICULLSTYLE mode );
void TriEnd( void );
int TriWorldToScreen( float *world, float *screen );
int TriBoxInPVS( float *mins, float *maxs );
void TriLightAtPoint( float *pos, float *value );
void TriColor4fRendermode( float r, float g, float b, float a, int rendermode );
int TriSpriteTexture( model_t *pSpriteModel, int frame );
extern model_t *cl_sprite_dot;
extern model_t *cl_sprite_shell;

View File

@ -15,7 +15,6 @@ GNU General Public License for more details.
#include "common.h"
#include "client.h"
#include "gl_local.h"
/*
=================================================================
@ -180,7 +179,7 @@ qboolean SCR_DrawCinematic( void )
qboolean redraw = false;
byte *frame = NULL;
if( !glw_state.initialized || cin_time <= 0.0f )
if( !ref.initialized || cin_time <= 0.0f )
return false;
if( cin_frame != last_frame )
@ -190,7 +189,7 @@ qboolean SCR_DrawCinematic( void )
redraw = true;
}
R_DrawStretchRaw( 0, 0, glState.width, glState.height, xres, yres, frame, redraw );
ref.dllFuncs.R_DrawStretchRaw( 0, 0, refState.width, refState.height, xres, yres, frame, redraw );
return true;
}

View File

@ -17,7 +17,6 @@ GNU General Public License for more details.
#include "client.h"
#include "const.h"
#include "entity_types.h"
#include "gl_local.h"
#include "vgui_draw.h"
#include "sound.h"
@ -59,17 +58,17 @@ void V_CalcViewRect( void )
}
size /= 100.0;
clgame.viewport[2] = glState.width * size;
clgame.viewport[3] = glState.height * size;
clgame.viewport[2] = refState.width * size;
clgame.viewport[3] = refState.height * size;
if( clgame.viewport[3] > glState.height - sb_lines )
clgame.viewport[3] = glState.height - sb_lines;
if( clgame.viewport[3] > glState.height )
clgame.viewport[3] = glState.height;
if( clgame.viewport[3] > refState.height - sb_lines )
clgame.viewport[3] = refState.height - sb_lines;
if( clgame.viewport[3] > refState.height )
clgame.viewport[3] = refState.height;
clgame.viewport[0] = ( glState.width - clgame.viewport[2] ) / 2;
clgame.viewport[0] = ( refState.width - clgame.viewport[2] ) / 2;
if( full ) clgame.viewport[1] = 0;
else clgame.viewport[1] = ( glState.height - sb_lines - clgame.viewport[3] ) / 2;
else clgame.viewport[1] = ( refState.height - sb_lines - clgame.viewport[3] ) / 2;
}
@ -113,8 +112,8 @@ void V_SetRefParams( ref_params_t *fd )
memset( fd, 0, sizeof( ref_params_t ));
// probably this is not needs
VectorCopy( RI.vieworg, fd->vieworg );
VectorCopy( RI.viewangles, fd->viewangles );
VectorCopy( refState.vieworg, fd->vieworg );
VectorCopy( refState.viewangles, fd->viewangles );
fd->frametime = host.frametime;
fd->time = cl.time;
@ -183,7 +182,7 @@ void V_RefApplyOverview( ref_viewpass_t *rvp )
return;
// NOTE: Xash3D may use 16:9 or 16:10 aspects
aspect = (float)glState.width / (float)glState.height;
aspect = (float)refState.width / (float)refState.height;
size_x = fabs( 8192.0f / ov->flZoom );
size_y = fabs( 8192.0f / (ov->flZoom * aspect ));
@ -216,7 +215,7 @@ void V_RefApplyOverview( ref_viewpass_t *rvp )
SetBits( rvp->flags, RF_DRAW_OVERVIEW );
Mod_SetOrthoBounds( mins, maxs );
RefRenderIface->GL_OrthoBounds( mins, maxs );
}
/*
@ -254,7 +253,7 @@ void V_GetRefParams( ref_params_t *fd, ref_viewpass_t *rvp )
rvp->fov_y = V_CalcFov( &rvp->fov_x, clgame.viewport[2], clgame.viewport[3] );
// adjust FOV for widescreen
if( glState.wideScreen && r_adjust_fov->value )
if( refState.wideScreen && r_adjust_fov->value )
V_AdjustFov( &rvp->fov_x, &rvp->fov_y, clgame.viewport[2], clgame.viewport[3], false );
rvp->flags = 0;
@ -273,7 +272,7 @@ V_PreRender
qboolean V_PreRender( void )
{
// too early
if( !glw_state.initialized )
if( !ref.initialized )
return false;
if( host.status == HOST_NOFOCUS )
@ -293,7 +292,7 @@ qboolean V_PreRender( void )
return false;
}
R_BeginFrame( !cl.paused );
ref.dllFuncs.R_BeginFrame( !cl.paused );
return true;
}
@ -318,9 +317,9 @@ void V_RenderView( void )
V_CalcViewRect (); // compute viewport rectangle
V_SetRefParams( &rp );
V_SetupViewModel ();
R_Set2DMode( false );
ref.dllFuncs.R_Set2DMode( false );
SCR_DirtyScreen();
GL_BackendStartFrame ();
ref.dllFuncs.GL_BackendStartFrame ();
do
{
@ -330,11 +329,15 @@ void V_RenderView( void )
if( viewnum == 0 && FBitSet( rvp.flags, RF_ONLY_CLIENTDRAW ))
{
#if 0
pglClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
pglClear( GL_COLOR_BUFFER_BIT );
#else
ref.dllFuncs.R_ClearScreen();
#endif
}
R_RenderFrame( &rvp );
RefRenderIface->GL_RenderFrame( &rvp );
S_UpdateFrame( &rvp );
viewnum++;
@ -342,7 +345,7 @@ void V_RenderView( void )
// draw debug triangles on a server
SV_DrawDebugTriangles ();
GL_BackendEndFrame ();
ref.dllFuncs.GL_BackendEndFrame ();
}
/*
@ -356,8 +359,8 @@ void V_PostRender( void )
static double oldtime;
qboolean draw_2d = false;
R_AllowFog( false );
R_Set2DMode( true );
ref.dllFuncs.R_AllowFog( false );
ref.dllFuncs.R_Set2DMode( true );
if( cls.state == ca_active && cls.signon == SIGNONS && cls.scrshot_action != scrshot_mapshot )
{
@ -383,8 +386,8 @@ void V_PostRender( void )
SV_DrawOrthoTriangles();
CL_DrawDemoRecording();
CL_DrawHUD( CL_CHANGELEVEL );
R_ShowTextures();
R_ShowTree();
ref.dllFuncs.R_ShowTextures();
ref.dllFuncs.R_ShowTree();
Con_DrawConsole();
UI_UpdateMenu( host.realtime );
Con_DrawVersion();
@ -394,6 +397,6 @@ void V_PostRender( void )
}
SCR_MakeScreenShot();
R_AllowFog( true );
R_EndFrame();
ref.dllFuncs.R_AllowFog( true );
ref.dllFuncs.R_EndFrame();
}

View File

@ -31,6 +31,7 @@ GNU General Public License for more details.
#include "netchan.h"
#include "net_api.h"
#include "world.h"
#include "ref_common.h"
#define MAX_DEMOS 32
#define MAX_MOVIES 8
@ -378,7 +379,7 @@ typedef struct
qboolean adjust_size; // allow to adjust scale for fonts
int renderMode; // override kRenderMode from TriAPI
int cullMode; // override CULL FACE from TriAPI
TRICULLSTYLE cullMode; // override CULL FACE from TriAPI
// holds text color
rgba_t textColor;

View File

@ -18,7 +18,6 @@ GNU General Public License for more details.
#include "keydefs.h"
#include "protocol.h" // get the protocol version
#include "con_nprint.h"
#include "gl_local.h"
#include "qfont.h"
#include "wadfile.h"
@ -443,8 +442,8 @@ void Con_CheckResize( void )
if( con.curFont && con.curFont->hFontTexture )
charWidth = con.curFont->charWidths['O'] - 1;
width = ( glState.width / charWidth ) - 2;
if( !glw_state.initialized ) width = (640 / 5);
width = ( refState.width / charWidth ) - 2;
if( !ref.initialized ) width = (640 / 5);
if( width == con.linewidth )
return;
@ -532,7 +531,7 @@ static qboolean Con_LoadFixedWidthFont( const char *fontname, cl_font_t *font )
return false;
// keep source to print directly into conback image
font->hFontTexture = GL_LoadTexture( fontname, NULL, 0, TF_FONT|TF_KEEP_SOURCE );
font->hFontTexture = RefRenderAPI->GL_LoadTexture( fontname, NULL, 0, TF_FONT|TF_KEEP_SOURCE );
R_GetTextureParms( &fontWidth, NULL, font->hFontTexture );
if( font->hFontTexture && fontWidth != 0 )
@ -568,7 +567,7 @@ static qboolean Con_LoadVariableWidthFont( const char *fontname, cl_font_t *font
if( !FS_FileExists( fontname, false ))
return false;
font->hFontTexture = GL_LoadTexture( fontname, NULL, 0, TF_FONT|TF_NEAREST );
font->hFontTexture = RefRenderAPI->GL_LoadTexture( fontname, NULL, 0, TF_FONT|TF_NEAREST );
R_GetTextureParms( &fontWidth, NULL, font->hFontTexture );
// setup consolefont
@ -651,9 +650,9 @@ static void Con_LoadConchars( void )
Con_LoadConsoleFont( i, con.chars + i );
// select properly fontsize
if( glState.width <= 640 )
if( refState.width <= 640 )
fontSize = 0;
else if( glState.width >= 1280 )
else if( refState.width >= 1280 )
fontSize = 2;
else fontSize = 1;
@ -805,7 +804,7 @@ int Con_UtfMoveRight( char *str, int pos, int length )
return pos+1;
}
static void Con_DrawCharToConback( int num, byte *conchars, byte *dest )
static void Con_DrawCharToConback( int num, const byte *conchars, byte *dest )
{
int row, col;
byte *source;
@ -843,8 +842,8 @@ static void Con_TextAdjustSize( int *x, int *y, int *w, int *h )
if( !x && !y && !w && !h ) return;
// scale for screen sizes
xscale = (float)glState.width / (float)clgame.scrInfo.iWidth;
yscale = (float)glState.height / (float)clgame.scrInfo.iHeight;
xscale = (float)refState.width / (float)clgame.scrInfo.iWidth;
yscale = (float)refState.height / (float)clgame.scrInfo.iHeight;
if( x ) *x *= xscale;
if( y ) *y *= yscale;
@ -863,7 +862,6 @@ static int Con_DrawGenericChar( int x, int y, int number, rgba_t color )
{
int width, height;
float s1, t1, s2, t2;
gl_texture_t *glt;
wrect_t *rc;
number &= 255;
@ -879,18 +877,15 @@ static int Con_DrawGenericChar( int x, int y, int number, rgba_t color )
return 0;
rc = &con.curFont->fontRc[number];
glt = R_GetTexture( con.curFont->hFontTexture );
width = glt->srcWidth;
height = glt->srcHeight;
R_GetTextureParms( &width, &height, con.curFont->hFontTexture );
if( !width || !height )
return con.curFont->charWidths[number];
// don't apply color to fixed fonts it's already colored
if( con.curFont->type != FONT_FIXED || glt->format == GL_LUMINANCE8_ALPHA8 )
pglColor4ubv( color );
else pglColor4ub( 255, 255, 255, color[3] );
R_GetTextureParms( &width, &height, con.curFont->hFontTexture );
if( con.curFont->type != FONT_FIXED || RENDER_GET_PARM( PARM_TEX_GLFORMAT, 0x8045 ) ) // GL_LUMINANCE8_ALPHA8
ref.dllFuncs.Color4ub( color[0], color[1], color[2], color[3] );
else ref.dllFuncs.Color4ub( 255, 255, 255, color[3] );
// calc rectangle
s1 = (float)rc->left / width;
@ -902,8 +897,8 @@ static int Con_DrawGenericChar( int x, int y, int number, rgba_t color )
if( clgame.ds.adjust_size )
Con_TextAdjustSize( &x, &y, &width, &height );
R_DrawStretchPic( x, y, width, height, s1, t1, s2, t2, con.curFont->hFontTexture );
pglColor4ub( 255, 255, 255, 255 ); // don't forget reset color
ref.dllFuncs.R_DrawStretchPic( x, y, width, height, s1, t1, s2, t2, con.curFont->hFontTexture );
ref.dllFuncs.Color4ub( 255, 255, 255, 255 ); // don't forget reset color
return con.curFont->charWidths[number];
}
@ -943,7 +938,7 @@ client version of routine
*/
int Con_DrawCharacter( int x, int y, int number, rgba_t color )
{
GL_SetRenderMode( kRenderTransTexture );
ref.dllFuncs.GL_SetRenderMode( kRenderTransTexture );
return Con_DrawGenericChar( x, y, number, color );
}
@ -1064,7 +1059,7 @@ int Con_DrawGenericString( int x, int y, const char *string, rgba_t setColor, qb
s++;
}
pglColor4ub( 255, 255, 255, 255 );
ref.dllFuncs.Color4ub( 255, 255, 255, 255 );
return drawLen;
}
@ -1627,10 +1622,12 @@ void Field_DrawInputLine( int x, int y, field_t *edit )
if( host.key_overstrike && cursorChar )
{
// overstrike cursor
#if 0
pglEnable( GL_BLEND );
pglDisable( GL_ALPHA_TEST );
pglBlendFunc( GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA );
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
#endif
Con_DrawGenericChar( x + curPos, y, cursorChar, colorDefault );
}
else
@ -1854,7 +1851,7 @@ int Con_DrawDebugLines( void )
int defaultX;
int y = 20;
defaultX = glState.width / 4;
defaultX = refState.width / 4;
for( i = 0; i < MAX_DBG_NOTIFY; i++ )
{
@ -1864,10 +1861,10 @@ int Con_DrawDebugLines( void )
int fontTall;
Con_DrawStringLen( con.notify[i].szNotify, &len, &fontTall );
x = glState.width - Q_max( defaultX, len ) - 10;
x = refState.width - Q_max( defaultX, len ) - 10;
fontTall += 1;
if( y + fontTall > glState.height - 20 )
if( y + fontTall > refState.height - 20 )
return count;
count++;
@ -1896,7 +1893,7 @@ void Con_DrawDebug( void )
{
Q_snprintf( dlstring, sizeof( dlstring ), "Downloading [%d remaining]: ^2%s^7 %5.1f%% time %.f secs",
host.downloadcount, host.downloadfile, scr_download->value, Sys_DoubleTime() - timeStart );
x = glState.width - 500;
x = refState.width - 500;
y = con.curFont->charHeight * 1.05f;
Con_DrawString( x, y, dlstring, g_color_table[7] );
}
@ -1962,7 +1959,7 @@ void Con_DrawNotify( void )
Field_DrawInputLine( x + len, y, &con.chat );
}
pglColor4ub( 255, 255, 255, 255 );
ref.dllFuncs.Color4ub( 255, 255, 255, 255 );
}
/*
@ -2034,9 +2031,9 @@ void Con_DrawSolidConsole( int lines )
if( lines <= 0 ) return;
// draw the background
GL_SetRenderMode( kRenderNormal );
pglColor4ub( 255, 255, 255, 255 ); // to prevent grab color from screenfade
R_DrawStretchPic( 0, lines - glState.width * 3 / 4, glState.width, glState.width * 3 / 4, 0, 0, 1, 1, con.background );
ref.dllFuncs.GL_SetRenderMode( kRenderNormal );
ref.dllFuncs.Color4ub( 255, 255, 255, 255 ); // to prevent grab color from screenfade
ref.dllFuncs.R_DrawStretchPic( 0, lines - refState.width * 3 / 4, refState.width, refState.width * 3 / 4, 0, 0, 1, 1, con.background );
if( !con.curFont || !host.allow_console )
return; // nothing to draw
@ -2054,10 +2051,10 @@ void Con_DrawSolidConsole( int lines )
Q_snprintf( curbuild, MAX_STRING, "%s %i/%s (%s-%s build %i)", XASH_ENGINE_NAME, PROTOCOL_VERSION, XASH_VERSION, Q_buildos(), Q_buildarch(), Q_buildnum( ));
Con_DrawStringLen( curbuild, &stringLen, &charH );
start = glState.width - stringLen;
start = refState.width - stringLen;
stringLen = Con_StringLength( curbuild );
fraction = lines / (float)glState.height;
fraction = lines / (float)refState.height;
color[3] = Q_min( fraction * 2.0f, 1.0f ) * 255; // fadeout version number
for( i = 0; i < stringLen; i++ )
@ -2101,7 +2098,7 @@ void Con_DrawSolidConsole( int lines )
y = lines - ( con.curFont->charHeight * 1.2f );
SCR_DrawFPS( max( y, 4 )); // to avoid to hide fps counter
pglColor4ub( 255, 255, 255, 255 );
ref.dllFuncs.Color4ub( 255, 255, 255, 255 );
}
/*
@ -2124,7 +2121,7 @@ void Con_DrawConsole( void )
{
if(( Cvar_VariableInteger( "cl_background" ) || Cvar_VariableInteger( "sv_background" )) && cls.key_dest != key_console )
con.vislines = con.showlines = 0;
else con.vislines = con.showlines = glState.height;
else con.vislines = con.showlines = refState.height;
}
else
{
@ -2141,7 +2138,7 @@ void Con_DrawConsole( void )
case ca_disconnected:
if( cls.key_dest != key_menu )
{
Con_DrawSolidConsole( glState.height );
Con_DrawSolidConsole( refState.height );
Key_SetKeyDest( key_console );
}
break;
@ -2156,7 +2153,7 @@ void Con_DrawConsole( void )
if( Cvar_VariableInteger( "cl_background" ) || Cvar_VariableInteger( "sv_background" ))
{
if( cls.key_dest == key_console )
Con_DrawSolidConsole( glState.height );
Con_DrawSolidConsole( refState.height );
}
else
{
@ -2183,7 +2180,7 @@ void Con_DrawVersion( void )
// draws the current build
byte *color = g_color_table[7];
int i, stringLen, width = 0, charH;
int start, height = glState.height;
int start, height = refState.height;
qboolean draw_version = false;
string curbuild;
@ -2209,7 +2206,7 @@ void Con_DrawVersion( void )
else Q_snprintf( curbuild, MAX_STRING, "v%i/%s (%s-%s build %i)", PROTOCOL_VERSION, XASH_VERSION, Q_buildos(), Q_buildarch(), Q_buildnum( ));
Con_DrawStringLen( curbuild, &stringLen, &charH );
start = glState.width - stringLen * 1.05f;
start = refState.width - stringLen * 1.05f;
stringLen = Con_StringLength( curbuild );
height -= charH * 1.05f;
@ -2232,8 +2229,8 @@ void Con_RunConsole( void )
if( host.allow_console && cls.key_dest == key_console )
{
if( cls.state < ca_active || cl.first_frame )
con.showlines = glState.height; // full screen
else con.showlines = (glState.height >> 1); // half screen
con.showlines = refState.height; // full screen
else con.showlines = (refState.height >> 1); // half screen
}
else con.showlines = 0; // none visible
@ -2322,28 +2319,28 @@ void Con_VidInit( void )
{
// trying to load truecolor image first
if( FS_FileExists( "gfx/shell/conback.bmp", false ) || FS_FileExists( "gfx/shell/conback.tga", false ))
con.background = GL_LoadTexture( "gfx/shell/conback", NULL, 0, TF_IMAGE );
con.background = RefRenderAPI->GL_LoadTexture( "gfx/shell/conback", NULL, 0, TF_IMAGE );
if( !con.background )
{
if( FS_FileExists( "cached/conback640", false ))
con.background = GL_LoadTexture( "cached/conback640", NULL, 0, TF_IMAGE );
con.background = RefRenderAPI->GL_LoadTexture( "cached/conback640", NULL, 0, TF_IMAGE );
else if( FS_FileExists( "cached/conback", false ))
con.background = GL_LoadTexture( "cached/conback", NULL, 0, TF_IMAGE );
con.background = RefRenderAPI->GL_LoadTexture( "cached/conback", NULL, 0, TF_IMAGE );
}
}
else
{
// trying to load truecolor image first
if( FS_FileExists( "gfx/shell/loading.bmp", false ) || FS_FileExists( "gfx/shell/loading.tga", false ))
con.background = GL_LoadTexture( "gfx/shell/loading", NULL, 0, TF_IMAGE );
con.background = RefRenderAPI->GL_LoadTexture( "gfx/shell/loading", NULL, 0, TF_IMAGE );
if( !con.background )
{
if( FS_FileExists( "cached/loading640", false ))
con.background = GL_LoadTexture( "cached/loading640", NULL, 0, TF_IMAGE );
con.background = RefRenderAPI->GL_LoadTexture( "cached/loading640", NULL, 0, TF_IMAGE );
else if( FS_FileExists( "cached/loading", false ))
con.background = GL_LoadTexture( "cached/loading", NULL, 0, TF_IMAGE );
con.background = RefRenderAPI->GL_LoadTexture( "cached/loading", NULL, 0, TF_IMAGE );
}
}
@ -2352,7 +2349,7 @@ void Con_VidInit( void )
{
qboolean draw_to_console = false;
int length = 0;
gl_texture_t *chars;
byte *buf;
// NOTE: only these games want to draw build number into console background
if( !Q_stricmp( FS_Gamedir(), "id1" ))
@ -2364,7 +2361,8 @@ void Con_VidInit( void )
if( !Q_stricmp( FS_Gamedir(), "rogue" ))
draw_to_console = true;
if( draw_to_console && con.curFont && ( chars = R_GetTexture( con.curFont->hFontTexture )) != NULL && chars->original )
if( draw_to_console && con.curFont &&
( buf = ref.dllFuncs.R_GetTextureOriginalBuffer( con.curFont->hFontTexture )) != NULL )
{
lmp_t *cb = (lmp_t *)FS_LoadFile( "gfx/conback.lmp", &length, false );
char ver[64];
@ -2377,19 +2375,19 @@ void Con_VidInit( void )
dest = (byte *)(cb + 1) + 320 * 186 + 320 - 11 - 8 * Q_strlen( ver );
y = Q_strlen( ver );
for( x = 0; x < y; x++ )
Con_DrawCharToConback( ver[x], chars->original->buffer, dest + (x << 3));
con.background = GL_LoadTexture( "#gfx/conback.lmp", (byte *)cb, length, TF_IMAGE );
Con_DrawCharToConback( ver[x], buf, dest + (x << 3));
con.background = RefRenderAPI->GL_LoadTexture( "#gfx/conback.lmp", (byte *)cb, length, TF_IMAGE );
}
if( cb ) Mem_Free( cb );
}
if( !con.background ) // trying the load unmodified conback
con.background = GL_LoadTexture( "gfx/conback.lmp", NULL, 0, TF_IMAGE );
con.background = RefRenderAPI->GL_LoadTexture( "gfx/conback.lmp", NULL, 0, TF_IMAGE );
}
// missed console image will be replaced as gray background like X-Ray or Crysis
if( con.background == tr.defaultTexture || con.background == 0 )
con.background = tr.grayTexture;
if( con.background == ref.dllFuncs.R_GetBuiltinTexture( REF_DEFAULT_TEXTURE ) || con.background == 0 )
con.background = ref.dllFuncs.R_GetBuiltinTexture( REF_GRAY_TEXTURE );
}
/*

View File

@ -20,7 +20,6 @@ GNU General Public License for more details.
#include "input.h"
#include "keydefs.h"
#include "client.h"
#include "gl_local.h"
#include "platform/platform.h"
#ifndef SHRT_MAX

File diff suppressed because it is too large Load Diff

View File

@ -17,7 +17,6 @@ GNU General Public License for more details.
#include "input.h"
#include "client.h"
#include "vgui_draw.h"
#include "gl_local.h"
#ifdef XASH_SDL
#include <SDL.h>
@ -143,7 +142,7 @@ void IN_ToggleClientMouse( int newstate, int oldstate )
{
// reset mouse pos, so cancel effect in game
#ifdef XASH_SDL
if( touch_enable->value )
if( 0 ) // touch_enable->value )
{
SDL_SetRelativeMouseMode( SDL_FALSE );
SDL_SetWindowGrab( host.hWnd, SDL_FALSE );
@ -518,7 +517,7 @@ void IN_CollectInput( float *forward, float *side, float *pitch, float *yaw, qbo
}
Joy_FinalizeMove( forward, side, yaw, pitch );
IN_TouchMove( forward, side, yaw, pitch );
// IN_TouchMove( forward, side, yaw, pitch );
if( look_filter->value )
{
@ -551,15 +550,15 @@ void IN_EngineAppendMove( float frametime, usercmd_t *cmd, qboolean active )
if( active )
{
float sensitivity = ( (float)RI.fov_x / (float)90.0f );
float sensitivity = ( (float)refState.fov_x / (float)90.0f );
IN_CollectInput( &forward, &side, &pitch, &yaw, in_mouseinitialized, m_enginemouse->value );
IN_JoyAppendMove( cmd, forward, side );
RI.viewangles[YAW] += yaw * sensitivity;
RI.viewangles[PITCH] += pitch * sensitivity;
RI.viewangles[PITCH] = bound( -90, RI.viewangles[PITCH], 90 );
refState.viewangles[YAW] += yaw * sensitivity;
refState.viewangles[PITCH] += pitch * sensitivity;
refState.viewangles[PITCH] = bound( -90, refState.viewangles[PITCH], 90 );
}
}

View File

@ -1,5 +1,5 @@
/*
mod_bmodel.c - loading & handling world and brushmodels
mod_dbghulls.c - loading & handling world and brushmodels
Copyright (C) 2016 Uncle Mike
This program is free software: you can redistribute it and/or modify
@ -16,7 +16,6 @@ GNU General Public License for more details.
#include "mod_local.h"
#include "mathlib.h"
#include "world.h"
#include "gl_local.h"
#include "client.h"
#define MAX_CLIPNODE_DEPTH 256 // should never exceeds
@ -713,66 +712,3 @@ void Mod_ReleaseHullPolygons( void )
}
world.num_hull_models = 0;
}
void R_DrawWorldHull( void )
{
hull_model_t *hull = &world.hull_models[0];
winding_t *poly;
int i;
if( FBitSet( r_showhull->flags, FCVAR_CHANGED ))
{
int val = bound( 0, (int)r_showhull->value, 3 );
if( val ) Mod_CreatePolygonsForHull( val );
ClearBits( r_showhull->flags, FCVAR_CHANGED );
}
if( !CVAR_TO_BOOL( r_showhull ))
return;
pglDisable( GL_TEXTURE_2D );
list_for_each_entry( poly, &hull->polys, chain )
{
srand((unsigned int)poly);
pglColor3f( rand() % 256 / 255.0, rand() % 256 / 255.0, rand() % 256 / 255.0 );
pglBegin( GL_POLYGON );
for( i = 0; i < poly->numpoints; i++ )
pglVertex3fv( poly->p[i] );
pglEnd();
}
pglEnable( GL_TEXTURE_2D );
}
void R_DrawModelHull( void )
{
hull_model_t *hull;
winding_t *poly;
int i;
if( !CVAR_TO_BOOL( r_showhull ))
return;
if( !RI.currentmodel || RI.currentmodel->name[0] != '*' )
return;
i = atoi( RI.currentmodel->name + 1 );
if( i < 1 || i >= world.num_hull_models )
return;
hull = &world.hull_models[i];
pglPolygonOffset( 1.0f, 2.0 );
pglEnable( GL_POLYGON_OFFSET_FILL );
pglDisable( GL_TEXTURE_2D );
list_for_each_entry( poly, &hull->polys, chain )
{
srand((unsigned int)poly);
pglColor3f( rand() % 256 / 255.0, rand() % 256 / 255.0, rand() % 256 / 255.0 );
pglBegin( GL_POLYGON );
for( i = 0; i < poly->numpoints; i++ )
pglVertex3fv( poly->p[i] );
pglEnd();
}
pglEnable( GL_TEXTURE_2D );
pglDisable( GL_POLYGON_OFFSET_FILL );
}

189
engine/client/ref_common.c Normal file
View File

@ -0,0 +1,189 @@
#include "common.h"
#include "client.h"
#include "library.h"
#include "cl_tent.h"
struct ref_state_s ref;
ref_globals_t refState;
convar_t *gl_vsync;
convar_t *gl_showtextures;
convar_t *vid_displayfrequency;
convar_t *vid_fullscreen;
convar_t *r_decals;
convar_t *r_adjust_fov;
void R_GetTextureParms( int *w, int *h, int texnum )
{
if( w ) *w = RENDER_GET_PARM( PARM_TEX_WIDTH, texnum );
if( h ) *h = RENDER_GET_PARM( PARM_TEX_HEIGHT, texnum );
}
void VID_InitDefaultResolution( void )
{
refState.width = 640;
refState.height = 480;
}
/*
================
GL_FreeImage
Frees image by name
================
*/
void GL_FreeImage( const char *name )
{
int texnum;
if(( texnum = RefRenderAPI->GL_FindTexture( name )) != 0 )
RefRenderAPI->GL_FreeTexture( texnum );
}
static int TriGetRenderMode( void )
{
return clgame.ds.renderMode;
}
static ref_api_t gEngfuncs =
{
TriGetRenderMode
};
static void R_UnloadProgs( void )
{
if( !ref.hInstance ) return;
// deinitialize renderer
ref.dllFuncs.R_Shutdown();
Cvar_FullSet( "host_refloaded", "0", FCVAR_READ_ONLY );
COM_FreeLibrary( ref.hInstance );
ref.hInstance = NULL;
memset( &refState, 0, sizeof( refState ));
Cvar_Unlink( FCVAR_RENDERINFO | FCVAR_GLCONFIG );
Cmd_Unlink( CMD_REFDLL );
}
static void CL_FillTriAPIFromRef( triangleapi_t *dst, const ref_interface_t *src )
{
dst->version = TRI_API_VERSION;
dst->Begin = src->Begin;
dst->RenderMode = TriRenderMode;
dst->End = src->End;
dst->Color4f = TriColor4f;
dst->Color4ub = TriColor4ub;
dst->TexCoord2f = src->TexCoord2f;
dst->Vertex3f = src->Vertex3f;
dst->Vertex3fv = src->Vertex3fv;
dst->Brightness = TriBrightness;
dst->CullFace = TriCullFace;
dst->SpriteTexture = TriSpriteTexture;
dst->WorldToScreen = TriWorldToScreen;
dst->Fog = src->Fog;
dst->ScreenToWorld = src->ScreenToWorld;
dst->GetMatrix = src->GetMatrix;
dst->BoxInPVS = TriBoxInPVS;
dst->LightAtPoint = TriLightAtPoint;
dst->Color4fRendermode = TriColor4fRendermode;
dst->FogParams = src->FogParams;
}
static qboolean R_LoadProgs( const char *name )
{
extern triangleapi_t gTriApi;
static ref_api_t gpEngfuncs;
REFAPI GetRefAPI; // single export
if( ref.hInstance ) R_UnloadProgs();
#ifdef XASH_INTERNAL_GAMELIBS
if( !(ref.hInstance = COM_LoadLibrary( name, false, true ) ))
{
return false;
}
#else
if( !(ref.hInstance = COM_LoadLibrary( name, false, true ) ))
{
FS_AllowDirectPaths( true );
if( !(ref.hInstance = COM_LoadLibrary( name, false, true ) ))
{
FS_AllowDirectPaths( false );
return false;
}
}
#endif
FS_AllowDirectPaths( false );
if( ( GetRefAPI = (REFAPI)COM_GetProcAddress( ref.hInstance, "GetRefAPI" )) == NULL )
{
COM_FreeLibrary( ref.hInstance );
Con_Reportf( "R_LoadProgs: can't init renderer API\n" );
ref.hInstance = NULL;
return false;
}
// make local copy of engfuncs to prevent overwrite it with user dll
memcpy( &gpEngfuncs, &gEngfuncs, sizeof( gpEngfuncs ));
if( !GetRefAPI( REF_API_VERSION, &ref.dllFuncs, &gpEngfuncs, &refState ))
{
COM_FreeLibrary( ref.hInstance );
Con_Reportf( "R_LoadProgs: can't init renderer API: wrong version\n" );
ref.hInstance = NULL;
return false;
}
refState.developer = host.allow_console;
if( !ref.dllFuncs.R_Init( true ) )
{
COM_FreeLibrary( ref.hInstance );
Con_Reportf( "R_LoadProgs: can't init renderer: %s\n", ref.dllFuncs.R_GetInitError() );
ref.hInstance = NULL;
return false;
}
Cvar_FullSet( "host_refloaded", "1", FCVAR_READ_ONLY );
ref.initialized = true;
// initialize TriAPI callbacks
CL_FillTriAPIFromRef( &gTriApi, &ref.dllFuncs );
return true;
}
void R_Shutdown( void )
{
R_UnloadProgs();
ref.initialized = false;
}
void R_Init( void )
{
char refdll[64];
if( !Sys_GetParmFromCmdLine( "-ref", refdll ) )
{
Q_strncpy( refdll, DEFAULT_RENDERER, sizeof( refdll ));
}
gl_vsync = Cvar_Get( "gl_vsync", "0", FCVAR_ARCHIVE, "enable vertical syncronization" );
gl_showtextures = Cvar_Get( "gl_showtextures", "0", FCVAR_CHEAT, "show all uploaded textures" );
vid_displayfrequency = Cvar_Get ( "vid_displayfrequency", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "fullscreen refresh rate" );
vid_fullscreen = Cvar_Get( "fullscreen", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "enable fullscreen mode" );
r_adjust_fov = Cvar_Get( "r_adjust_fov", "1", FCVAR_ARCHIVE, "making FOV adjustment for wide-screens" );
r_decals = Cvar_Get( "r_decals", "4096", FCVAR_ARCHIVE, "sets the maximum number of decals" );
if( !R_LoadProgs( refdll ))
{
R_Shutdown();
Host_Error( "Can't initialize %s renderer!\n", refdll );
return;
}
}

View File

@ -0,0 +1,54 @@
/*
ref_common.h - Xash3D render dll API
Copyright (C) 2019 a1batross
This program 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 3 of the License, or
(at your option) any later version.
This program 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.
*/
#pragma once
#ifndef REF_COMMON_H
#define REF_COMMON_H
#include "ref_api.h"
#define TF_SKY (TF_SKYSIDE|TF_NOMIPMAP)
#define TF_FONT (TF_NOMIPMAP|TF_CLAMP)
#define TF_IMAGE (TF_NOMIPMAP|TF_CLAMP)
#define TF_DECAL (TF_CLAMP)
#define RP_LOCALCLIENT( e ) ((e) != NULL && (e)->index == ( cl.playernum + 1 ) && e->player )
struct ref_state_s
{
qboolean initialized;
HINSTANCE hInstance;
ref_interface_t dllFuncs;
};
extern struct ref_state_s ref;
extern ref_globals_t refState;
// handy API wrappers
void R_GetTextureParms( int *w, int *h, int texnum );
#define RefRenderAPI ref.dllFuncs.RenderAPI
#define RefRenderIface ref.dllFuncs.RenderIface
#define RENDER_GET_PARM( parm, arg ) RefRenderAPI->RenderGetParm( (parm), (arg) )
#define GL_LoadTextureInternal( name, pic, flags ) ref.dllFuncs.GL_LoadTextureFromBuffer( name, pic, flags, false )
#define GL_UpdateTextureInternal( name, pic, flags ) ref.dllFuncs.GL_LoadTextureFromBuffer( name, pic, flags, true )
// common engine and renderer cvars
extern convar_t *r_decals;
extern convar_t *r_adjust_fov;
extern convar_t *vid_fullscreen;
extern convar_t *vid_displayfrequency;
#endif // REF_COMMON_H

View File

@ -17,7 +17,6 @@ GNU General Public License for more details.
#include "sound.h"
#include "client.h"
#include "con_nprint.h"
#include "gl_local.h"
#include "pm_local.h"
#include "platform/platform.h"
@ -926,7 +925,7 @@ void S_StartSound( const vec3_t pos, int ent, int chan, sound_t handle, float fv
// and we didn't find it (it's not playing), go ahead and start it up
}
if( !pos ) pos = RI.vieworg;
if( !pos ) pos = refState.vieworg;
if( chan == CHAN_STREAM )
SetBits( flags, SND_STOP_LOOPING );

View File

@ -18,12 +18,11 @@ GNU General Public License for more details.
#include <string.h>
#include "common.h"
#include "client.h"
#include "gl_local.h"
#include "vgui_draw.h"
#include "vgui_api.h"
#include "library.h"
#include "keydefs.h"
#include "gl_local.h"
#include "ref_common.h"
#ifdef XASH_SDL
#include <SDL_events.h>
static SDL_Cursor* s_pDefaultCursor[20];
@ -38,20 +37,6 @@ static enum VGUI_DefaultCursor s_currentCursor;
static HINSTANCE s_pVGuiSupport; // vgui_support library
static convar_t *vgui_utf8 = NULL;
void VGUI_DrawInit( void );
void VGUI_DrawShutdown( void );
void VGUI_SetupDrawingText( int *pColor );
void VGUI_SetupDrawingRect( int *pColor );
void VGUI_SetupDrawingImage( int *pColor );
void VGUI_BindTexture( int id );
void VGUI_EnableTexture( qboolean enable );
void VGUI_CreateTexture( int id, int width, int height );
void VGUI_UploadTexture( int id, const char *buffer, int width, int height );
void VGUI_UploadTextureBlock( int id, int drawX, int drawY, const byte *rgba, int blockWidth, int blockHeight );
void VGUI_DrawQuad( const vpoint_t *ul, const vpoint_t *lr );
void VGUI_GetTextureSizes( int *width, int *height );
int VGUI_GenerateTexture( void );
// Helper functions for vgui backend
/*void VGUI_HideCursor( void )
@ -78,8 +63,8 @@ qboolean GAME_EXPORT VGUI_IsInGame( void )
void GAME_EXPORT VGUI_GetMousePos( int *_x, int *_y )
{
float xscale = (float)glState.width / (float)clgame.scrInfo.iWidth;
float yscale = (float)glState.height / (float)clgame.scrInfo.iHeight;
float xscale = (float)refState.width / (float)clgame.scrInfo.iWidth;
float yscale = (float)refState.height / (float)clgame.scrInfo.iHeight;
int x, y;
Platform_GetMousePos( &x, &y );
@ -176,19 +161,19 @@ int GAME_EXPORT VGUI_UtfProcessChar( int in )
vguiapi_t vgui =
{
false, // Not initialized yet
VGUI_DrawInit,
VGUI_DrawShutdown,
VGUI_SetupDrawingText,
VGUI_SetupDrawingRect,
VGUI_SetupDrawingImage,
VGUI_BindTexture,
VGUI_EnableTexture,
VGUI_CreateTexture,
VGUI_UploadTexture,
VGUI_UploadTextureBlock,
VGUI_DrawQuad,
VGUI_GetTextureSizes,
VGUI_GenerateTexture,
NULL, // VGUI_DrawInit,
NULL, // VGUI_DrawShutdown,
NULL, // VGUI_SetupDrawingText,
NULL, // VGUI_SetupDrawingRect,
NULL, // VGUI_SetupDrawingImage,
NULL, // VGUI_BindTexture,
NULL, // VGUI_EnableTexture,
NULL, // VGUI_CreateTexture,
NULL, // VGUI_UploadTexture,
NULL, // VGUI_UploadTextureBlock,
NULL, // VGUI_DrawQuad,
NULL, // VGUI_GetTextureSizes,
NULL, // VGUI_GenerateTexture,
VGUI_EngineMalloc,
/* VGUI_ShowCursor,
VGUI_HideCursor,*/
@ -521,237 +506,12 @@ void VGui_KeyEvent( int key, int down )
void VGui_MouseMove( int x, int y )
{
float xscale = (float)glState.width / (float)clgame.scrInfo.iWidth;
float yscale = (float)glState.height / (float)clgame.scrInfo.iHeight;
float xscale = (float)refState.width / (float)clgame.scrInfo.iWidth;
float yscale = (float)refState.height / (float)clgame.scrInfo.iHeight;
if( vgui.initialized )
vgui.MouseMove( x / xscale, y / yscale );
}
/*
================
VGUI_DrawInit
Startup VGUI backend
================
*/
void GAME_EXPORT VGUI_DrawInit( void )
{
memset( g_textures, 0, sizeof( g_textures ));
g_textureId = g_iBoundTexture = 0;
}
/*
================
VGUI_DrawShutdown
Release all textures
================
*/
void GAME_EXPORT VGUI_DrawShutdown( void )
{
int i;
for( i = 1; i < g_textureId; i++ )
{
GL_FreeTexture( g_textures[i] );
}
}
/*
================
VGUI_GenerateTexture
generate unique texture number
================
*/
int GAME_EXPORT VGUI_GenerateTexture( void )
{
if( ++g_textureId >= VGUI_MAX_TEXTURES )
Sys_Error( "VGUI_GenerateTexture: VGUI_MAX_TEXTURES limit exceeded\n" );
return g_textureId;
}
/*
================
VGUI_UploadTexture
Upload texture into video memory
================
*/
void GAME_EXPORT VGUI_UploadTexture( int id, const char *buffer, int width, int height )
{
rgbdata_t r_image;
char texName[32];
if( id <= 0 || id >= VGUI_MAX_TEXTURES )
{
Con_DPrintf( S_ERROR "VGUI_UploadTexture: bad texture %i. Ignored\n", id );
return;
}
Q_snprintf( texName, sizeof( texName ), "*vgui%i", id );
memset( &r_image, 0, sizeof( r_image ));
r_image.width = width;
r_image.height = height;
r_image.type = PF_RGBA_32;
r_image.size = r_image.width * r_image.height * 4;
r_image.flags = IMAGE_HAS_COLOR|IMAGE_HAS_ALPHA;
r_image.buffer = (byte *)buffer;
g_textures[id] = GL_LoadTextureInternal( texName, &r_image, TF_IMAGE );
}
/*
================
VGUI_CreateTexture
Create empty rgba texture and upload them into video memory
================
*/
void GAME_EXPORT VGUI_CreateTexture( int id, int width, int height )
{
rgbdata_t r_image;
char texName[32];
if( id <= 0 || id >= VGUI_MAX_TEXTURES )
{
Con_Reportf( S_ERROR "VGUI_CreateTexture: bad texture %i. Ignored\n", id );
return;
}
Q_snprintf( texName, sizeof( texName ), "*vgui%i", id );
memset( &r_image, 0, sizeof( r_image ));
r_image.width = width;
r_image.height = height;
r_image.type = PF_RGBA_32;
r_image.size = r_image.width * r_image.height * 4;
r_image.flags = IMAGE_HAS_ALPHA;
r_image.buffer = NULL;
g_textures[id] = GL_LoadTextureInternal( texName, &r_image, TF_IMAGE|TF_NEAREST );
g_iBoundTexture = id;
}
void GAME_EXPORT VGUI_UploadTextureBlock( int id, int drawX, int drawY, const byte *rgba, int blockWidth, int blockHeight )
{
if( id <= 0 || id >= VGUI_MAX_TEXTURES || g_textures[id] == 0 || g_textures[id] == tr.whiteTexture )
{
Con_Reportf( S_ERROR "VGUI_UploadTextureBlock: bad texture %i. Ignored\n", id );
return;
}
pglTexSubImage2D( GL_TEXTURE_2D, 0, drawX, drawY, blockWidth, blockHeight, GL_RGBA, GL_UNSIGNED_BYTE, rgba );
g_iBoundTexture = id;
}
void GAME_EXPORT VGUI_SetupDrawingRect( int *pColor )
{
pglEnable( GL_BLEND );
pglDisable( GL_ALPHA_TEST );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
pglColor4ub( pColor[0], pColor[1], pColor[2], 255 - pColor[3] );
}
void GAME_EXPORT VGUI_SetupDrawingText( int *pColor )
{
pglEnable( GL_BLEND );
pglEnable( GL_ALPHA_TEST );
pglAlphaFunc( GL_GREATER, 0.0f );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
pglColor4ub( pColor[0], pColor[1], pColor[2], 255 - pColor[3] );
}
void GAME_EXPORT VGUI_SetupDrawingImage( int *pColor )
{
pglEnable( GL_BLEND );
pglEnable( GL_ALPHA_TEST );
pglAlphaFunc( GL_GREATER, 0.0f );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
pglColor4ub( pColor[0], pColor[1], pColor[2], 255 - pColor[3] );
}
void GAME_EXPORT VGUI_BindTexture( int id )
{
if( id > 0 && id < VGUI_MAX_TEXTURES && g_textures[id] )
{
GL_Bind( XASH_TEXTURE0, g_textures[id] );
g_iBoundTexture = id;
}
else
{
// NOTE: same as bogus index 2700 in GoldSrc
id = g_iBoundTexture = 1;
GL_Bind( XASH_TEXTURE0, g_textures[id] );
}
}
/*
================
VGUI_GetTextureSizes
returns wide and tall for currently binded texture
================
*/
void GAME_EXPORT VGUI_GetTextureSizes( int *width, int *height )
{
gl_texture_t *glt;
int texnum;
if( g_iBoundTexture )
texnum = g_textures[g_iBoundTexture];
else texnum = tr.defaultTexture;
glt = R_GetTexture( texnum );
if( width ) *width = glt->srcWidth;
if( height ) *height = glt->srcHeight;
}
/*
================
VGUI_EnableTexture
disable texturemode for fill rectangle
================
*/
void GAME_EXPORT VGUI_EnableTexture( qboolean enable )
{
if( enable ) pglEnable( GL_TEXTURE_2D );
else pglDisable( GL_TEXTURE_2D );
}
/*
================
VGUI_DrawQuad
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;
ASSERT( ul != NULL && lr != NULL );
pglBegin( GL_QUADS );
pglTexCoord2f( ul->coord[0], ul->coord[1] );
pglVertex2f( ul->point[0] * xscale, ul->point[1] * yscale );
pglTexCoord2f( lr->coord[0], ul->coord[1] );
pglVertex2f( lr->point[0] * xscale, ul->point[1] * yscale );
pglTexCoord2f( lr->coord[0], lr->coord[1] );
pglVertex2f( lr->point[0] * xscale, lr->point[1] * yscale );
pglTexCoord2f( ul->coord[0], lr->coord[1] );
pglVertex2f( ul->point[0] * xscale, lr->point[1] * yscale );
pglEnd();
}
void VGui_Paint()
{
if(vgui.initialized)

View File

@ -15,7 +15,6 @@ GNU General Public License for more details.
#include "common.h"
#include "client.h"
#include "gl_local.h"
#include "mod_local.h"
#include "input.h"
#include "vid_common.h"
@ -31,7 +30,6 @@ convar_t *gl_wgl_msaa_samples;
convar_t *gl_lightmap_nearest;
convar_t *gl_keeptjunctions;
convar_t *gl_emboss_scale;
convar_t *gl_showtextures;
convar_t *gl_detailscale;
convar_t *gl_check_errors;
convar_t *gl_polyoffset;
@ -76,9 +74,9 @@ convar_t *vid_highdpi;
byte *r_temppool;
ref_globals_t tr;
gl_globals_t tr;
glconfig_t glConfig;
glstate_t glState;
glstate_t glState;
glwstate_t glw_state;
/*
@ -445,7 +443,6 @@ void GL_InitCommands( void )
r_lighting_extended = Cvar_Get( "r_lighting_extended", "1", FCVAR_ARCHIVE, "allow to get lighting from world and bmodels" );
r_lighting_modulate = Cvar_Get( "r_lighting_modulate", "0.6", FCVAR_ARCHIVE, "lightstyles modulate scale" );
r_lighting_ambient = Cvar_Get( "r_lighting_ambient", "0.3", FCVAR_ARCHIVE, "map ambient lighting scale" );
r_adjust_fov = Cvar_Get( "r_adjust_fov", "1", FCVAR_ARCHIVE, "making FOV adjustment for wide-screens" );
r_novis = Cvar_Get( "r_novis", "0", 0, "ignore vis information (perfomance test)" );
r_nocull = Cvar_Get( "r_nocull", "0", 0, "ignore frustrum culling (perfomance test)" );
r_detailtextures = Cvar_Get( "r_detailtextures", "1", FCVAR_ARCHIVE, "enable detail textures support, use '2' for autogenerate detail.txt" );
@ -455,7 +452,7 @@ void GL_InitCommands( void )
r_traceglow = Cvar_Get( "r_traceglow", "1", FCVAR_ARCHIVE, "cull flares behind models" );
r_lightmap = Cvar_Get( "r_lightmap", "0", FCVAR_CHEAT, "lightmap debugging tool" );
r_drawentities = Cvar_Get( "r_drawentities", "1", FCVAR_CHEAT, "render entities" );
r_decals = Cvar_Get( "r_decals", "4096", FCVAR_ARCHIVE, "sets the maximum number of decals" );
r_decals = engine.Cvar_Find( "r_decals" );
window_xpos = Cvar_Get( "_window_xpos", "130", FCVAR_RENDERINFO, "window position by horizontal" );
window_ypos = Cvar_Get( "_window_ypos", "48", FCVAR_RENDERINFO, "window position by vertical" );
@ -463,13 +460,13 @@ void GL_InitCommands( void )
gl_texture_nearest = Cvar_Get( "gl_texture_nearest", "0", FCVAR_ARCHIVE, "disable texture filter" );
gl_lightmap_nearest = Cvar_Get( "gl_lightmap_nearest", "0", FCVAR_ARCHIVE, "disable lightmap filter" );
gl_check_errors = Cvar_Get( "gl_check_errors", "1", FCVAR_ARCHIVE, "ignore video engine errors" );
gl_vsync = Cvar_Get( "gl_vsync", "0", FCVAR_ARCHIVE, "enable vertical syncronization" );
gl_vsync = engine.Cvar_Find( "gl_vsync" );
gl_detailscale = Cvar_Get( "gl_detailscale", "4.0", FCVAR_ARCHIVE, "default scale applies while auto-generate list of detail textures" );
gl_texture_anisotropy = Cvar_Get( "gl_anisotropy", "8", FCVAR_ARCHIVE, "textures anisotropic filter" );
gl_texture_lodbias = Cvar_Get( "gl_texture_lodbias", "0.0", FCVAR_ARCHIVE, "LOD bias for mipmapped textures (perfomance|quality)" );
gl_keeptjunctions = Cvar_Get( "gl_keeptjunctions", "1", FCVAR_ARCHIVE, "removing tjuncs causes blinking pixels" );
gl_emboss_scale = Cvar_Get( "gl_emboss_scale", "0", FCVAR_ARCHIVE|FCVAR_LATCH, "fake bumpmapping scale" );
gl_showtextures = Cvar_Get( "r_showtextures", "0", FCVAR_CHEAT, "show all uploaded textures" );
gl_showtextures = engine.Cvar_Find( "r_showtextures" );
gl_finish = Cvar_Get( "gl_finish", "0", FCVAR_ARCHIVE, "use glFinish instead of glFlush" );
gl_nosort = Cvar_Get( "gl_nosort", "0", FCVAR_ARCHIVE, "disable sorting of translucent surfaces" );
gl_clear = Cvar_Get( "gl_clear", "0", FCVAR_ARCHIVE, "clearing screen after each frame" );
@ -487,8 +484,8 @@ void GL_InitCommands( void )
vid_gamma = Cvar_Get( "gamma", "2.5", FCVAR_ARCHIVE, "gamma amount" );
vid_brightness = Cvar_Get( "brightness", "0.0", FCVAR_ARCHIVE, "brightness factor" );
vid_fullscreen = Cvar_Get( "fullscreen", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "enable fullscreen mode" );
vid_displayfrequency = Cvar_Get ( "vid_displayfrequency", "0", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "fullscreen refresh rate" );
vid_fullscreen = engine.Cvar_Find( "fullscreen" );
vid_displayfrequency = engine.Cvar_Find ( "vid_displayfrequency" );
vid_highdpi = Cvar_Get( "vid_highdpi", "1", FCVAR_RENDERINFO|FCVAR_VIDRESTART, "enable High-DPI mode" );
Cmd_AddCommand( "r_info", R_RenderInfo_f, "display renderer info" );

View File

@ -5,33 +5,12 @@
#define FCONTEXT_CORE_PROFILE BIT( 0 )
#define FCONTEXT_DEBUG_ARB BIT( 1 )
typedef struct vidmode_s
{
const char *desc;
int width;
int height;
} vidmode_t;
// minimal recommended resolution
#define VID_MIN_WIDTH 640
#define VID_MIN_HEIGHT 480
//
// vid_common.c
//
qboolean VID_SetMode( void );
#define GL_CheckForErrors() GL_CheckForErrors_( __FILE__, __LINE__ )
void GL_CheckForErrors_( const char *filename, const int fileline );
const char *GL_ErrorString( int err );
void GL_UpdateSwapInterval( void );
qboolean GL_Support( int r_ext );
void VID_CheckChanges( void );
int GL_MaxTextureUnits( void );
qboolean R_Init( void );
void R_Shutdown( void );
const char *VID_GetModeString( int vid_mode );
void R_SaveVideoMode( int w, int h );
void VID_StartupGamma( void );
void GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char *cvarname, int r_ext );
void GL_SetExtension( int r_ext, int enable );

View File

@ -1029,9 +1029,8 @@ void SV_BroadcastCommand( const char *fmt, ... ) _format( 1 );
qboolean SV_RestoreCustomDecal( struct decallist_s *entry, edict_t *pEdict, qboolean adjacent );
void SV_BroadcastPrintf( sv_client_t *ignore, char *fmt, ... ) _format( 2 );
int R_CreateDecalList( struct decallist_s *pList );
void R_DecalRemoveAll( int texture );
void R_ClearAllDecals( void );
void R_ClearStaticEntities( void );
void CL_ClearStaticEntities( void );
qboolean S_StreamGetCurrentState( char *currentTrack, char *loopTrack, int *position );
struct cl_entity_s *CL_GetEntityByIndex( int index );
struct player_info_s *CL_GetPlayerInfo( int playerIndex );
@ -1058,7 +1057,6 @@ int SV_GetSaveComment( const char *savename, char *comment );
qboolean SV_NewGame( const char *mapName, qboolean loadGame );
void SV_ClipPMoveToEntity( struct physent_s *pe, const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, struct pmtrace_s *tr );
void CL_ClipPMoveToEntity( struct physent_s *pe, const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, struct pmtrace_s *tr );
void CL_Particle( const vec3_t origin, int color, float life, int zpos, int zvel ); // debug thing
void SV_SysError( const char *error_string );
void SV_ShutdownGame( void );
void SV_ExecLoadLevel( void );
@ -1104,7 +1102,6 @@ qboolean LZSS_IsCompressed( const byte *source );
uint LZSS_GetActualSize( const byte *source );
byte *LZSS_Compress( byte *pInput, int inputLength, uint *pOutputSize );
uint LZSS_Decompress( const byte *pInput, byte *pOutput );
const byte *GL_TextureData( unsigned int texnum );
void GL_FreeImage( const char *name );
void VID_InitDefaultResolution( void );
void UI_SetActiveMenu( qboolean fActive );

View File

@ -37,6 +37,7 @@ enum
#define CMD_CLIENTDLL BIT( 1 ) // added by client.dll
#define CMD_GAMEUIDLL BIT( 2 ) // added by GameUI.dll
#define CMD_LOCALONLY BIT( 3 ) // restricted from server commands
#define CMD_REFDLL BIT( 4 ) // added by ref.dll
typedef void (*xcommand_t)( void );

View File

@ -15,6 +15,7 @@ GNU General Public License for more details.
#include "common.h"
#include "custom.h"
#include "ref_common.h"
qboolean CustomDecal_Validate( void *raw, int nFileSize )
{
@ -48,7 +49,7 @@ void COM_ClearCustomizationList( customization_t *pHead, qboolean bCleanDecals )
if( pCurrent->resource.type == t_decal )
{
if( bCleanDecals && CL_Active( ))
R_DecalRemoveAll( pCurrent->nUserData1 );
ref.dllFuncs.R_DecalRemoveAll( pCurrent->nUserData1 );
}
#endif

View File

@ -15,7 +15,6 @@ GNU General Public License for more details.
#include "common.h"
#include <mathlib.h>
#include "gl_local.h"
//-----------------------------------------------------------------------------
// Gamma conversion support
@ -85,4 +84,4 @@ byte LightToTexGamma( byte b )
byte TextureToGamma( byte b )
{
return texgammatable[b];
}
}

View File

@ -16,7 +16,6 @@ GNU General Public License for more details.
#include "imagelib.h"
#include "mathlib.h"
#include "mod_local.h"
#include "gl_export.h"
#define LERPBYTE( i ) r = resamplerow1[i]; out[i] = (byte)(((( resamplerow2[i] - r ) * lerp)>>16 ) + r )
#define FILTER_SIZE 5
@ -1534,4 +1533,4 @@ qboolean Image_Process( rgbdata_t **pix, int width, int height, uint flags, floa
image.force_flags = 0;
return result;
}
}

View File

@ -762,3 +762,50 @@ void QuaternionSlerp( const vec4_t p, const vec4_t q, float t, vec4_t qt )
QuaternionSlerpNoAlign( p, q2, t, qt );
}
/*
====================
V_CalcFov
====================
*/
float V_CalcFov( float *fov_x, float width, float height )
{
float x, half_fov_y;
if( *fov_x < 1.0f || *fov_x > 179.0f )
*fov_x = 90.0f; // default value
x = width / tan( DEG2RAD( *fov_x ) * 0.5f );
half_fov_y = atan( height / x );
return RAD2DEG( half_fov_y ) * 2;
}
/*
====================
V_AdjustFov
====================
*/
void V_AdjustFov( float *fov_x, float *fov_y, float width, float height, qboolean lock_x )
{
float x, y;
if( width * 3 == 4 * height || width * 4 == height * 5 )
{
// 4:3 or 5:4 ratio
return;
}
if( lock_x )
{
*fov_y = 2 * atan((width * 3) / (height * 4) * tan( *fov_y * M_PI / 360.0 * 0.5 )) * 360 / M_PI;
return;
}
y = V_CalcFov( fov_x, 640, 480 );
x = *fov_x;
*fov_x = V_CalcFov( &y, height, width );
if( *fov_x < x ) *fov_x = x;
else *fov_y = y;
}

View File

@ -193,6 +193,9 @@ void Matrix4x4_OriginFromMatrix( const matrix4x4 in, float *out );
void Matrix4x4_Transpose( matrix4x4 out, const matrix4x4 in1 );
qboolean Matrix4x4_Invert_Full( matrix4x4 out, const matrix4x4 in1 );
float V_CalcFov( float *fov_x, float width, float height );
void V_AdjustFov( float *fov_x, float *fov_y, float width, float height, qboolean lock_x );
extern vec3_t vec3_origin;
extern int boxpnt[6][4];
extern const matrix3x4 matrix3x4_identity;

View File

@ -20,7 +20,6 @@ GNU General Public License for more details.
#include "studio.h"
#include "wadfile.h"
#include "world.h"
#include "gl_local.h"
#include "enginefeatures.h"
#include "client.h"
#include "server.h" // LUMP_ error codes
@ -1033,7 +1032,7 @@ static void Mod_CalcSurfaceExtents( msurface_t *surf )
info->lightextents[i] = surf->extents[i];
}
#ifndef XASH_DEDICATED
#if !defined XASH_DEDICATED && 0 // REFTODO:
if( !FBitSet( tex->flags, TEX_SPECIAL ) && ( surf->extents[i] > 16384 ) && ( tr.block_size == BLOCK_SIZE_DEFAULT ))
Con_Reportf( S_ERROR "Bad surface extents %i\n", surf->extents[i] );
#endif // XASH_DEDICATED
@ -1802,10 +1801,8 @@ static void Mod_LoadTextures( dbspmodel_t *bmod )
{
#ifndef XASH_DEDICATED
// release old sky layers first
GL_FreeTexture( tr.solidskyTexture );
GL_FreeTexture( tr.alphaskyTexture );
tr.solidskyTexture = 0;
tr.alphaskyTexture = 0;
ref.dllFuncs.R_FreeSharedTexture( REF_SOLIDSKY_TEXTURE );
ref.dllFuncs.R_FreeSharedTexture( REF_SOLIDSKY_TEXTURE );
#endif
}
@ -1830,7 +1827,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod )
Q_strncpy( tx->name, "*default", sizeof( tx->name ));
#ifndef XASH_DEDICATED
tx->gl_texturenum = tr.defaultTexture;
tx->gl_texturenum = ref.dllFuncs.R_GetBuiltinTexture( REF_DEFAULT_TEXTURE );
tx->width = tx->height = 16;
#endif
continue; // missed
@ -1850,7 +1847,6 @@ static void Mod_LoadTextures( dbspmodel_t *bmod )
tx->width = mt->width;
tx->height = mt->height;
if( mt->offsets[0] > 0 )
{
int size = (int)sizeof( mip_t ) + ((mt->width * mt->height * 85)>>6);
@ -1876,9 +1872,10 @@ static void Mod_LoadTextures( dbspmodel_t *bmod )
// check for multi-layered sky texture (quake1 specific)
if( bmod->isworld && !Q_strncmp( mt->name, "sky", 3 ) && (( mt->width / mt->height ) == 2 ))
{
R_InitSkyClouds( mt, tx, custom_palette ); // load quake sky
ref.dllFuncs.R_InitSkyClouds( mt, tx, custom_palette ); // load quake sky
if( tr.solidskyTexture && tr.alphaskyTexture )
if( ref.dllFuncs.R_GetBuiltinTexture( REF_SOLIDSKY_TEXTURE ) &&
ref.dllFuncs.R_GetBuiltinTexture( REF_ALPHASKY_TEXTURE ) )
SetBits( world.flags, FWORLD_SKYSPHERE );
continue;
}
@ -1899,7 +1896,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod )
if( FS_FileExists( texpath, false ))
{
tx->gl_texturenum = GL_LoadTexture( texpath, NULL, 0, TF_ALLOW_EMBOSS );
tx->gl_texturenum = RefRenderAPI->GL_LoadTexture( texpath, NULL, 0, TF_ALLOW_EMBOSS );
bmod->wadlist.wadusage[j]++; // this wad are really used
break;
}
@ -1915,7 +1912,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod )
if( custom_palette ) size += sizeof( short ) + 768;
Q_snprintf( texname, sizeof( texname ), "#%s:%s.mip", loadstat.name, mt->name );
tx->gl_texturenum = GL_LoadTexture( texname, (byte *)mt, size, TF_ALLOW_EMBOSS );
tx->gl_texturenum = RefRenderAPI->GL_LoadTexture( texname, (byte *)mt, size, TF_ALLOW_EMBOSS );
}
// if texture is completely missed
@ -1923,11 +1920,11 @@ static void Mod_LoadTextures( dbspmodel_t *bmod )
{
if( host.type != HOST_DEDICATED )
Con_DPrintf( S_ERROR "unable to find %s.mip\n", mt->name );
tx->gl_texturenum = tr.defaultTexture;
tx->gl_texturenum = ref.dllFuncs.R_GetBuiltinTexture( REF_DEFAULT_TEXTURE );
}
// check for luma texture
if( FBitSet( R_GetTexture( tx->gl_texturenum )->flags, TF_HAS_LUMA ))
if( FBitSet( RENDER_GET_PARM( PARM_TEX_FLAGS, tx->gl_texturenum ), TF_HAS_LUMA ))
{
Q_snprintf( texname, sizeof( texname ), "#%s:%s_luma.mip", loadstat.name, mt->name );
@ -1938,7 +1935,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod )
int size = (int)sizeof( mip_t ) + ((mt->width * mt->height * 85)>>6);
if( custom_palette ) size += sizeof( short ) + 768;
tx->fb_texturenum = GL_LoadTexture( texname, (byte *)mt, size, TF_MAKELUMA );
tx->fb_texturenum = RefRenderAPI->GL_LoadTexture( texname, (byte *)mt, size, TF_MAKELUMA );
}
else
{
@ -1963,7 +1960,7 @@ static void Mod_LoadTextures( dbspmodel_t *bmod )
}
// okay, loading it from wad or hi-res version
tx->fb_texturenum = GL_LoadTexture( texname, src, srcSize, TF_MAKELUMA );
tx->fb_texturenum = RefRenderAPI->GL_LoadTexture( texname, src, srcSize, TF_MAKELUMA );
if( src ) Mem_Free( src );
}
}
@ -2246,7 +2243,7 @@ static void Mod_LoadSurfaces( dbspmodel_t *bmod )
#ifndef XASH_DEDICATED // TODO: Do we need subdivide on server?
if( FBitSet( out->flags, SURF_DRAWTURB ))
GL_SubdivideSurface( out ); // cut up polygon for warps
ref.dllFuncs.GL_SubdivideSurface( out ); // cut up polygon for warps
#endif
}
@ -2822,11 +2819,11 @@ void Mod_UnloadBrushModel( model_t *mod )
for( i = 0; i < mod->numtextures; i++ )
{
tx = mod->textures[i];
if( !tx || tx->gl_texturenum == tr.defaultTexture )
if( !tx || tx->gl_texturenum == ref.dllFuncs.R_GetBuiltinTexture( REF_DEFAULT_TEXTURE ) )
continue; // free slot
GL_FreeTexture( tx->gl_texturenum ); // main texture
GL_FreeTexture( tx->fb_texturenum ); // luma texture
RefRenderAPI->GL_FreeTexture( tx->gl_texturenum ); // main texture
RefRenderAPI->GL_FreeTexture( tx->fb_texturenum ); // luma texture
}
#endif
Mem_FreePool( &mod->mempool );

View File

@ -222,8 +222,6 @@ void R_StudioCalcBoneQuaternion( int frame, float s, mstudiobone_t *pbone, mstud
void R_StudioCalcBonePosition( int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, vec3_t adj, vec3_t pos );
void *R_StudioGetAnim( studiohdr_t *m_pStudioHeader, model_t *m_pSubModel, mstudioseqdesc_t *pseqdesc );
void Mod_StudioComputeBounds( void *buffer, vec3_t mins, vec3_t maxs, qboolean ignore_sequences );
void Mod_StudioLoadTextures( model_t *mod, void *data );
void Mod_StudioUnloadTextures( void *data );
int Mod_HitgroupForStudioHull( int index );
void Mod_ClearStudioCache( void );

View File

@ -18,6 +18,7 @@ GNU General Public License for more details.
#include "studio.h"
#include "r_studioint.h"
#include "library.h"
#include "ref_common.h"
typedef int (*STUDIOAPI)( int, sv_blending_interface_t**, server_studio_api_t*, float (*transform)[3][4], float (*bones)[MAXSTUDIOBONES][3][4] );
@ -1065,7 +1066,7 @@ void Mod_LoadStudioModel( model_t *mod, const void *buffer, qboolean *loaded )
}
else
{
Mod_StudioLoadTextures( mod, thdr );
ref.dllFuncs.Mod_StudioLoadTextures( mod, thdr );
// give space for textures and skinrefs
size1 = thdr->numtextures * sizeof( mstudiotexture_t );
@ -1092,7 +1093,7 @@ void Mod_LoadStudioModel( model_t *mod, const void *buffer, qboolean *loaded )
loadmodel->cache.data = Mem_Calloc( loadmodel->mempool, phdr->length );
memcpy( loadmodel->cache.data, buffer, phdr->length );
phdr = (studiohdr_t *)loadmodel->cache.data; // get the new pointer on studiohdr
Mod_StudioLoadTextures( mod, phdr );
ref.dllFuncs.Mod_StudioLoadTextures( mod, phdr );
// NOTE: we wan't keep raw textures in memory. just cutoff model pointer above texture base
loadmodel->cache.data = Mem_Realloc( loadmodel->mempool, loadmodel->cache.data, phdr->texturedataindex );
@ -1148,7 +1149,7 @@ void Mod_UnloadStudioModel( model_t *mod )
return; // not a studio
#ifndef XASH_DEDICATED
Mod_StudioUnloadTextures( mod->cache.data );
ref.dllFuncs.Mod_StudioUnloadTextures( mod->cache.data );
#endif
Mem_FreePool( &mod->mempool );
memset( mod, 0, sizeof( *mod ));

View File

@ -20,7 +20,6 @@ GNU General Public License for more details.
#include "studio.h"
#include "wadfile.h"
#include "world.h"
#include "gl_local.h"
#include "enginefeatures.h"
#include "client.h"
#include "server.h"
@ -112,24 +111,9 @@ static void Mod_FreeModel( model_t *mod )
if( mod->name[0] != '*' )
Mod_FreeUserData( mod );
// select the properly unloader
switch( mod->type )
{
case mod_sprite:
Mod_UnloadSpriteModel( mod );
break;
#ifndef XASH_DEDICATED
case mod_alias:
Mod_UnloadAliasModel( mod );
break;
#endif
case mod_studio:
Mod_UnloadStudioModel( mod );
break;
case mod_brush:
Mod_UnloadBrushModel( mod );
break;
}
// notify renderer about unloading
if( ref.dllFuncs.Mod_UnloadModel )
ref.dllFuncs.Mod_UnloadModel( mod );
memset( mod, 0, sizeof( *mod ));
}
@ -303,21 +287,18 @@ model_t *Mod_LoadModel( model_t *mod, qboolean crash )
switch( *(uint *)buf )
{
case IDSTUDIOHEADER:
Mod_LoadStudioModel( mod, buf, &loaded );
ref.dllFuncs.Mod_LoadModel( mod_studio, mod, buf, &loaded, 0 );
break;
case IDSPRITEHEADER:
Mod_LoadSpriteModel( mod, buf, &loaded, 0 );
ref.dllFuncs.Mod_LoadModel( mod_sprite, mod, buf, &loaded, 0 );
break;
// TODO: Load alias models on dedicated too?
#ifndef XASH_DEDICATED
case IDALIASHEADER:
Mod_LoadAliasModel( mod, buf, &loaded );
ref.dllFuncs.Mod_LoadModel( mod_alias, mod, buf, &loaded, 0 );
break;
#endif
case Q1BSP_VERSION:
case HLBSP_VERSION:
case QBSP2_VERSION:
Mod_LoadBrushModel( mod, buf, &loaded );
ref.dllFuncs.Mod_LoadModel( mod_brush, mod, buf, &loaded, 0 );
break;
default:
Mem_Free( buf );

View File

@ -16,6 +16,7 @@ GNU General Public License for more details.
#include "common.h"
#include "mathlib.h"
#include "pm_local.h"
#include "ref_common.h"
// expand debugging BBOX particle hulls by this many units.
#define BOX_GAP 0.0f
@ -41,7 +42,7 @@ void PM_ParticleLine( const vec3_t start, const vec3_t end, int pcolor, float li
while( curdist <= len )
{
VectorMA( start, curdist, diff, pos );
CL_Particle( pos, pcolor, life, 0, zvel );
ref.dllFuncs.CL_Particle( pos, pcolor, life, 0, zvel );
curdist += 2.0f;
}
#endif // XASH_DEDICATED
@ -89,4 +90,4 @@ void PM_DrawBBox( const vec3_t mins, const vec3_t maxs, const vec3_t origin, int
PM_DrawRectangle( p[boxpnt[i][1]], p[boxpnt[i][0]], p[boxpnt[i][2]], p[boxpnt[i][3]], pcolor, life );
}
#endif // XASH_DEDICATED
}
}

View File

@ -24,7 +24,6 @@ GNU General Public License for more details.
#include "events.h"
#include "sound.h"
#include "vid_common.h"
#include "gl_local.h"
static int wheelbutton;
@ -214,10 +213,10 @@ static void SDLash_EventFilter( SDL_Event *event )
#ifdef TOUCHEMU
if( mdown )
IN_TouchEvent( event_motion, 0,
event->motion.x/(float)glState.width,
event->motion.y/(float)glState.height,
event->motion.xrel/(float)glState.width,
event->motion.yrel/(float)glState.height );
event->motion.x/(float)refState.width,
event->motion.y/(float)refState.height,
event->motion.xrel/(float)refState.width,
event->motion.yrel/(float)refState.height );
SDL_ShowCursor( true );
#endif
break;
@ -227,8 +226,8 @@ static void SDLash_EventFilter( SDL_Event *event )
#ifdef TOUCHEMU
mdown = event->button.state != SDL_RELEASED;
IN_TouchEvent( event_down, 0,
event->button.x/(float)glState.width,
event->button.y/(float)glState.height, 0, 0);
event->button.x/(float)refState.width,
event->button.y/(float)refState.height, 0, 0);
#else
SDLash_MouseEvent( event->button );
#endif
@ -289,13 +288,13 @@ static void SDLash_EventFilter( SDL_Event *event )
if( scale == 2 )
{
x /= (float)glState.width;
y /= (float)glState.height;
dx /= (float)glState.width;
dy /= (float)glState.height;
x /= (float)refState.width;
y /= (float)refState.height;
dx /= (float)refState.width;
dy /= (float)refState.height;
}
IN_TouchEvent( type, event->tfinger.fingerId, x, y, dx, dy );
// IN_TouchEvent( type, event->tfinger.fingerId, x, y, dx, dy );
break;
}

View File

@ -23,7 +23,6 @@ GNU General Public License for more details.
#include "events.h"
#include "sound.h"
#include "vid_common.h"
#include "gl_local.h"
static SDL_Joystick *joy;
static SDL_GameController *gamecontroller;

View File

@ -16,7 +16,6 @@ GNU General Public License for more details.
#include <SDL.h>
#include "common.h"
#include "client.h"
#include "gl_local.h"
#include "mod_local.h"
#include "input.h"
#include "vid_common.h"
@ -25,191 +24,6 @@ GNU General Public License for more details.
static vidmode_t *vidmodes = NULL;
static int num_vidmodes = 0;
static int context_flags = 0;
#define GL_CALL( x ) #x, (void**)&p##x
static dllfunc_t opengl_110funcs[] =
{
{ GL_CALL( glClearColor ) },
{ GL_CALL( glClear ) },
{ GL_CALL( glAlphaFunc ) },
{ GL_CALL( glBlendFunc ) },
{ GL_CALL( glCullFace ) },
{ GL_CALL( glDrawBuffer ) },
{ GL_CALL( glReadBuffer ) },
{ GL_CALL( glAccum ) },
{ GL_CALL( glEnable ) },
{ GL_CALL( glDisable ) },
{ GL_CALL( glEnableClientState ) },
{ GL_CALL( glDisableClientState ) },
{ GL_CALL( glGetBooleanv ) },
{ GL_CALL( glGetDoublev ) },
{ GL_CALL( glGetFloatv ) },
{ GL_CALL( glGetIntegerv ) },
{ GL_CALL( glGetError ) },
{ GL_CALL( glGetString ) },
{ GL_CALL( glFinish ) },
{ GL_CALL( glFlush ) },
{ GL_CALL( glClearDepth ) },
{ GL_CALL( glDepthFunc ) },
{ GL_CALL( glDepthMask ) },
{ GL_CALL( glDepthRange ) },
{ GL_CALL( glFrontFace ) },
{ GL_CALL( glDrawElements ) },
{ GL_CALL( glDrawArrays ) },
{ GL_CALL( glColorMask ) },
{ GL_CALL( glIndexPointer ) },
{ GL_CALL( glVertexPointer ) },
{ GL_CALL( glNormalPointer ) },
{ GL_CALL( glColorPointer ) },
{ GL_CALL( glTexCoordPointer ) },
{ GL_CALL( glArrayElement ) },
{ GL_CALL( glColor3f ) },
{ GL_CALL( glColor3fv ) },
{ GL_CALL( glColor4f ) },
{ GL_CALL( glColor4fv ) },
{ GL_CALL( glColor3ub ) },
{ GL_CALL( glColor4ub ) },
{ GL_CALL( glColor4ubv ) },
{ GL_CALL( glTexCoord1f ) },
{ GL_CALL( glTexCoord2f ) },
{ GL_CALL( glTexCoord3f ) },
{ GL_CALL( glTexCoord4f ) },
{ GL_CALL( glTexCoord1fv ) },
{ GL_CALL( glTexCoord2fv ) },
{ GL_CALL( glTexCoord3fv ) },
{ GL_CALL( glTexCoord4fv ) },
{ GL_CALL( glTexGenf ) },
{ GL_CALL( glTexGenfv ) },
{ GL_CALL( glTexGeni ) },
{ GL_CALL( glVertex2f ) },
{ GL_CALL( glVertex3f ) },
{ GL_CALL( glVertex3fv ) },
{ GL_CALL( glNormal3f ) },
{ GL_CALL( glNormal3fv ) },
{ GL_CALL( glBegin ) },
{ GL_CALL( glEnd ) },
{ GL_CALL( glLineWidth ) },
{ GL_CALL( glPointSize ) },
{ GL_CALL( glMatrixMode ) },
{ GL_CALL( glOrtho ) },
{ GL_CALL( glRasterPos2f ) },
{ GL_CALL( glFrustum ) },
{ GL_CALL( glViewport ) },
{ GL_CALL( glPushMatrix ) },
{ GL_CALL( glPopMatrix ) },
{ GL_CALL( glPushAttrib ) },
{ GL_CALL( glPopAttrib ) },
{ GL_CALL( glLoadIdentity ) },
{ GL_CALL( glLoadMatrixd ) },
{ GL_CALL( glLoadMatrixf ) },
{ GL_CALL( glMultMatrixd ) },
{ GL_CALL( glMultMatrixf ) },
{ GL_CALL( glRotated ) },
{ GL_CALL( glRotatef ) },
{ GL_CALL( glScaled ) },
{ GL_CALL( glScalef ) },
{ GL_CALL( glTranslated ) },
{ GL_CALL( glTranslatef ) },
{ GL_CALL( glReadPixels ) },
{ GL_CALL( glDrawPixels ) },
{ GL_CALL( glStencilFunc ) },
{ GL_CALL( glStencilMask ) },
{ GL_CALL( glStencilOp ) },
{ GL_CALL( glClearStencil ) },
{ GL_CALL( glIsEnabled ) },
{ GL_CALL( glIsList ) },
{ GL_CALL( glIsTexture ) },
{ GL_CALL( glTexEnvf ) },
{ GL_CALL( glTexEnvfv ) },
{ GL_CALL( glTexEnvi ) },
{ GL_CALL( glTexParameterf ) },
{ GL_CALL( glTexParameterfv ) },
{ GL_CALL( glTexParameteri ) },
{ GL_CALL( glHint ) },
{ GL_CALL( glPixelStoref ) },
{ GL_CALL( glPixelStorei ) },
{ GL_CALL( glGenTextures ) },
{ GL_CALL( glDeleteTextures ) },
{ GL_CALL( glBindTexture ) },
{ GL_CALL( glTexImage1D ) },
{ GL_CALL( glTexImage2D ) },
{ GL_CALL( glTexSubImage1D ) },
{ GL_CALL( glTexSubImage2D ) },
{ GL_CALL( glCopyTexImage1D ) },
{ GL_CALL( glCopyTexImage2D ) },
{ GL_CALL( glCopyTexSubImage1D ) },
{ GL_CALL( glCopyTexSubImage2D ) },
{ GL_CALL( glScissor ) },
{ GL_CALL( glGetTexImage ) },
{ GL_CALL( glGetTexEnviv ) },
{ GL_CALL( glPolygonOffset ) },
{ GL_CALL( glPolygonMode ) },
{ GL_CALL( glPolygonStipple ) },
{ GL_CALL( glClipPlane ) },
{ GL_CALL( glGetClipPlane ) },
{ GL_CALL( glShadeModel ) },
{ GL_CALL( glGetTexLevelParameteriv ) },
{ GL_CALL( glGetTexLevelParameterfv ) },
{ GL_CALL( glFogfv ) },
{ GL_CALL( glFogf ) },
{ GL_CALL( glFogi ) },
{ NULL , NULL }
};
static dllfunc_t debugoutputfuncs[] =
{
{ GL_CALL( glDebugMessageControlARB ) },
{ GL_CALL( glDebugMessageInsertARB ) },
{ GL_CALL( glDebugMessageCallbackARB ) },
{ GL_CALL( glGetDebugMessageLogARB ) },
{ NULL , NULL }
};
static dllfunc_t multitexturefuncs[] =
{
{ GL_CALL( glMultiTexCoord1f ) },
{ GL_CALL( glMultiTexCoord2f ) },
{ GL_CALL( glMultiTexCoord3f ) },
{ GL_CALL( glMultiTexCoord4f ) },
{ GL_CALL( glActiveTexture ) },
{ GL_CALL( glActiveTextureARB ) },
{ GL_CALL( glClientActiveTexture ) },
{ GL_CALL( glClientActiveTextureARB ) },
{ NULL , NULL }
};
static dllfunc_t texture3dextfuncs[] =
{
{ GL_CALL( glTexImage3D ) },
{ GL_CALL( glTexSubImage3D ) },
{ GL_CALL( glCopyTexSubImage3D ) },
{ NULL , NULL }
};
static dllfunc_t texturecompressionfuncs[] =
{
{ GL_CALL( glCompressedTexImage3DARB ) },
{ GL_CALL( glCompressedTexImage2DARB ) },
{ GL_CALL( glCompressedTexImage1DARB ) },
{ GL_CALL( glCompressedTexSubImage3DARB ) },
{ GL_CALL( glCompressedTexSubImage2DARB ) },
{ GL_CALL( glCompressedTexSubImage1DARB ) },
{ GL_CALL( glGetCompressedTexImage ) },
{ NULL , NULL }
};
static dllfunc_t vbofuncs[] =
{
{ GL_CALL( glBindBufferARB ) },
{ GL_CALL( glDeleteBuffersARB ) },
{ GL_CALL( glGenBuffersARB ) },
{ GL_CALL( glIsBufferARB ) },
{ GL_CALL( glMapBufferARB ) },
{ GL_CALL( glUnmapBufferARB ) }, // ,
{ GL_CALL( glBufferDataARB ) },
{ GL_CALL( glBufferSubDataARB ) },
{ NULL, NULL}
};
static void GL_SetupAttributes( void );
int R_MaxVideoModes( void )
@ -348,39 +162,6 @@ static void WIN_SetDPIAwareness( void )
}
#endif
/*
========================
DebugCallback
For ARB_debug_output
========================
*/
static void APIENTRY GL_DebugOutput( GLuint source, GLuint type, GLuint id, GLuint severity, GLint length, const GLcharARB *message, GLvoid *userParam )
{
switch( type )
{
case GL_DEBUG_TYPE_ERROR_ARB:
Con_Printf( S_OPENGL_ERROR "%s\n", message );
break;
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB:
Con_Printf( S_OPENGL_WARN "%s\n", message );
break;
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB:
Con_Printf( S_OPENGL_WARN "%s\n", message );
break;
case GL_DEBUG_TYPE_PORTABILITY_ARB:
if( host_developer.value < DEV_EXTENDED )
return;
Con_Printf( S_OPENGL_WARN "%s\n", message );
break;
case GL_DEBUG_TYPE_PERFORMANCE_ARB:
Con_Printf( S_OPENGL_NOTE "%s\n", message );
break;
case GL_DEBUG_TYPE_OTHER_ARB:
default: Con_Printf( S_OPENGL_NOTE "%s\n", message );
break;
}
}
/*
=================
@ -897,251 +678,6 @@ qboolean R_Init_Video( void )
return true;
}
#ifdef XASH_GLES
void GL_InitExtensionsGLES( void )
{
// intialize wrapper type
#ifdef XASH_NANOGL
glConfig.context = CONTEXT_TYPE_GLES_1_X;
glConfig.wrapper = GLES_WRAPPER_NANOGL;
#elif defined( XASH_WES )
glConfig.context = CONTEXT_TYPE_GLES_2_X;
glConfig.wrapper = GLES_WRAPPER_WES;
#endif
glConfig.hardware_type = GLHW_GENERIC;
// initalize until base opengl functions loaded
GL_SetExtension( GL_DRAW_RANGEELEMENTS_EXT, true );
GL_SetExtension( GL_ARB_MULTITEXTURE, true );
pglGetIntegerv( GL_MAX_TEXTURE_UNITS_ARB, &glConfig.max_texture_units );
glConfig.max_texture_coords = glConfig.max_texture_units = 4;
GL_SetExtension( GL_ENV_COMBINE_EXT, true );
GL_SetExtension( GL_DOT3_ARB_EXT, true );
GL_SetExtension( GL_TEXTURE_3D_EXT, false );
GL_SetExtension( GL_SGIS_MIPMAPS_EXT, true ); // gles specs
GL_SetExtension( GL_ARB_VERTEX_BUFFER_OBJECT_EXT, true ); // gles specs
// hardware cubemaps
GL_CheckExtension( "GL_OES_texture_cube_map", NULL, "gl_texture_cubemap", GL_TEXTURECUBEMAP_EXT );
if( GL_Support( GL_TEXTURECUBEMAP_EXT ))
pglGetIntegerv( GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, &glConfig.max_cubemap_size );
GL_SetExtension( GL_ARB_SEAMLESS_CUBEMAP, false );
GL_SetExtension( GL_EXT_POINTPARAMETERS, false );
GL_CheckExtension( "GL_OES_texture_npot", NULL, "gl_texture_npot", GL_ARB_TEXTURE_NPOT_EXT );
GL_SetExtension( GL_TEXTURE_COMPRESSION_EXT, false );
GL_SetExtension( GL_CUSTOM_VERTEX_ARRAY_EXT, false );
GL_SetExtension( GL_CLAMPTOEDGE_EXT, true ); // by gles1 specs
GL_SetExtension( GL_ANISOTROPY_EXT, false );
GL_SetExtension( GL_TEXTURE_LODBIAS, false );
GL_SetExtension( GL_CLAMP_TEXBORDER_EXT, false );
GL_SetExtension( GL_BLEND_MINMAX_EXT, false );
GL_SetExtension( GL_BLEND_SUBTRACT_EXT, false );
GL_SetExtension( GL_SEPARATESTENCIL_EXT, false );
GL_SetExtension( GL_STENCILTWOSIDE_EXT, false );
GL_SetExtension( GL_TEXTURE_ENV_ADD_EXT,false );
GL_SetExtension( GL_SHADER_OBJECTS_EXT, false );
GL_SetExtension( GL_SHADER_GLSL100_EXT, false );
GL_SetExtension( GL_VERTEX_SHADER_EXT,false );
GL_SetExtension( GL_FRAGMENT_SHADER_EXT, false );
GL_SetExtension( GL_SHADOW_EXT, false );
GL_SetExtension( GL_ARB_DEPTH_FLOAT_EXT, false );
GL_SetExtension( GL_OCCLUSION_QUERIES_EXT,false );
GL_CheckExtension( "GL_OES_depth_texture", NULL, "gl_depthtexture", GL_DEPTH_TEXTURE );
glConfig.texRectangle = glConfig.max_2d_rectangle_size = 0; // no rectangle
Cvar_FullSet( "gl_allow_mirrors", "0", CVAR_READ_ONLY); // No support for GLES
}
#else
void GL_InitExtensionsBigGL()
{
// intialize wrapper type
glConfig.context = CONTEXT_TYPE_GL;
glConfig.wrapper = GLES_WRAPPER_NONE;
if( Q_stristr( glConfig.renderer_string, "geforce" ))
glConfig.hardware_type = GLHW_NVIDIA;
else if( Q_stristr( glConfig.renderer_string, "quadro fx" ))
glConfig.hardware_type = GLHW_NVIDIA;
else if( Q_stristr(glConfig.renderer_string, "rv770" ))
glConfig.hardware_type = GLHW_RADEON;
else if( Q_stristr(glConfig.renderer_string, "radeon hd" ))
glConfig.hardware_type = GLHW_RADEON;
else if( Q_stristr( glConfig.renderer_string, "eah4850" ) || Q_stristr( glConfig.renderer_string, "eah4870" ))
glConfig.hardware_type = GLHW_RADEON;
else if( Q_stristr( glConfig.renderer_string, "radeon" ))
glConfig.hardware_type = GLHW_RADEON;
else if( Q_stristr( glConfig.renderer_string, "intel" ))
glConfig.hardware_type = GLHW_INTEL;
else glConfig.hardware_type = GLHW_GENERIC;
// multitexture
glConfig.max_texture_units = glConfig.max_texture_coords = glConfig.max_teximage_units = 1;
GL_CheckExtension( "GL_ARB_multitexture", multitexturefuncs, "gl_arb_multitexture", GL_ARB_MULTITEXTURE );
if( GL_Support( GL_ARB_MULTITEXTURE ))
{
pglGetIntegerv( GL_MAX_TEXTURE_UNITS_ARB, &glConfig.max_texture_units );
}
if( glConfig.max_texture_units == 1 )
GL_SetExtension( GL_ARB_MULTITEXTURE, false );
// 3d texture support
GL_CheckExtension( "GL_EXT_texture3D", texture3dextfuncs, "gl_texture_3d", GL_TEXTURE_3D_EXT );
if( GL_Support( GL_TEXTURE_3D_EXT ))
{
pglGetIntegerv( GL_MAX_3D_TEXTURE_SIZE, &glConfig.max_3d_texture_size );
if( glConfig.max_3d_texture_size < 32 )
{
GL_SetExtension( GL_TEXTURE_3D_EXT, false );
Con_Printf( S_ERROR "GL_EXT_texture3D reported bogus GL_MAX_3D_TEXTURE_SIZE, disabled\n" );
}
}
// 2d texture array support
GL_CheckExtension( "GL_EXT_texture_array", texture3dextfuncs, "gl_texture_2d_array", GL_TEXTURE_ARRAY_EXT );
if( GL_Support( GL_TEXTURE_ARRAY_EXT ))
pglGetIntegerv( GL_MAX_ARRAY_TEXTURE_LAYERS_EXT, &glConfig.max_2d_texture_layers );
// cubemaps support
GL_CheckExtension( "GL_ARB_texture_cube_map", NULL, "gl_texture_cubemap", GL_TEXTURE_CUBEMAP_EXT );
if( GL_Support( GL_TEXTURE_CUBEMAP_EXT ))
{
pglGetIntegerv( GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, &glConfig.max_cubemap_size );
// check for seamless cubemaps too
GL_CheckExtension( "GL_ARB_seamless_cube_map", NULL, "gl_texture_cubemap_seamless", GL_ARB_SEAMLESS_CUBEMAP );
}
GL_CheckExtension( "GL_ARB_texture_non_power_of_two", NULL, "gl_texture_npot", GL_ARB_TEXTURE_NPOT_EXT );
GL_CheckExtension( "GL_ARB_texture_compression", texturecompressionfuncs, "gl_dds_hardware_support", GL_TEXTURE_COMPRESSION_EXT );
GL_CheckExtension( "GL_EXT_texture_edge_clamp", NULL, "gl_clamp_to_edge", GL_CLAMPTOEDGE_EXT );
if( !GL_Support( GL_CLAMPTOEDGE_EXT ))
GL_CheckExtension( "GL_SGIS_texture_edge_clamp", NULL, "gl_clamp_to_edge", GL_CLAMPTOEDGE_EXT );
glConfig.max_texture_anisotropy = 0.0f;
GL_CheckExtension( "GL_EXT_texture_filter_anisotropic", NULL, "gl_ext_anisotropic_filter", GL_ANISOTROPY_EXT );
if( GL_Support( GL_ANISOTROPY_EXT ))
pglGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &glConfig.max_texture_anisotropy );
#ifdef _WIN32 // Win32 only drivers?
// g-cont. because lodbias it too glitchy on Intel's cards
if( glConfig.hardware_type != GLHW_INTEL )
#endif
GL_CheckExtension( "GL_EXT_texture_lod_bias", NULL, "gl_texture_mipmap_biasing", GL_TEXTURE_LOD_BIAS );
if( GL_Support( GL_TEXTURE_LOD_BIAS ))
pglGetFloatv( GL_MAX_TEXTURE_LOD_BIAS_EXT, &glConfig.max_texture_lod_bias );
GL_CheckExtension( "GL_ARB_texture_border_clamp", NULL, "gl_ext_texborder_clamp", GL_CLAMP_TEXBORDER_EXT );
GL_CheckExtension( "GL_ARB_depth_texture", NULL, "gl_depthtexture", GL_DEPTH_TEXTURE );
GL_CheckExtension( "GL_ARB_texture_float", NULL, "gl_arb_texture_float", GL_ARB_TEXTURE_FLOAT_EXT );
GL_CheckExtension( "GL_ARB_depth_buffer_float", NULL, "gl_arb_depth_float", GL_ARB_DEPTH_FLOAT_EXT );
GL_CheckExtension( "GL_EXT_gpu_shader4", NULL, NULL, GL_EXT_GPU_SHADER4 ); // don't confuse users
GL_CheckExtension( "GL_ARB_shading_language_100", NULL, "gl_glslprogram", GL_SHADER_GLSL100_EXT );
GL_CheckExtension( "GL_ARB_vertex_buffer_object", vbofuncs, "gl_vertex_buffer_object", GL_ARB_VERTEX_BUFFER_OBJECT_EXT );
// rectangle textures support
GL_CheckExtension( "GL_ARB_texture_rectangle", NULL, "gl_texture_rectangle", GL_TEXTURE_2D_RECT_EXT );
// this won't work without extended context
if( glw_state.extended )
GL_CheckExtension( "GL_ARB_debug_output", debugoutputfuncs, "gl_debug_output", GL_DEBUG_OUTPUT );
if( GL_Support( GL_SHADER_GLSL100_EXT ))
{
pglGetIntegerv( GL_MAX_TEXTURE_COORDS_ARB, &glConfig.max_texture_coords );
pglGetIntegerv( GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &glConfig.max_teximage_units );
// check for hardware skinning
pglGetIntegerv( GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, &glConfig.max_vertex_uniforms );
pglGetIntegerv( GL_MAX_VERTEX_ATTRIBS_ARB, &glConfig.max_vertex_attribs );
#ifdef _WIN32 // Win32 only drivers?
if( glConfig.hardware_type == GLHW_RADEON && glConfig.max_vertex_uniforms > 512 )
glConfig.max_vertex_uniforms /= 4; // radeon returns not correct info
#endif
}
else
{
// just get from multitexturing
glConfig.max_texture_coords = glConfig.max_teximage_units = glConfig.max_texture_units;
}
pglGetIntegerv( GL_MAX_TEXTURE_SIZE, &glConfig.max_2d_texture_size );
if( glConfig.max_2d_texture_size <= 0 ) glConfig.max_2d_texture_size = 256;
if( GL_Support( GL_TEXTURE_2D_RECT_EXT ))
pglGetIntegerv( GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT, &glConfig.max_2d_rectangle_size );
#ifndef XASH_GL_STATIC
// enable gldebug if allowed
if( GL_Support( GL_DEBUG_OUTPUT ))
{
if( host_developer.value )
{
Con_Reportf( "Installing GL_DebugOutput...\n");
pglDebugMessageCallbackARB( GL_DebugOutput, NULL );
// force everything to happen in the main thread instead of in a separate driver thread
pglEnable( GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB );
}
// enable all the low priority messages
pglDebugMessageControlARB( GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_LOW_ARB, 0, NULL, true );
}
#endif
}
#endif
void GL_InitExtensions( void )
{
// initialize gl extensions
GL_CheckExtension( "OpenGL 1.1.0", opengl_110funcs, NULL, GL_OPENGL_110 );
// get our various GL strings
glConfig.vendor_string = pglGetString( GL_VENDOR );
glConfig.renderer_string = pglGetString( GL_RENDERER );
glConfig.version_string = pglGetString( GL_VERSION );
glConfig.extensions_string = pglGetString( GL_EXTENSIONS );
Con_Reportf( "^3Video^7: %s\n", glConfig.renderer_string );
#ifdef XASH_GLES
GL_InitExtensionsGLES();
#else
GL_InitExtensionsBigGL();
#endif
if( GL_Support( GL_TEXTURE_2D_RECT_EXT ))
pglGetIntegerv( GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT, &glConfig.max_2d_rectangle_size );
Cvar_Get( "gl_max_size", va( "%i", glConfig.max_2d_texture_size ), 0, "opengl texture max dims" );
Cvar_Set( "gl_anisotropy", va( "%f", bound( 0, gl_texture_anisotropy->value, glConfig.max_texture_anisotropy )));
if( GL_Support( GL_TEXTURE_COMPRESSION_EXT ))
Image_AddCmdFlags( IL_DDS_HARDWARE );
// MCD has buffering issues
#ifdef _WIN32
if( Q_strstr( glConfig.renderer_string, "gdi" ))
Cvar_SetValue( "gl_finish", 1 );
#endif
tr.framecount = tr.visframecount = 1;
glw_state.initialized = true;
}
rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen )
{
@ -1271,9 +807,7 @@ void R_Free_Video( void )
R_FreeVideoModes();
// now all extensions are disabled
memset( glConfig.extension, 0, sizeof( glConfig.extension ));
glw_state.initialized = false;
ref.dllFuncs.GL_ClearExtensions();
}
#endif // XASH_DEDICATED

View File

@ -22,6 +22,7 @@ GNU General Public License for more details.
#include "studio.h"
#include "const.h"
#include "render_api.h" // modelstate_t
#include "ref_common.h" // decals
#define ENTVARS_COUNT ARRAYSIZE( gEntvarsDescription )
@ -552,7 +553,7 @@ void SV_RestartStaticEnts( void )
int i;
// remove all the static entities on the client
R_ClearStaticEntities();
CL_ClearStaticEntities();
// resend them again
for( i = 0; i < sv.num_static_entities; i++ )
@ -616,10 +617,10 @@ void SV_RestartDecals( void )
// g-cont. add space for studiodecals if present
host.decalList = (decallist_t *)Z_Calloc( sizeof( decallist_t ) * MAX_RENDER_DECALS * 2 );
host.numdecals = R_CreateDecalList( host.decalList );
host.numdecals = ref.dllFuncs.R_CreateDecalList( host.decalList );
// remove decals from map
R_ClearAllDecals();
ref.dllFuncs.R_ClearAllDecals();
// write decals into reliable datagram
msg = SV_GetReliableDatagram();

View File

@ -18,7 +18,7 @@ GNU General Public License for more details.
#include "const.h"
#include "library.h"
#include "triangleapi.h"
#include "gl_export.h"
#include "ref_common.h"
typedef int (*PHYSICAPI)( int, server_physics_api_t*, physics_interface_t* );
#ifndef XASH_DEDICATED
@ -1884,17 +1884,19 @@ void SV_DrawDebugTriangles( void )
if( svgame.physFuncs.DrawDebugTriangles != NULL )
{
#if 0
// debug draws only
pglDisable( GL_BLEND );
pglDepthMask( GL_FALSE );
pglDisable( GL_TEXTURE_2D );
#endif
// draw wireframe overlay
svgame.physFuncs.DrawDebugTriangles ();
#if 0
pglEnable( GL_TEXTURE_2D );
pglDepthMask( GL_TRUE );
pglEnable( GL_BLEND );
#endif
}
}
@ -2001,6 +2003,11 @@ const char* pfnGetModelName( int modelindex )
return sv.model_precache[modelindex];
}
static const byte *GL_TextureData( unsigned int texnum )
{
return ref.dllFuncs.GL_TextureData( texnum );
}
static server_physics_api_t gPhysicsAPI =
{
SV_LinkEdict,

View File

@ -19,6 +19,7 @@ GNU General Public License for more details.
#include "const.h"
#include "render_api.h" // decallist_t
#include "sound.h" // S_GetDynamicSounds
#include "ref_common.h" // decals
/*
==============================================================================
@ -1129,7 +1130,7 @@ static void SaveClientState( SAVERESTOREDATA *pSaveData, const char *level, int
decalList = (decallist_t *)Z_Calloc( sizeof( decallist_t ) * MAX_RENDER_DECALS * 2 );
// initialize client header
header.decalCount = R_CreateDecalList( decalList );
header.decalCount = ref.dllFuncs.R_CreateDecalList( decalList );
header.entityCount = sv.num_static_entities;
if( !changelevel )

View File

@ -839,3 +839,49 @@ void R_ShowTree( void )
Con_NPrintf( 0, "max recursion %d\n", tr.max_recursion );
}
/*
================
SCR_TimeRefresh_f
timerefresh [noflip]
================
*/
void SCR_TimeRefresh_f( void )
{
int i;
double start, stop;
double time;
if( cls.state != ca_active )
return;
start = Sys_DoubleTime();
// run without page flipping like GoldSrc
if( Cmd_Argc() == 1 )
{
pglDrawBuffer( GL_FRONT );
for( i = 0; i < 128; i++ )
{
refState.viewangles[1] = i / 128.0 * 360.0f;
R_RenderScene();
}
pglFinish();
R_EndFrame();
}
else
{
for( i = 0; i < 128; i++ )
{
ref.dllFuncs.R_BeginFrame( true );
refState.viewangles[1] = i / 128.0 * 360.0f;
ref.dllFuncs.R_RenderScene();
ref.dllFuncs.R_EndFrame();
}
}
stop = Sys_DoubleTime ();
time = (stop - start);
Con_Printf( "%f seconds (%f fps)\n", time, 128 / time );
}

View File

@ -1398,7 +1398,7 @@ void CL_KillDeadBeams( cl_entity_t *pDeadEntity )
pbeam = cl_active_beams; // old list.
pnewlist = NULL; // new list.
while( pbeam )
{
pnext = pbeam->next;
@ -1418,7 +1418,7 @@ void CL_KillDeadBeams( cl_entity_t *pDeadEntity )
if( pbeam->type != TE_BEAMFOLLOW )
{
// remove beam
pbeam->die = cl.time - 0.1f;
pbeam->die = cl.time - 0.1f;
// kill off particles
pHead = pbeam->particles;
@ -1959,7 +1959,7 @@ void CL_ReadLineFile_f( void )
Con_Printf( S_ERROR "couldn't open %s\n", filename );
return;
}
Con_Printf( "Reading %s...\n", filename );
count = 0;
@ -2002,7 +2002,7 @@ void CL_ReadLineFile_f( void )
p2[2] = Q_atof( token );
count++;
if( !R_BeamPoints( p1, p2, modelIndex, 0, 2, 0, 255, 0, 0, 0, 255.0f, 0.0f, 0.0f ))
{
if( !model || model->type != mod_sprite )

491
ref_gl/gl_context.c Normal file
View File

@ -0,0 +1,491 @@
/*
vid_sdl.c - SDL vid component
Copyright (C) 2018 a1batross
This program 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 3 of the License, or
(at your option) any later version.
This program 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.
*/
#include "common.h"
#include "client.h"
#include "gl_local.h"
#include "gl_export.h"
#define GL_CALL( x ) #x, (void**)&p##x
static dllfunc_t opengl_110funcs[] =
{
{ GL_CALL( glClearColor ) },
{ GL_CALL( glClear ) },
{ GL_CALL( glAlphaFunc ) },
{ GL_CALL( glBlendFunc ) },
{ GL_CALL( glCullFace ) },
{ GL_CALL( glDrawBuffer ) },
{ GL_CALL( glReadBuffer ) },
{ GL_CALL( glAccum ) },
{ GL_CALL( glEnable ) },
{ GL_CALL( glDisable ) },
{ GL_CALL( glEnableClientState ) },
{ GL_CALL( glDisableClientState ) },
{ GL_CALL( glGetBooleanv ) },
{ GL_CALL( glGetDoublev ) },
{ GL_CALL( glGetFloatv ) },
{ GL_CALL( glGetIntegerv ) },
{ GL_CALL( glGetError ) },
{ GL_CALL( glGetString ) },
{ GL_CALL( glFinish ) },
{ GL_CALL( glFlush ) },
{ GL_CALL( glClearDepth ) },
{ GL_CALL( glDepthFunc ) },
{ GL_CALL( glDepthMask ) },
{ GL_CALL( glDepthRange ) },
{ GL_CALL( glFrontFace ) },
{ GL_CALL( glDrawElements ) },
{ GL_CALL( glDrawArrays ) },
{ GL_CALL( glColorMask ) },
{ GL_CALL( glIndexPointer ) },
{ GL_CALL( glVertexPointer ) },
{ GL_CALL( glNormalPointer ) },
{ GL_CALL( glColorPointer ) },
{ GL_CALL( glTexCoordPointer ) },
{ GL_CALL( glArrayElement ) },
{ GL_CALL( glColor3f ) },
{ GL_CALL( glColor3fv ) },
{ GL_CALL( glColor4f ) },
{ GL_CALL( glColor4fv ) },
{ GL_CALL( glColor3ub ) },
{ GL_CALL( glColor4ub ) },
{ GL_CALL( glColor4ubv ) },
{ GL_CALL( glTexCoord1f ) },
{ GL_CALL( glTexCoord2f ) },
{ GL_CALL( glTexCoord3f ) },
{ GL_CALL( glTexCoord4f ) },
{ GL_CALL( glTexCoord1fv ) },
{ GL_CALL( glTexCoord2fv ) },
{ GL_CALL( glTexCoord3fv ) },
{ GL_CALL( glTexCoord4fv ) },
{ GL_CALL( glTexGenf ) },
{ GL_CALL( glTexGenfv ) },
{ GL_CALL( glTexGeni ) },
{ GL_CALL( glVertex2f ) },
{ GL_CALL( glVertex3f ) },
{ GL_CALL( glVertex3fv ) },
{ GL_CALL( glNormal3f ) },
{ GL_CALL( glNormal3fv ) },
{ GL_CALL( glBegin ) },
{ GL_CALL( glEnd ) },
{ GL_CALL( glLineWidth ) },
{ GL_CALL( glPointSize ) },
{ GL_CALL( glMatrixMode ) },
{ GL_CALL( glOrtho ) },
{ GL_CALL( glRasterPos2f ) },
{ GL_CALL( glFrustum ) },
{ GL_CALL( glViewport ) },
{ GL_CALL( glPushMatrix ) },
{ GL_CALL( glPopMatrix ) },
{ GL_CALL( glPushAttrib ) },
{ GL_CALL( glPopAttrib ) },
{ GL_CALL( glLoadIdentity ) },
{ GL_CALL( glLoadMatrixd ) },
{ GL_CALL( glLoadMatrixf ) },
{ GL_CALL( glMultMatrixd ) },
{ GL_CALL( glMultMatrixf ) },
{ GL_CALL( glRotated ) },
{ GL_CALL( glRotatef ) },
{ GL_CALL( glScaled ) },
{ GL_CALL( glScalef ) },
{ GL_CALL( glTranslated ) },
{ GL_CALL( glTranslatef ) },
{ GL_CALL( glReadPixels ) },
{ GL_CALL( glDrawPixels ) },
{ GL_CALL( glStencilFunc ) },
{ GL_CALL( glStencilMask ) },
{ GL_CALL( glStencilOp ) },
{ GL_CALL( glClearStencil ) },
{ GL_CALL( glIsEnabled ) },
{ GL_CALL( glIsList ) },
{ GL_CALL( glIsTexture ) },
{ GL_CALL( glTexEnvf ) },
{ GL_CALL( glTexEnvfv ) },
{ GL_CALL( glTexEnvi ) },
{ GL_CALL( glTexParameterf ) },
{ GL_CALL( glTexParameterfv ) },
{ GL_CALL( glTexParameteri ) },
{ GL_CALL( glHint ) },
{ GL_CALL( glPixelStoref ) },
{ GL_CALL( glPixelStorei ) },
{ GL_CALL( glGenTextures ) },
{ GL_CALL( glDeleteTextures ) },
{ GL_CALL( glBindTexture ) },
{ GL_CALL( glTexImage1D ) },
{ GL_CALL( glTexImage2D ) },
{ GL_CALL( glTexSubImage1D ) },
{ GL_CALL( glTexSubImage2D ) },
{ GL_CALL( glCopyTexImage1D ) },
{ GL_CALL( glCopyTexImage2D ) },
{ GL_CALL( glCopyTexSubImage1D ) },
{ GL_CALL( glCopyTexSubImage2D ) },
{ GL_CALL( glScissor ) },
{ GL_CALL( glGetTexImage ) },
{ GL_CALL( glGetTexEnviv ) },
{ GL_CALL( glPolygonOffset ) },
{ GL_CALL( glPolygonMode ) },
{ GL_CALL( glPolygonStipple ) },
{ GL_CALL( glClipPlane ) },
{ GL_CALL( glGetClipPlane ) },
{ GL_CALL( glShadeModel ) },
{ GL_CALL( glGetTexLevelParameteriv ) },
{ GL_CALL( glGetTexLevelParameterfv ) },
{ GL_CALL( glFogfv ) },
{ GL_CALL( glFogf ) },
{ GL_CALL( glFogi ) },
{ NULL , NULL }
};
static dllfunc_t debugoutputfuncs[] =
{
{ GL_CALL( glDebugMessageControlARB ) },
{ GL_CALL( glDebugMessageInsertARB ) },
{ GL_CALL( glDebugMessageCallbackARB ) },
{ GL_CALL( glGetDebugMessageLogARB ) },
{ NULL , NULL }
};
static dllfunc_t multitexturefuncs[] =
{
{ GL_CALL( glMultiTexCoord1f ) },
{ GL_CALL( glMultiTexCoord2f ) },
{ GL_CALL( glMultiTexCoord3f ) },
{ GL_CALL( glMultiTexCoord4f ) },
{ GL_CALL( glActiveTexture ) },
{ GL_CALL( glActiveTextureARB ) },
{ GL_CALL( glClientActiveTexture ) },
{ GL_CALL( glClientActiveTextureARB ) },
{ NULL , NULL }
};
static dllfunc_t texture3dextfuncs[] =
{
{ GL_CALL( glTexImage3D ) },
{ GL_CALL( glTexSubImage3D ) },
{ GL_CALL( glCopyTexSubImage3D ) },
{ NULL , NULL }
};
static dllfunc_t texturecompressionfuncs[] =
{
{ GL_CALL( glCompressedTexImage3DARB ) },
{ GL_CALL( glCompressedTexImage2DARB ) },
{ GL_CALL( glCompressedTexImage1DARB ) },
{ GL_CALL( glCompressedTexSubImage3DARB ) },
{ GL_CALL( glCompressedTexSubImage2DARB ) },
{ GL_CALL( glCompressedTexSubImage1DARB ) },
{ GL_CALL( glGetCompressedTexImage ) },
{ NULL , NULL }
};
static dllfunc_t vbofuncs[] =
{
{ GL_CALL( glBindBufferARB ) },
{ GL_CALL( glDeleteBuffersARB ) },
{ GL_CALL( glGenBuffersARB ) },
{ GL_CALL( glIsBufferARB ) },
{ GL_CALL( glMapBufferARB ) },
{ GL_CALL( glUnmapBufferARB ) }, // ,
{ GL_CALL( glBufferDataARB ) },
{ GL_CALL( glBufferSubDataARB ) },
{ NULL, NULL}
};
/*
========================
DebugCallback
For ARB_debug_output
========================
*/
static void APIENTRY GL_DebugOutput( GLuint source, GLuint type, GLuint id, GLuint severity, GLint length, const GLcharARB *message, GLvoid *userParam )
{
switch( type )
{
case GL_DEBUG_TYPE_ERROR_ARB:
Con_Printf( S_OPENGL_ERROR "%s\n", message );
break;
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB:
Con_Printf( S_OPENGL_WARN "%s\n", message );
break;
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB:
Con_Printf( S_OPENGL_WARN "%s\n", message );
break;
case GL_DEBUG_TYPE_PORTABILITY_ARB:
if( host_developer.value < DEV_EXTENDED )
return;
Con_Printf( S_OPENGL_WARN "%s\n", message );
break;
case GL_DEBUG_TYPE_PERFORMANCE_ARB:
Con_Printf( S_OPENGL_NOTE "%s\n", message );
break;
case GL_DEBUG_TYPE_OTHER_ARB:
default: Con_Printf( S_OPENGL_NOTE "%s\n", message );
break;
}
}
#ifdef XASH_GLES
void GL_InitExtensionsGLES( void )
{
// intialize wrapper type
#ifdef XASH_NANOGL
glConfig.context = CONTEXT_TYPE_GLES_1_X;
glConfig.wrapper = GLES_WRAPPER_NANOGL;
#elif defined( XASH_WES )
glConfig.context = CONTEXT_TYPE_GLES_2_X;
glConfig.wrapper = GLES_WRAPPER_WES;
#endif
glConfig.hardware_type = GLHW_GENERIC;
// initalize until base opengl functions loaded
GL_SetExtension( GL_DRAW_RANGEELEMENTS_EXT, true );
GL_SetExtension( GL_ARB_MULTITEXTURE, true );
pglGetIntegerv( GL_MAX_TEXTURE_UNITS_ARB, &glConfig.max_texture_units );
glConfig.max_texture_coords = glConfig.max_texture_units = 4;
GL_SetExtension( GL_ENV_COMBINE_EXT, true );
GL_SetExtension( GL_DOT3_ARB_EXT, true );
GL_SetExtension( GL_TEXTURE_3D_EXT, false );
GL_SetExtension( GL_SGIS_MIPMAPS_EXT, true ); // gles specs
GL_SetExtension( GL_ARB_VERTEX_BUFFER_OBJECT_EXT, true ); // gles specs
// hardware cubemaps
GL_CheckExtension( "GL_OES_texture_cube_map", NULL, "gl_texture_cubemap", GL_TEXTURECUBEMAP_EXT );
if( GL_Support( GL_TEXTURECUBEMAP_EXT ))
pglGetIntegerv( GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, &glConfig.max_cubemap_size );
GL_SetExtension( GL_ARB_SEAMLESS_CUBEMAP, false );
GL_SetExtension( GL_EXT_POINTPARAMETERS, false );
GL_CheckExtension( "GL_OES_texture_npot", NULL, "gl_texture_npot", GL_ARB_TEXTURE_NPOT_EXT );
GL_SetExtension( GL_TEXTURE_COMPRESSION_EXT, false );
GL_SetExtension( GL_CUSTOM_VERTEX_ARRAY_EXT, false );
GL_SetExtension( GL_CLAMPTOEDGE_EXT, true ); // by gles1 specs
GL_SetExtension( GL_ANISOTROPY_EXT, false );
GL_SetExtension( GL_TEXTURE_LODBIAS, false );
GL_SetExtension( GL_CLAMP_TEXBORDER_EXT, false );
GL_SetExtension( GL_BLEND_MINMAX_EXT, false );
GL_SetExtension( GL_BLEND_SUBTRACT_EXT, false );
GL_SetExtension( GL_SEPARATESTENCIL_EXT, false );
GL_SetExtension( GL_STENCILTWOSIDE_EXT, false );
GL_SetExtension( GL_TEXTURE_ENV_ADD_EXT,false );
GL_SetExtension( GL_SHADER_OBJECTS_EXT, false );
GL_SetExtension( GL_SHADER_GLSL100_EXT, false );
GL_SetExtension( GL_VERTEX_SHADER_EXT,false );
GL_SetExtension( GL_FRAGMENT_SHADER_EXT, false );
GL_SetExtension( GL_SHADOW_EXT, false );
GL_SetExtension( GL_ARB_DEPTH_FLOAT_EXT, false );
GL_SetExtension( GL_OCCLUSION_QUERIES_EXT,false );
GL_CheckExtension( "GL_OES_depth_texture", NULL, "gl_depthtexture", GL_DEPTH_TEXTURE );
glConfig.texRectangle = glConfig.max_2d_rectangle_size = 0; // no rectangle
Cvar_FullSet( "gl_allow_mirrors", "0", CVAR_READ_ONLY); // No support for GLES
}
#else
void GL_InitExtensionsBigGL()
{
// intialize wrapper type
glConfig.context = CONTEXT_TYPE_GL;
glConfig.wrapper = GLES_WRAPPER_NONE;
if( Q_stristr( glConfig.renderer_string, "geforce" ))
glConfig.hardware_type = GLHW_NVIDIA;
else if( Q_stristr( glConfig.renderer_string, "quadro fx" ))
glConfig.hardware_type = GLHW_NVIDIA;
else if( Q_stristr(glConfig.renderer_string, "rv770" ))
glConfig.hardware_type = GLHW_RADEON;
else if( Q_stristr(glConfig.renderer_string, "radeon hd" ))
glConfig.hardware_type = GLHW_RADEON;
else if( Q_stristr( glConfig.renderer_string, "eah4850" ) || Q_stristr( glConfig.renderer_string, "eah4870" ))
glConfig.hardware_type = GLHW_RADEON;
else if( Q_stristr( glConfig.renderer_string, "radeon" ))
glConfig.hardware_type = GLHW_RADEON;
else if( Q_stristr( glConfig.renderer_string, "intel" ))
glConfig.hardware_type = GLHW_INTEL;
else glConfig.hardware_type = GLHW_GENERIC;
// multitexture
glConfig.max_texture_units = glConfig.max_texture_coords = glConfig.max_teximage_units = 1;
GL_CheckExtension( "GL_ARB_multitexture", multitexturefuncs, "gl_arb_multitexture", GL_ARB_MULTITEXTURE );
if( GL_Support( GL_ARB_MULTITEXTURE ))
{
pglGetIntegerv( GL_MAX_TEXTURE_UNITS_ARB, &glConfig.max_texture_units );
}
if( glConfig.max_texture_units == 1 )
GL_SetExtension( GL_ARB_MULTITEXTURE, false );
// 3d texture support
GL_CheckExtension( "GL_EXT_texture3D", texture3dextfuncs, "gl_texture_3d", GL_TEXTURE_3D_EXT );
if( GL_Support( GL_TEXTURE_3D_EXT ))
{
pglGetIntegerv( GL_MAX_3D_TEXTURE_SIZE, &glConfig.max_3d_texture_size );
if( glConfig.max_3d_texture_size < 32 )
{
GL_SetExtension( GL_TEXTURE_3D_EXT, false );
Con_Printf( S_ERROR "GL_EXT_texture3D reported bogus GL_MAX_3D_TEXTURE_SIZE, disabled\n" );
}
}
// 2d texture array support
GL_CheckExtension( "GL_EXT_texture_array", texture3dextfuncs, "gl_texture_2d_array", GL_TEXTURE_ARRAY_EXT );
if( GL_Support( GL_TEXTURE_ARRAY_EXT ))
pglGetIntegerv( GL_MAX_ARRAY_TEXTURE_LAYERS_EXT, &glConfig.max_2d_texture_layers );
// cubemaps support
GL_CheckExtension( "GL_ARB_texture_cube_map", NULL, "gl_texture_cubemap", GL_TEXTURE_CUBEMAP_EXT );
if( GL_Support( GL_TEXTURE_CUBEMAP_EXT ))
{
pglGetIntegerv( GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, &glConfig.max_cubemap_size );
// check for seamless cubemaps too
GL_CheckExtension( "GL_ARB_seamless_cube_map", NULL, "gl_texture_cubemap_seamless", GL_ARB_SEAMLESS_CUBEMAP );
}
GL_CheckExtension( "GL_ARB_texture_non_power_of_two", NULL, "gl_texture_npot", GL_ARB_TEXTURE_NPOT_EXT );
GL_CheckExtension( "GL_ARB_texture_compression", texturecompressionfuncs, "gl_dds_hardware_support", GL_TEXTURE_COMPRESSION_EXT );
GL_CheckExtension( "GL_EXT_texture_edge_clamp", NULL, "gl_clamp_to_edge", GL_CLAMPTOEDGE_EXT );
if( !GL_Support( GL_CLAMPTOEDGE_EXT ))
GL_CheckExtension( "GL_SGIS_texture_edge_clamp", NULL, "gl_clamp_to_edge", GL_CLAMPTOEDGE_EXT );
glConfig.max_texture_anisotropy = 0.0f;
GL_CheckExtension( "GL_EXT_texture_filter_anisotropic", NULL, "gl_ext_anisotropic_filter", GL_ANISOTROPY_EXT );
if( GL_Support( GL_ANISOTROPY_EXT ))
pglGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &glConfig.max_texture_anisotropy );
#ifdef _WIN32 // Win32 only drivers?
// g-cont. because lodbias it too glitchy on Intel's cards
if( glConfig.hardware_type != GLHW_INTEL )
#endif
GL_CheckExtension( "GL_EXT_texture_lod_bias", NULL, "gl_texture_mipmap_biasing", GL_TEXTURE_LOD_BIAS );
if( GL_Support( GL_TEXTURE_LOD_BIAS ))
pglGetFloatv( GL_MAX_TEXTURE_LOD_BIAS_EXT, &glConfig.max_texture_lod_bias );
GL_CheckExtension( "GL_ARB_texture_border_clamp", NULL, "gl_ext_texborder_clamp", GL_CLAMP_TEXBORDER_EXT );
GL_CheckExtension( "GL_ARB_depth_texture", NULL, "gl_depthtexture", GL_DEPTH_TEXTURE );
GL_CheckExtension( "GL_ARB_texture_float", NULL, "gl_arb_texture_float", GL_ARB_TEXTURE_FLOAT_EXT );
GL_CheckExtension( "GL_ARB_depth_buffer_float", NULL, "gl_arb_depth_float", GL_ARB_DEPTH_FLOAT_EXT );
GL_CheckExtension( "GL_EXT_gpu_shader4", NULL, NULL, GL_EXT_GPU_SHADER4 ); // don't confuse users
GL_CheckExtension( "GL_ARB_shading_language_100", NULL, "gl_glslprogram", GL_SHADER_GLSL100_EXT );
GL_CheckExtension( "GL_ARB_vertex_buffer_object", vbofuncs, "gl_vertex_buffer_object", GL_ARB_VERTEX_BUFFER_OBJECT_EXT );
// rectangle textures support
GL_CheckExtension( "GL_ARB_texture_rectangle", NULL, "gl_texture_rectangle", GL_TEXTURE_2D_RECT_EXT );
// this won't work without extended context
if( glw_state.extended )
GL_CheckExtension( "GL_ARB_debug_output", debugoutputfuncs, "gl_debug_output", GL_DEBUG_OUTPUT );
if( GL_Support( GL_SHADER_GLSL100_EXT ))
{
pglGetIntegerv( GL_MAX_TEXTURE_COORDS_ARB, &glConfig.max_texture_coords );
pglGetIntegerv( GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &glConfig.max_teximage_units );
// check for hardware skinning
pglGetIntegerv( GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, &glConfig.max_vertex_uniforms );
pglGetIntegerv( GL_MAX_VERTEX_ATTRIBS_ARB, &glConfig.max_vertex_attribs );
#ifdef _WIN32 // Win32 only drivers?
if( glConfig.hardware_type == GLHW_RADEON && glConfig.max_vertex_uniforms > 512 )
glConfig.max_vertex_uniforms /= 4; // radeon returns not correct info
#endif
}
else
{
// just get from multitexturing
glConfig.max_texture_coords = glConfig.max_teximage_units = glConfig.max_texture_units;
}
pglGetIntegerv( GL_MAX_TEXTURE_SIZE, &glConfig.max_2d_texture_size );
if( glConfig.max_2d_texture_size <= 0 ) glConfig.max_2d_texture_size = 256;
if( GL_Support( GL_TEXTURE_2D_RECT_EXT ))
pglGetIntegerv( GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT, &glConfig.max_2d_rectangle_size );
#ifndef XASH_GL_STATIC
// enable gldebug if allowed
if( GL_Support( GL_DEBUG_OUTPUT ))
{
if( host_developer.value )
{
Con_Reportf( "Installing GL_DebugOutput...\n");
pglDebugMessageCallbackARB( GL_DebugOutput, NULL );
// force everything to happen in the main thread instead of in a separate driver thread
pglEnable( GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB );
}
// enable all the low priority messages
pglDebugMessageControlARB( GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_LOW_ARB, 0, NULL, true );
}
#endif
}
#endif
void GL_InitExtensions( void )
{
// initialize gl extensions
GL_CheckExtension( "OpenGL 1.1.0", opengl_110funcs, NULL, GL_OPENGL_110 );
// get our various GL strings
glConfig.vendor_string = pglGetString( GL_VENDOR );
glConfig.renderer_string = pglGetString( GL_RENDERER );
glConfig.version_string = pglGetString( GL_VERSION );
glConfig.extensions_string = pglGetString( GL_EXTENSIONS );
Con_Reportf( "^3Video^7: %s\n", glConfig.renderer_string );
#ifdef XASH_GLES
GL_InitExtensionsGLES();
#else
GL_InitExtensionsBigGL();
#endif
if( GL_Support( GL_TEXTURE_2D_RECT_EXT ))
pglGetIntegerv( GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT, &glConfig.max_2d_rectangle_size );
Cvar_Get( "gl_max_size", va( "%i", glConfig.max_2d_texture_size ), 0, "opengl texture max dims" );
Cvar_Set( "gl_anisotropy", va( "%f", bound( 0, gl_texture_anisotropy->value, glConfig.max_texture_anisotropy )));
if( GL_Support( GL_TEXTURE_COMPRESSION_EXT ))
Image_AddCmdFlags( IL_DDS_HARDWARE );
// MCD has buffering issues
#ifdef _WIN32
if( Q_strstr( glConfig.renderer_string, "gdi" ))
Cvar_SetValue( "gl_finish", 1 );
#endif
tr.framecount = tr.visframecount = 1;
glw_state.initialized = true;
}
void GL_ClearExtensions( void )
{
// now all extensions are disabled
memset( glConfig.extension, 0, sizeof( glConfig.extension ));
glw_state.initialized = false;
}

93
ref_gl/gl_dbghulls.c Normal file
View File

@ -0,0 +1,93 @@
/*
gl_dbghulls.c - loading & handling world and brushmodels
Copyright (C) 2016 Uncle Mike
This program 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 3 of the License, or
(at your option) any later version.
This program 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.
*/
#include "mod_local.h"
#include "mathlib.h"
#include "world.h"
#include "gl_local.h"
#include "client.h"
#define list_entry( ptr, type, member ) \
((type *)((char *)(ptr) - (size_t)(&((type *)0)->member)))
// iterate over each entry in the list
#define list_for_each_entry( pos, head, member ) \
for( pos = list_entry( (head)->next, winding_t, member ); \
&pos->member != (head); \
pos = list_entry( pos->member.next, winding_t, member ))
void R_DrawWorldHull( void )
{
hull_model_t *hull = &world.hull_models[0];
winding_t *poly;
int i;
if( FBitSet( r_showhull->flags, FCVAR_CHANGED ))
{
int val = bound( 0, (int)r_showhull->value, 3 );
if( val ) Mod_CreatePolygonsForHull( val );
ClearBits( r_showhull->flags, FCVAR_CHANGED );
}
if( !CVAR_TO_BOOL( r_showhull ))
return;
pglDisable( GL_TEXTURE_2D );
list_for_each_entry( poly, &hull->polys, chain )
{
srand((unsigned int)poly);
pglColor3f( rand() % 256 / 255.0, rand() % 256 / 255.0, rand() % 256 / 255.0 );
pglBegin( GL_POLYGON );
for( i = 0; i < poly->numpoints; i++ )
pglVertex3fv( poly->p[i] );
pglEnd();
}
pglEnable( GL_TEXTURE_2D );
}
void R_DrawModelHull( void )
{
hull_model_t *hull;
winding_t *poly;
int i;
if( !CVAR_TO_BOOL( r_showhull ))
return;
if( !RI.currentmodel || RI.currentmodel->name[0] != '*' )
return;
i = atoi( RI.currentmodel->name + 1 );
if( i < 1 || i >= world.num_hull_models )
return;
hull = &world.hull_models[i];
pglPolygonOffset( 1.0f, 2.0 );
pglEnable( GL_POLYGON_OFFSET_FILL );
pglDisable( GL_TEXTURE_2D );
list_for_each_entry( poly, &hull->polys, chain )
{
srand((unsigned int)poly);
pglColor3f( rand() % 256 / 255.0, rand() % 256 / 255.0, rand() % 256 / 255.0 );
pglBegin( GL_POLYGON );
for( i = 0; i < poly->numpoints; i++ )
pglVertex3fv( poly->p[i] );
pglEnd();
}
pglEnable( GL_TEXTURE_2D );
pglDisable( GL_POLYGON_OFFSET_FILL );
}

View File

@ -1761,21 +1761,6 @@ int GL_FindTexture( const char *name )
return 0;
}
/*
================
GL_FreeImage
Frees image by name
================
*/
void GL_FreeImage( const char *name )
{
int texnum;
if(( texnum = GL_FindTexture( name )) != 0 )
GL_FreeTexture( texnum );
}
/*
================
GL_FreeTexture

View File

@ -22,6 +22,7 @@ GNU General Public License for more details.
#include "protocol.h"
#include "dlight.h"
#include "gl_frustum.h"
#include "ref_api.h"
extern byte *r_temppool;
@ -52,11 +53,6 @@ extern byte *r_temppool;
#define RP_LOCALCLIENT( e ) ((e) != NULL && (e)->index == ( cl.playernum + 1 ) && e->player )
#define RP_NORMALPASS() ( FBitSet( RI.params, RP_NONVIEWERREF ) == 0 )
#define TF_SKY (TF_SKYSIDE|TF_NOMIPMAP)
#define TF_FONT (TF_NOMIPMAP|TF_CLAMP)
#define TF_IMAGE (TF_NOMIPMAP|TF_CLAMP)
#define TF_DECAL (TF_CLAMP)
#define CULL_VISIBLE 0 // not culled
#define CULL_BACKSIDE 1 // backside of transparent wall
#define CULL_FRUSTUM 2 // culled by frustum
@ -215,7 +211,7 @@ typedef struct
// cull info
vec3_t modelorg; // relative to viewpoint
} ref_globals_t;
} gl_globals_t;
typedef struct
{
@ -239,7 +235,7 @@ typedef struct
extern ref_speeds_t r_stats;
extern ref_instance_t RI;
extern ref_globals_t tr;
extern gl_globals_t tr;
extern float gldepthmin, gldepthmax;
extern dlight_t cl_dlights[MAX_DLIGHTS];
@ -323,7 +319,6 @@ void GL_UpdateTexSize( int texnum, int width, int height, int depth );
void GL_ApplyTextureParams( gl_texture_t *tex );
int GL_FindTexture( const char *name );
void GL_FreeTexture( GLenum texnum );
void GL_FreeImage( const char *name );
const char *GL_Target( GLenum target );
void R_InitDlightTexture( void );
void R_TextureList_f( void );
@ -369,8 +364,6 @@ void R_DrawFog( void );
//
// gl_rmath.c
//
float V_CalcFov( float *fov_x, float width, float height );
void V_AdjustFov( float *fov_x, float *fov_y, float width, float height, qboolean lock_x );
void Matrix4x4_ToArrayFloatGL( const matrix4x4 in, float out[16] );
void Matrix4x4_FromArrayFloatGL( matrix4x4 out, const float in[16] );
void Matrix4x4_Concat( matrix4x4 out, const matrix4x4 in1, const matrix4x4 in2 );
@ -452,6 +445,23 @@ void R_DrawSkyBox( void );
void R_DrawClouds( void );
void EmitWaterPolys( msurface_t *warp, qboolean reverse );
//
// gl_vgui.c
//
void VGUI_DrawInit( void );
void VGUI_DrawShutdown( void );
void VGUI_SetupDrawingText( int *pColor );
void VGUI_SetupDrawingRect( int *pColor );
void VGUI_SetupDrawingImage( int *pColor );
void VGUI_BindTexture( int id );
void VGUI_EnableTexture( qboolean enable );
void VGUI_CreateTexture( int id, int width, int height );
void VGUI_UploadTexture( int id, const char *buffer, int width, int height );
void VGUI_UploadTextureBlock( int id, int drawX, int drawY, const byte *rgba, int blockWidth, int blockHeight );
void VGUI_DrawQuad( const vpoint_t *ul, const vpoint_t *lr );
void VGUI_GetTextureSizes( int *width, int *height );
int VGUI_GenerateTexture( void );
#include "vid_common.h"
//
@ -530,17 +540,6 @@ enum
GL_EXTCOUNT, // must be last
};
enum
{
GL_KEEP_UNIT = -1,
XASH_TEXTURE0 = 0,
XASH_TEXTURE1,
XASH_TEXTURE2,
XASH_TEXTURE3, // g-cont. 4 units should be enough
XASH_TEXTURE4, // mittorn. bump+detail needs 5 for single-pass
MAX_TEXTURE_UNITS = 32 // can't access to all over units without GLSL or cg
};
typedef enum
{
GLHW_GENERIC, // where everthing works the way it should
@ -673,7 +672,6 @@ extern convar_t *r_lighting_ambient;
extern convar_t *r_studio_lambert;
extern convar_t *r_detailtextures;
extern convar_t *r_drawentities;
extern convar_t *r_adjust_fov;
extern convar_t *r_decals;
extern convar_t *r_novis;
extern convar_t *r_nocull;
@ -685,14 +683,8 @@ extern convar_t *r_lightmap;
extern convar_t *r_vbo;
extern convar_t *r_vbo_dlightmode;
extern convar_t *vid_displayfrequency;
extern convar_t *vid_fullscreen;
extern convar_t *vid_brightness;
extern convar_t *vid_gamma;
extern convar_t *vid_highdpi;
extern convar_t *window_xpos;
extern convar_t *window_ypos;
extern convar_t *scr_height;
#endif//GL_LOCAL_H

View File

@ -1391,7 +1391,7 @@ const byte *GL_TextureData( unsigned int texnum )
if( pic != NULL )
return pic->buffer;
return NULL;
return NULL;
}
static const ref_overview_t *GL_GetOverviewParms( void )

View File

@ -18,53 +18,6 @@ GNU General Public License for more details.
#include "mathlib.h"
#include "client.h"
/*
====================
V_CalcFov
====================
*/
float V_CalcFov( float *fov_x, float width, float height )
{
float x, half_fov_y;
if( *fov_x < 1.0f || *fov_x > 179.0f )
*fov_x = 90.0f; // default value
x = width / tan( DEG2RAD( *fov_x ) * 0.5f );
half_fov_y = atan( height / x );
return RAD2DEG( half_fov_y ) * 2;
}
/*
====================
V_AdjustFov
====================
*/
void V_AdjustFov( float *fov_x, float *fov_y, float width, float height, qboolean lock_x )
{
float x, y;
if( width * 3 == 4 * height || width * 4 == height * 5 )
{
// 4:3 or 5:4 ratio
return;
}
if( lock_x )
{
*fov_y = 2 * atan((width * 3) / (height * 4) * tan( *fov_y * M_PI / 360.0 * 0.5 )) * 360 / M_PI;
return;
}
y = V_CalcFov( fov_x, 640, 480 );
x = *fov_x;
*fov_x = V_CalcFov( &y, height, width );
if( *fov_x < x ) *fov_x = x;
else *fov_y = y;
}
/*
========================================================================
@ -313,4 +266,4 @@ void Matrix4x4_ConcatScale3( matrix4x4 out, float x, float y, float z )
Matrix4x4_Copy( base, out );
Matrix4x4_CreateScale3( temp, x, y, z );
Matrix4x4_Concat( out, base, temp );
}
}

View File

@ -104,29 +104,6 @@ static void R_ParseDetailTextures( const char *filename )
Mem_Free( afile );
}
/*
=======================
R_ClearStaticEntities
e.g. by demo request
=======================
*/
void R_ClearStaticEntities( void )
{
int i;
if( host.type == HOST_DEDICATED )
return;
// clear out efrags in case the level hasn't been reloaded
for( i = 0; i < cl.worldmodel->numleafs; i++ )
cl.worldmodel->leafs[i+1].efrags = NULL;
clgame.numStatics = 0;
CL_ClearEfrags ();
}
void R_NewMap( void )
{
texture_t *tx;

View File

@ -663,33 +663,6 @@ float R_StudioEstimateInterpolant( cl_entity_t *e )
return dadt;
}
/*
====================
CL_GetStudioEstimatedFrame
====================
*/
float CL_GetStudioEstimatedFrame( cl_entity_t *ent )
{
studiohdr_t *pstudiohdr;
mstudioseqdesc_t *pseqdesc;
int sequence;
if( ent->model != NULL && ent->model->type == mod_studio )
{
pstudiohdr = (studiohdr_t *)Mod_StudioExtradata( ent->model );
if( pstudiohdr )
{
sequence = bound( 0, ent->curstate.sequence, pstudiohdr->numseq - 1 );
pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr + pstudiohdr->seqindex) + sequence;
return R_StudioEstimateFrame( ent, pseqdesc );
}
}
return 0;
}
/*
====================
CL_GetSequenceDuration

335
ref_gl/gl_triapi.c Normal file
View File

@ -0,0 +1,335 @@
/*
gl_triapi.c - TriAPI draw methods
Copyright (C) 2011 Uncle Mike
Copyright (C) 2019 a1batross
This program 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 3 of the License, or
(at your option) any later version.
This program 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.
*/
#include "gl_local.h"
#include "const.h"
/*
===============================================================
TRIAPI IMPLEMENTATION
===============================================================
*/
/*
=============
TriRenderMode
set rendermode
=============
*/
void TriRenderMode( int mode )
{
switch( mode )
{
case kRenderNormal:
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
pglDisable( GL_BLEND );
pglDepthMask( GL_TRUE );
break;
case kRenderTransAlpha:
pglEnable( GL_BLEND );
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
pglDepthMask( GL_FALSE );
break;
case kRenderTransColor:
case kRenderTransTexture:
pglEnable( GL_BLEND );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
break;
case kRenderGlow:
case kRenderTransAdd:
pglBlendFunc( GL_SRC_ALPHA, GL_ONE );
pglEnable( GL_BLEND );
pglDepthMask( GL_FALSE );
break;
}
}
/*
=============
TriBegin
begin triangle sequence
=============
*/
void TriBegin( int mode )
{
switch( mode )
{
case TRI_POINTS:
mode = GL_POINTS;
break;
case TRI_TRIANGLES:
mode = GL_TRIANGLES;
break;
case TRI_TRIANGLE_FAN:
mode = GL_TRIANGLE_FAN;
break;
case TRI_QUADS:
mode = GL_QUADS;
break;
case TRI_LINES:
mode = GL_LINES;
break;
case TRI_TRIANGLE_STRIP:
mode = GL_TRIANGLE_STRIP;
break;
case TRI_QUAD_STRIP:
mode = GL_QUAD_STRIP;
break;
case TRI_POLYGON:
default:
mode = GL_POLYGON;
break;
}
pglBegin( mode );
}
/*
=============
TriEnd
draw triangle sequence
=============
*/
void TriEnd( void )
{
pglEnd( );
}
/*
=============
_TriColor4f
=============
*/
void _TriColor4f( float r, float g, float b, float a )
{
pglColor4f( r, g, b, a );
}
/*
=============
_TriColor4ub
=============
*/
void _TriColor4ub( byte r, byte g, byte b, byte a )
{
pglColor4ub( r, g, b, a );
}
/*
=============
TriColor4f
=============
*/
void TriColor4f( float r, float g, float b, float a )
{
if( engine.TriGetRenderMode() == kRenderTransAlpha )
RefTriAPI->Color4ub( r * 255.9f, g * 255.9f, b * 255.9f, a * 255.0f );
else RefTriAPI->Color4f( r * a, g * a, b * a, 1.0 );
clgame.ds.triRGBA[0] = r;
clgame.ds.triRGBA[1] = g;
clgame.ds.triRGBA[2] = b;
clgame.ds.triRGBA[3] = a;
}
/*
=============
TriColor4ub
=============
*/
void TriColor4ub( byte r, byte g, byte b, byte a )
{
clgame.ds.triRGBA[0] = r * (1.0f / 255.0f);
clgame.ds.triRGBA[1] = g * (1.0f / 255.0f);
clgame.ds.triRGBA[2] = b * (1.0f / 255.0f);
clgame.ds.triRGBA[3] = a * (1.0f / 255.0f);
pglColor4f( clgame.ds.triRGBA[0], clgame.ds.triRGBA[1], clgame.ds.triRGBA[2], 1.0f );
}
/*
=============
TriTexCoord2f
=============
*/
void TriTexCoord2f( float u, float v )
{
pglTexCoord2f( u, v );
}
/*
=============
TriVertex3fv
=============
*/
void TriVertex3fv( const float *v )
{
pglVertex3fv( v );
}
/*
=============
TriVertex3f
=============
*/
void TriVertex3f( float x, float y, float z )
{
pglVertex3f( x, y, z );
}
/*
=============
TriWorldToScreen
convert world coordinates (x,y,z) into screen (x, y)
=============
*/
int TriWorldToScreen( float *world, float *screen )
{
int retval;
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];
return retval;
}
/*
=============
TriSpriteTexture
bind current texture
=============
*/
int TriSpriteTexture( model_t *pSpriteModel, int frame )
{
int gl_texturenum;
if(( gl_texturenum = R_GetSpriteTexture( pSpriteModel, frame )) == 0 )
return 0;
if( gl_texturenum <= 0 || gl_texturenum > MAX_TEXTURES )
gl_texturenum = tr.defaultTexture;
GL_Bind( XASH_TEXTURE0, gl_texturenum );
return gl_texturenum; // INCOMPATIBILITY
}
/*
=============
TriFog
enables global fog on the level
=============
*/
void TriFog( float flFogColor[3], float flStart, float flEnd, int bOn )
{
// overrided by internal fog
if( RI.fogEnabled ) return;
RI.fogCustom = bOn;
// check for invalid parms
if( flEnd <= flStart )
{
RI.fogCustom = false;
pglDisable( GL_FOG );
return;
}
if( RI.fogCustom )
pglEnable( GL_FOG );
else pglDisable( GL_FOG );
// copy fog params
RI.fogColor[0] = flFogColor[0] / 255.0f;
RI.fogColor[1] = flFogColor[1] / 255.0f;
RI.fogColor[2] = flFogColor[2] / 255.0f;
RI.fogStart = flStart;
RI.fogColor[3] = 1.0f;
RI.fogDensity = 0.0f;
RI.fogSkybox = true;
RI.fogEnd = flEnd;
pglFogi( GL_FOG_MODE, GL_LINEAR );
pglFogfv( GL_FOG_COLOR, RI.fogColor );
pglFogf( GL_FOG_START, RI.fogStart );
pglFogf( GL_FOG_END, RI.fogEnd );
pglHint( GL_FOG_HINT, GL_NICEST );
}
/*
=============
TriGetMatrix
very strange export
=============
*/
void TriGetMatrix( const int pname, float *matrix )
{
pglGetFloatv( pname, matrix );
}
/*
=============
TriForParams
=============
*/
void TriFogParams( float flDensity, int iFogSkybox )
{
RI.fogDensity = flDensity;
RI.fogSkybox = iFogSkybox;
}
/*
=============
TriCullFace
=============
*/
void _TriCullFace( TRICULLSTYLE mode )
{
int glMode;
switch( mode )
{
case TRI_FRONT:
glMode = GL_FRONT;
break;
default:
glMode = GL_NONE;
break;
}
GL_Cull( mode );
}

242
ref_gl/gl_vgui.c Normal file
View File

@ -0,0 +1,242 @@
/*
gl_vgui.c - OpenGL vgui draw methods
Copyright (C) 2011 Uncle Mike
Copyright (C) 2019 a1batross
This program 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 3 of the License, or
(at your option) any later version.
This program 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.
*/
#include "gl_local.h"
/*
================
VGUI_DrawInit
Startup VGUI backend
================
*/
void GAME_EXPORT VGUI_DrawInit( void )
{
memset( g_textures, 0, sizeof( g_textures ));
g_textureId = g_iBoundTexture = 0;
}
/*
================
VGUI_DrawShutdown
Release all textures
================
*/
void GAME_EXPORT VGUI_DrawShutdown( void )
{
int i;
for( i = 1; i < g_textureId; i++ )
{
GL_FreeTexture( g_textures[i] );
}
}
/*
================
VGUI_GenerateTexture
generate unique texture number
================
*/
int GAME_EXPORT VGUI_GenerateTexture( void )
{
if( ++g_textureId >= VGUI_MAX_TEXTURES )
Sys_Error( "VGUI_GenerateTexture: VGUI_MAX_TEXTURES limit exceeded\n" );
return g_textureId;
}
/*
================
VGUI_UploadTexture
Upload texture into video memory
================
*/
void GAME_EXPORT VGUI_UploadTexture( int id, const char *buffer, int width, int height )
{
rgbdata_t r_image;
char texName[32];
if( id <= 0 || id >= VGUI_MAX_TEXTURES )
{
Con_DPrintf( S_ERROR "VGUI_UploadTexture: bad texture %i. Ignored\n", id );
return;
}
Q_snprintf( texName, sizeof( texName ), "*vgui%i", id );
memset( &r_image, 0, sizeof( r_image ));
r_image.width = width;
r_image.height = height;
r_image.type = PF_RGBA_32;
r_image.size = r_image.width * r_image.height * 4;
r_image.flags = IMAGE_HAS_COLOR|IMAGE_HAS_ALPHA;
r_image.buffer = (byte *)buffer;
g_textures[id] = GL_LoadTextureInternal( texName, &r_image, TF_IMAGE );
}
/*
================
VGUI_CreateTexture
Create empty rgba texture and upload them into video memory
================
*/
void GAME_EXPORT VGUI_CreateTexture( int id, int width, int height )
{
rgbdata_t r_image;
char texName[32];
if( id <= 0 || id >= VGUI_MAX_TEXTURES )
{
Con_Reportf( S_ERROR "VGUI_CreateTexture: bad texture %i. Ignored\n", id );
return;
}
Q_snprintf( texName, sizeof( texName ), "*vgui%i", id );
memset( &r_image, 0, sizeof( r_image ));
r_image.width = width;
r_image.height = height;
r_image.type = PF_RGBA_32;
r_image.size = r_image.width * r_image.height * 4;
r_image.flags = IMAGE_HAS_ALPHA;
r_image.buffer = NULL;
g_textures[id] = GL_LoadTextureInternal( texName, &r_image, TF_IMAGE|TF_NEAREST );
g_iBoundTexture = id;
}
void GAME_EXPORT VGUI_UploadTextureBlock( int id, int drawX, int drawY, const byte *rgba, int blockWidth, int blockHeight )
{
if( id <= 0 || id >= VGUI_MAX_TEXTURES || g_textures[id] == 0 || g_textures[id] == tr.whiteTexture )
{
Con_Reportf( S_ERROR "VGUI_UploadTextureBlock: bad texture %i. Ignored\n", id );
return;
}
pglTexSubImage2D( GL_TEXTURE_2D, 0, drawX, drawY, blockWidth, blockHeight, GL_RGBA, GL_UNSIGNED_BYTE, rgba );
g_iBoundTexture = id;
}
void GAME_EXPORT VGUI_SetupDrawingRect( int *pColor )
{
pglEnable( GL_BLEND );
pglDisable( GL_ALPHA_TEST );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
pglColor4ub( pColor[0], pColor[1], pColor[2], 255 - pColor[3] );
}
void GAME_EXPORT VGUI_SetupDrawingText( int *pColor )
{
pglEnable( GL_BLEND );
pglEnable( GL_ALPHA_TEST );
pglAlphaFunc( GL_GREATER, 0.0f );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
pglColor4ub( pColor[0], pColor[1], pColor[2], 255 - pColor[3] );
}
void GAME_EXPORT VGUI_SetupDrawingImage( int *pColor )
{
pglEnable( GL_BLEND );
pglEnable( GL_ALPHA_TEST );
pglAlphaFunc( GL_GREATER, 0.0f );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
pglColor4ub( pColor[0], pColor[1], pColor[2], 255 - pColor[3] );
}
void GAME_EXPORT VGUI_BindTexture( int id )
{
if( id > 0 && id < VGUI_MAX_TEXTURES && g_textures[id] )
{
GL_Bind( XASH_TEXTURE0, g_textures[id] );
g_iBoundTexture = id;
}
else
{
// NOTE: same as bogus index 2700 in GoldSrc
id = g_iBoundTexture = 1;
GL_Bind( XASH_TEXTURE0, g_textures[id] );
}
}
/*
================
VGUI_GetTextureSizes
returns wide and tall for currently binded texture
================
*/
void GAME_EXPORT VGUI_GetTextureSizes( int *width, int *height )
{
gl_texture_t *glt;
int texnum;
if( g_iBoundTexture )
texnum = g_textures[g_iBoundTexture];
else texnum = tr.defaultTexture;
glt = R_GetTexture( texnum );
if( width ) *width = glt->srcWidth;
if( height ) *height = glt->srcHeight;
}
/*
================
VGUI_EnableTexture
disable texturemode for fill rectangle
================
*/
void GAME_EXPORT VGUI_EnableTexture( qboolean enable )
{
if( enable ) pglEnable( GL_TEXTURE_2D );
else pglDisable( GL_TEXTURE_2D );
}
/*
================
VGUI_DrawQuad
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;
ASSERT( ul != NULL && lr != NULL );
pglBegin( GL_QUADS );
pglTexCoord2f( ul->coord[0], ul->coord[1] );
pglVertex2f( ul->point[0] * xscale, ul->point[1] * yscale );
pglTexCoord2f( lr->coord[0], ul->coord[1] );
pglVertex2f( lr->point[0] * xscale, ul->point[1] * yscale );
pglTexCoord2f( lr->coord[0], lr->coord[1] );
pglVertex2f( lr->point[0] * xscale, lr->point[1] * yscale );
pglTexCoord2f( ul->coord[0], lr->coord[1] );
pglVertex2f( ul->point[0] * xscale, lr->point[1] * yscale );
pglEnd();
}

View File

@ -819,4 +819,4 @@ void EmitWaterPolys( msurface_t *warp, qboolean reverse )
pglEnd();
GL_SetupFogColorForSurfaces();
}
}

50
ref_gl/wscript Normal file
View File

@ -0,0 +1,50 @@
#! /usr/bin/env python
# encoding: utf-8
# mittorn, 2018
from waflib import Logs
import os
from fwgslib import get_subproject_name
top = '.'
def options(opt):
# stub
return
def configure(conf):
# check for dedicated server build
if conf.options.DEDICATED:
return
if conf.options.SUPPORT_BSP2_FORMAT:
conf.env.append_unique('DEFINES', 'SUPPORT_BSP2_FORMAT')
def build(bld):
if bld.env.DEDICATED:
return
bld.load_envs()
name = get_subproject_name(bld)
bld.env = bld.all_envs[name]
libs = []
source = bld.path.ant_glob(['*.c'])
includes = ['.',
'../engine/common',
'../engine/server',
'../engine/client',
'../common',
'../pm_shared' ]
bld.shlib(
source = source,
target = name,
features = 'c',
includes = includes,
use = libs,
install_path = bld.env.LIBDIR,
subsystem = bld.env.MSVC_SUBSYSTEM
)

View File

@ -17,7 +17,7 @@ SUBDIRS = [ 'engine', 'game_launch', 'mainui', 'vgui_support' ]
top = '.'
def options(opt):
opt.load('xcompile compiler_cxx compiler_c')
opt.load('xcompile compiler_cxx compiler_c sdl2')
if sys.platform == 'win32':
opt.load('msvc msvs')
@ -37,6 +37,10 @@ def options(opt):
'--win-style-install', action = 'store_true', dest = 'WIN_INSTALL', default = False,
help = 'install like Windows build, ignore prefix, useful for development')
opt.add_option(
'--enable-bsp2', action = 'store_true', dest = 'SUPPORT_BSP2_FORMAT', default = False,
help = 'build engine and renderers with BSP2 map support(recommended for Quake, breaks compability!)')
opt.recurse(SUBDIRS)
def configure(conf):
@ -62,7 +66,7 @@ def configure(conf):
conf.env.BIT32_MANDATORY = not conf.options.ALLOW64
conf.env.BIT32_ALLOW64 = conf.options.ALLOW64
conf.load('force_32bit')
conf.load('force_32bit sdl2')
if conf.env.DEST_SIZEOF_VOID_P == 4:
Logs.info('NOTE: will build engine for 32-bit target')