2016-12-18 04:43:04 +00:00
|
|
|
/*
|
|
|
|
===========================================================================
|
|
|
|
Copyright (C) 1999-2005 Id Software, Inc.
|
|
|
|
|
|
|
|
This file is part of Quake III Arena source code.
|
|
|
|
|
|
|
|
Quake III Arena source code is free software; you can redistribute it
|
|
|
|
and/or modify it under the terms of the GNU General Public License as
|
|
|
|
published by the Free Software Foundation; either version 2 of the License,
|
|
|
|
or (at your option) any later version.
|
|
|
|
|
|
|
|
Quake III Arena source code is distributed in the hope that it will be
|
|
|
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Quake III Arena source code; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
===========================================================================
|
|
|
|
*/
|
|
|
|
#ifndef __TR_PUBLIC_H
|
|
|
|
#define __TR_PUBLIC_H
|
|
|
|
|
|
|
|
#include "../qcommon/tr_types.h"
|
|
|
|
|
|
|
|
|
|
|
|
// print levels for severity-coloring (FIXME: move to qcommon for cgame as well?)
|
|
|
|
typedef enum {
|
|
|
|
PRINT_ALL,
|
|
|
|
PRINT_DEVELOPER, // only print when "developer 1"
|
|
|
|
PRINT_WARNING,
|
|
|
|
PRINT_ERROR
|
|
|
|
} printParm_t;
|
|
|
|
|
|
|
|
|
|
|
|
enum {
|
2019-09-25 03:25:59 +00:00
|
|
|
RF_USEC,
|
2016-12-18 04:43:04 +00:00
|
|
|
RF_LEAF_CLUSTER,
|
|
|
|
RF_LEAF_AREA,
|
|
|
|
RF_LEAFS,
|
|
|
|
|
|
|
|
RF_BEZ_CULL_S_IN,
|
|
|
|
RF_BEZ_CULL_S_CLIP,
|
|
|
|
RF_BEZ_CULL_S_OUT,
|
|
|
|
RF_BEZ_CULL_B_IN,
|
|
|
|
RF_BEZ_CULL_B_CLIP,
|
|
|
|
RF_BEZ_CULL_B_OUT,
|
|
|
|
|
|
|
|
RF_MD3_CULL_S_IN,
|
|
|
|
RF_MD3_CULL_S_CLIP,
|
|
|
|
RF_MD3_CULL_S_OUT,
|
|
|
|
RF_MD3_CULL_B_IN,
|
|
|
|
RF_MD3_CULL_B_CLIP,
|
|
|
|
RF_MD3_CULL_B_OUT,
|
|
|
|
|
|
|
|
RF_LIGHT_CULL_IN,
|
|
|
|
RF_LIGHT_CULL_OUT,
|
|
|
|
RF_LIT_LEAFS,
|
|
|
|
RF_LIT_SURFS,
|
|
|
|
RF_LIT_CULLS,
|
|
|
|
|
|
|
|
RF_STATS_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
// backend stats, especially V/I counts, can skyrocket in 2D
|
|
|
|
// which is technically correct, but not actually useful
|
|
|
|
// so we maintain two sets and switch between them as projection2D changes
|
|
|
|
|
|
|
|
enum {
|
2019-09-25 03:25:59 +00:00
|
|
|
RB_USEC,
|
|
|
|
RB_USEC_END, // post-process etc. + buffer swap
|
|
|
|
RB_USEC_GPU, // not always available
|
2016-12-18 04:43:04 +00:00
|
|
|
|
|
|
|
RB_VERTICES,
|
|
|
|
RB_INDICES,
|
|
|
|
RB_SURFACES,
|
|
|
|
RB_BATCHES,
|
2020-11-05 02:50:58 +00:00
|
|
|
RB_SHADER_CHANGES, // vertex + pixel shader combos, not Q3 shaders
|
|
|
|
RB_DRAW_CALLS, // dispatched API draw calls
|
2016-12-18 04:43:04 +00:00
|
|
|
|
|
|
|
RB_LIT_VERTICES,
|
|
|
|
RB_LIT_INDICES,
|
|
|
|
RB_LIT_SURFACES,
|
|
|
|
RB_LIT_BATCHES,
|
|
|
|
|
|
|
|
RB_LIT_VERTICES_LATECULLTEST,
|
|
|
|
RB_LIT_INDICES_LATECULL_IN,
|
|
|
|
RB_LIT_INDICES_LATECULL_OUT,
|
|
|
|
|
|
|
|
RB_STATS_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// these are the functions exported by the refresh module
|
|
|
|
//
|
|
|
|
typedef struct {
|
|
|
|
// called before the library is unloaded
|
|
|
|
// if the system is just reconfiguring, pass destroyWindow = qfalse,
|
|
|
|
// which will keep the screen from flashing to the desktop.
|
|
|
|
void (*Shutdown)( qbool destroyWindow );
|
|
|
|
|
|
|
|
// All data that will be used in a level should be
|
|
|
|
// registered before rendering any frames to prevent disk hits,
|
|
|
|
// but they can still be registered at a later time
|
|
|
|
// if necessary.
|
|
|
|
//
|
|
|
|
// BeginRegistration makes any existing media pointers invalid
|
|
|
|
// and returns the current gl configuration, including screen width
|
|
|
|
// and height, which can be used by the client to intelligently
|
|
|
|
// size display elements
|
|
|
|
void (*BeginRegistration)( glconfig_t *config );
|
|
|
|
qhandle_t (*RegisterModel)( const char *name );
|
|
|
|
qhandle_t (*RegisterSkin)( const char *name );
|
|
|
|
qhandle_t (*RegisterShader)( const char *name );
|
|
|
|
qhandle_t (*RegisterShaderNoMip)( const char *name );
|
|
|
|
void (*LoadWorld)( const char *name );
|
|
|
|
|
|
|
|
// the vis data is a large enough block of data that we go to the trouble
|
|
|
|
// of sharing it with the clipmodel subsystem
|
|
|
|
void (*SetWorldVisData)( const byte *vis );
|
|
|
|
|
|
|
|
// EndRegistration will draw a tiny polygon with each texture, forcing
|
|
|
|
// them to be loaded into card memory
|
|
|
|
void (*EndRegistration)();
|
|
|
|
|
|
|
|
// a scene is built up by calls to R_ClearScene and the various R_Add functions.
|
|
|
|
// Nothing is drawn until R_RenderScene is called.
|
|
|
|
void (*ClearScene)();
|
2017-06-22 05:15:47 +00:00
|
|
|
void (*AddRefEntityToScene)( const refEntity_t *re, qbool intShaderTime );
|
2016-12-18 04:43:04 +00:00
|
|
|
void (*AddPolyToScene)( qhandle_t hShader, int numVerts, const polyVert_t *verts, int num );
|
|
|
|
qbool (*LightForPoint)( const vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir );
|
|
|
|
void (*AddLightToScene)( const vec3_t org, float radius, float r, float g, float b );
|
|
|
|
void (*RenderScene)( const refdef_t *fd );
|
|
|
|
|
|
|
|
void (*SetColor)( const float* rgba ); // NULL = 1,1,1,1
|
|
|
|
void (*DrawStretchPic)( float x, float y, float w, float h,
|
|
|
|
float s1, float t1, float s2, float t2, qhandle_t hShader );
|
2017-12-27 04:13:33 +00:00
|
|
|
void (*DrawTriangle)( float x0, float y0, float x1, float y1, float x2, float y2,
|
|
|
|
float s0, float t0, float s1, float t1, float s2, float t2, qhandle_t hShader );
|
2016-12-18 04:43:04 +00:00
|
|
|
|
|
|
|
// Draw images for cinematic rendering, pass as 32 bit rgba
|
|
|
|
void (*DrawStretchRaw) (int x, int y, int w, int h, int cols, int rows, const byte *data, int client, qbool dirty);
|
|
|
|
|
|
|
|
void (*BeginFrame)( stereoFrame_t stereoFrame );
|
|
|
|
|
|
|
|
// if the pointers are not NULL, they will be filled with stats tables
|
2018-01-06 23:03:42 +00:00
|
|
|
void (*EndFrame)( int* pcFE, int* pc2D, int* pc3D, qbool render );
|
2016-12-18 04:43:04 +00:00
|
|
|
|
|
|
|
int (*MarkFragments)( int numPoints, const vec3_t *points, const vec3_t projection,
|
|
|
|
int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer );
|
|
|
|
|
|
|
|
int (*LerpTag)( orientation_t *tag, qhandle_t model, int startFrame, int endFrame,
|
|
|
|
float frac, const char *tagName );
|
|
|
|
void (*ModelBounds)( qhandle_t model, vec3_t mins, vec3_t maxs );
|
|
|
|
|
|
|
|
qbool (*GetEntityToken)( char* buffer, int size );
|
|
|
|
qbool (*inPVS)( const vec3_t p1, const vec3_t p2 );
|
|
|
|
|
|
|
|
void (*TakeVideoFrame)( int h, int w, byte* captureBuffer, byte *encodeBuffer, qbool motionJpeg );
|
2017-10-03 18:13:05 +00:00
|
|
|
|
|
|
|
// when the final model-view matrix is computed, for cl_drawMouseLag
|
|
|
|
int (*GetCameraMatrixTime)();
|
2018-12-08 21:43:58 +00:00
|
|
|
|
2019-09-25 03:25:59 +00:00
|
|
|
// qtrue means it should be safe to call any other function
|
|
|
|
qbool (*Registered)();
|
|
|
|
|
|
|
|
// do we need to sleep this frame to maintain the frame-rate cap?
|
|
|
|
qbool (*ShouldSleep)();
|
2016-12-18 04:43:04 +00:00
|
|
|
} refexport_t;
|
|
|
|
|
|
|
|
//
|
|
|
|
// these are the functions imported by the refresh module
|
|
|
|
//
|
|
|
|
typedef struct {
|
2017-11-05 21:40:32 +00:00
|
|
|
float (*SetConsoleVisibility)( float fraction );
|
|
|
|
|
2016-12-18 04:43:04 +00:00
|
|
|
// print message on the local console
|
|
|
|
void (QDECL *Printf)( printParm_t printLevel, const char *fmt, ... );
|
|
|
|
|
|
|
|
// abort the game
|
|
|
|
void (QDECL *Error)( int errorLevel, const char *fmt, ... );
|
|
|
|
|
|
|
|
// milliseconds should only be used for profiling, never
|
|
|
|
// for anything game related. Get time from the refdef
|
2019-09-25 03:25:59 +00:00
|
|
|
// time scaled
|
2016-12-18 04:43:04 +00:00
|
|
|
int (*Milliseconds)();
|
|
|
|
|
2019-09-25 03:25:59 +00:00
|
|
|
// for profiling only
|
|
|
|
// not time scaled
|
|
|
|
int64_t (*Microseconds)();
|
|
|
|
|
2016-12-18 04:43:04 +00:00
|
|
|
// stack based memory allocation for per-level things that
|
|
|
|
// won't be freed
|
|
|
|
#ifdef HUNK_DEBUG
|
|
|
|
void *(*Hunk_AllocDebug)( int size, ha_pref pref, char *label, char *file, int line );
|
|
|
|
#else
|
|
|
|
void *(*Hunk_Alloc)( int size, ha_pref pref );
|
|
|
|
#endif
|
|
|
|
void *(*Hunk_AllocateTempMemory)( int size );
|
|
|
|
void (*Hunk_FreeTempMemory)( void *block );
|
|
|
|
|
|
|
|
// dynamic memory allocator for things that need to be freed
|
|
|
|
void *(*Malloc)( int bytes );
|
|
|
|
void (*Free)( void *buf );
|
|
|
|
|
|
|
|
cvar_t *(*Cvar_Get)( const char *name, const char *value, int flags );
|
2017-10-03 17:11:10 +00:00
|
|
|
void (*Cvar_SetHelp)( const char *name, const char *help );
|
2016-12-18 04:43:04 +00:00
|
|
|
void (*Cvar_Set)( const char *name, const char *value );
|
|
|
|
|
2017-10-03 17:11:10 +00:00
|
|
|
void (*Cvar_RegisterTable)( const cvarTableItem_t* cvars, int count );
|
|
|
|
|
|
|
|
void (*Cmd_RegisterTable)( const cmdTableItem_t* cmds, int count );
|
2017-10-03 22:35:26 +00:00
|
|
|
void (*Cmd_UnregisterModule)();
|
2016-12-18 04:43:04 +00:00
|
|
|
|
|
|
|
int (*Cmd_Argc)();
|
|
|
|
const char* (*Cmd_Argv)(int i);
|
|
|
|
|
|
|
|
// visualization for debugging collision detection
|
|
|
|
void (*CM_DrawDebugSurface)( void (*drawPoly)(int color, int numPoints, const float* points) );
|
|
|
|
|
|
|
|
// a -1 return means the file does not exist
|
|
|
|
// NULL can be passed for buf to just determine existance
|
|
|
|
int (*FS_ReadFile)( const char *name, void **buf );
|
2022-05-28 14:50:42 +00:00
|
|
|
int (*FS_ReadFilePak)( const char *name, void **buf, int* pakChecksum );
|
2016-12-18 04:43:04 +00:00
|
|
|
void (*FS_FreeFile)( void *buf );
|
|
|
|
char** (*FS_ListFiles)( const char *name, const char *extension, int *numfilesfound );
|
|
|
|
void (*FS_FreeFileList)( char **filelist );
|
|
|
|
void (*FS_WriteFile)( const char *qpath, const void *buffer, int size );
|
2022-05-28 14:50:42 +00:00
|
|
|
qbool (*FS_GetPakPath)( char *name, int nameSize, int pakChecksum );
|
2016-12-18 04:43:04 +00:00
|
|
|
|
|
|
|
// cinematic stuff
|
2019-09-25 03:25:59 +00:00
|
|
|
qbool (*CIN_GrabCinematic)( int handle, int* w, int* h, const byte** data, int* client, qbool* dirty );
|
2016-12-18 04:43:04 +00:00
|
|
|
int (*CIN_PlayCinematic)( const char *arg0, int xpos, int ypos, int width, int height, int bits );
|
2019-09-25 03:25:59 +00:00
|
|
|
e_status (*CIN_RunCinematic)( int handle );
|
2016-12-18 04:43:04 +00:00
|
|
|
|
|
|
|
void (*CL_WriteAVIVideoFrame)( const byte *buffer, int size );
|
|
|
|
} refimport_t;
|
|
|
|
|
|
|
|
|
|
|
|
// this is the only function actually exported at the linker level
|
|
|
|
// if the module can't init to a valid rendering state, it will return NULL
|
|
|
|
const refexport_t* GetRefAPI( const refimport_t* rimp );
|
|
|
|
|
2017-05-06 20:01:14 +00:00
|
|
|
|
2016-12-18 04:43:04 +00:00
|
|
|
#endif // __TR_PUBLIC_H
|