1 /*
2 ===========================================================================
3 Copyright (C) 1999 - 2005, Id Software, Inc.
4 Copyright (C) 2000 - 2013, Raven Software, Inc.
5 Copyright (C) 2001 - 2013, Activision, Inc.
6 Copyright (C) 2005 - 2015, ioquake3 contributors
7 Copyright (C) 2013 - 2015, OpenJK contributors
8 
9 This file is part of the OpenJK source code.
10 
11 OpenJK is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License version 2 as
13 published by the Free Software Foundation.
14 
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 GNU General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, see <http://www.gnu.org/licenses/>.
22 ===========================================================================
23 */
24 
25 #ifndef TR_PUBLIC_H
26 #define TR_PUBLIC_H
27 
28 #include "../rd-common/tr_types.h"
29 #include "../qcommon/MiniHeap.h"
30 #include "../qcommon/qcommon.h"
31 #include "../ghoul2/ghoul2_shared.h"
32 
33 #define	REF_API_VERSION 9
34 
35 //
36 // these are the functions exported by the refresh module
37 //
38 
39 typedef struct refexport_s {
40 	// called before the library is unloaded
41 	// if the system is just reconfiguring, pass destroyWindow = qfalse,
42 	// which will keep the screen from flashing to the desktop.
43 	void				(*Shutdown)								( qboolean destroyWindow, qboolean restarting );
44 
45 	// All data that will be used in a level should be
46 	// registered before rendering any frames to prevent disk hits,
47 	// but they can still be registered at a later time
48 	// if necessary.
49 	//
50 	// BeginRegistration makes any existing media pointers invalid
51 	// and returns the current gl configuration, including screen width
52 	// and height, which can be used by the client to intelligently
53 	// size display elements
54 	void				(*BeginRegistration)					( glconfig_t *config );
55 	qhandle_t			(*RegisterModel)						( const char *name );
56 	qhandle_t			(*RegisterServerModel)					( const char *name );
57 	qhandle_t			(*RegisterSkin)							( const char *name );
58 	qhandle_t			(*RegisterServerSkin)					( const char *name );
59 	qhandle_t			(*RegisterShader)						( const char *name );
60 	qhandle_t			(*RegisterShaderNoMip)					( const char *name );
61 	const char *		(*ShaderNameFromIndex)					( int index );
62 	void				(*LoadWorld)							( const char *name );
63 
64 	// the vis data is a large enough block of data that we go to the trouble
65 	// of sharing it with the clipmodel subsystem
66 	void				(*SetWorldVisData)						( const byte *vis );
67 
68 	// EndRegistration will draw a tiny polygon with each texture, forcing
69 	// them to be loaded into card memory
70 	void				(*EndRegistration)						( void );
71 
72 	// a scene is built up by calls to R_ClearScene and the various R_Add functions.
73 	// Nothing is drawn until R_RenderScene is called.
74 	void				(*ClearScene)							( void );
75 	void				(*ClearDecals)							( void );
76 	void				(*AddRefEntityToScene)					( const refEntity_t *re );
77 	void				(*AddMiniRefEntityToScene)				( const miniRefEntity_t *re );
78 	void				(*AddPolyToScene)						( qhandle_t hShader , int numVerts, const polyVert_t *verts, int num );
79 	void				(*AddDecalToScene)						( qhandle_t shader, const vec3_t origin, const vec3_t dir, float orientation, float r, float g, float b, float a, qboolean alphaFade, float radius, qboolean temporary );
80 	int					(*LightForPoint)						( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir );
81 	void				(*AddLightToScene)						( const vec3_t org, float intensity, float r, float g, float b );
82 	void				(*AddAdditiveLightToScene)				( const vec3_t org, float intensity, float r, float g, float b );
83 
84 	void				(*RenderScene)							( const refdef_t *fd );
85 
86 	void				(*SetColor)								( const float *rgba );	// NULL = 1,1,1,1
87 	void				(*DrawStretchPic)						( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader );	// 0 = white
88 	void				(*DrawRotatePic)						( float x, float y, float w, float h, float s1, float t1, float s2, float t2, float a1, qhandle_t hShader );	// 0 = white
89 	void				(*DrawRotatePic2)						( float x, float y, float w, float h, float s1, float t1, float s2, float t2, float a1, qhandle_t hShader );	// 0 = white
90 
91 	// Draw images for cinematic rendering, pass as 32 bit rgba
92 	void				(*DrawStretchRaw)						( int x, int y, int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty );
93 	void				(*UploadCinematic)						( int cols, int rows, const byte *data, int client, qboolean dirty );
94 
95 	void				(*BeginFrame)							( stereoFrame_t stereoFrame );
96 
97 	// if the pointers are not NULL, timing info will be returned
98 	void				(*EndFrame)								( int *frontEndMsec, int *backEndMsec );
99 
100 
101 	int					(*MarkFragments)						( int numPoints, const vec3_t *points, const vec3_t projection, int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer );
102 
103 	int					(*LerpTag)								( orientation_t *tag,  qhandle_t model, int startFrame, int endFrame, float frac, const char *tagName );
104 	void				(*ModelBounds)							( qhandle_t model, vec3_t mins, vec3_t maxs );
105 	void				(*ModelBoundsRef)						( refEntity_t *model, vec3_t mins, vec3_t maxs );
106 
107 	qhandle_t			(*RegisterFont)							( const char *fontName );
108 	int					(*Font_StrLenPixels)					( const char *text, const int iFontIndex, const float scale );
109 	int					(*Font_StrLenChars)						( const char *text );
110 	int					(*Font_HeightPixels)					( const int iFontIndex, const float scale );
111 	void				(*Font_DrawString)						( int ox, int oy, const char *text, const float *rgba, const int setIndex, int iCharLimit, const float scale );
112 	qboolean			(*Language_IsAsian)						( void );
113 	qboolean			(*Language_UsesSpaces)					( void );
114 	unsigned int		(*AnyLanguage_ReadCharFromString)		( const char *psText, int *piAdvanceCount, qboolean *pbIsTrailingPunctuation/* = NULL*/ );
115 
116 	void				(*RemapShader)							( const char *oldShader, const char *newShader, const char *offsetTime );
117 	qboolean			(*GetEntityToken)						( char *buffer, int size );
118 	qboolean			(*inPVS)								( const vec3_t p1, const vec3_t p2, byte *mask );
119 
120 	void				(*GetLightStyle)						( int style, color4ub_t color );
121 	void				(*SetLightStyle)						( int style, int color );
122 
123 	void				(*GetBModelVerts)						( int bmodelIndex, vec3_t *vec, vec3_t normal );
124 
125 	// These were missing in 1.01, had direct access to renderer backend
126 	void				(*SetRangedFog)							( float range );
127 	void				(*SetRefractionProperties)				( float distortionAlpha, float distortionStretch, qboolean distortionPrePost, qboolean distortionNegate );
128 	float				(*GetDistanceCull)						( void );
129 	void				(*GetRealRes)							( int *w, int *h );
130 	void				(*AutomapElevationAdjustment)			( float newHeight );
131 	qboolean			(*InitializeWireframeAutomap)			( void );
132 	void				(*AddWeatherZone)						( vec3_t mins, vec3_t maxs );
133 	void				(*WorldEffectCommand)					( const char *command );
134 	void				(*RegisterMedia_LevelLoadBegin)			( const char *psMapName, ForceReload_e eForceReload );
135 	void				(*RegisterMedia_LevelLoadEnd)			( void );
136 	int					(*RegisterMedia_GetLevel)				( void );
137 	qboolean			(*RegisterImages_LevelLoadEnd)			( void );
138 	qboolean			(*RegisterModels_LevelLoadEnd)			( qboolean bDeleteEverythingNotUsedThisLevel );
139 
140 	// AVI recording
141 	void				(*TakeVideoFrame)						( int h, int w, byte* captureBuffer, byte *encodeBuffer, qboolean motionJpeg );
142 
143 	// G2 stuff
144 	void				(*InitSkins)							( void );
145 	void				(*InitShaders)							( qboolean server );
146 	void				(*SVModelInit)							( void );
147 	void				(*HunkClearCrap)						( void );
148 
149 	// G2API
150 	int					(*G2API_AddBolt)						( CGhoul2Info_v &ghoul2, const int modelIndex, const char *boneName );
151 	int					(*G2API_AddBoltSurfNum)					( CGhoul2Info *ghlInfo, const int surfIndex );
152 	int					(*G2API_AddSurface)						( CGhoul2Info *ghlInfo, int surfaceNumber, int polyNumber, float BarycentricI, float BarycentricJ, int lod );
153 	void				(*G2API_AnimateG2ModelsRag)				( CGhoul2Info_v &ghoul2, int AcurrentTime, CRagDollUpdateParams *params );
154 	qboolean			(*G2API_AttachEnt)						( int *boltInfo, CGhoul2Info_v& ghoul2, int modelIndex, int toBoltIndex, int entNum, int toModelNum );
155 	qboolean			(*G2API_AttachG2Model)					( CGhoul2Info_v &ghoul2From, int modelFrom, CGhoul2Info_v &ghoul2To, int toBoltIndex, int toModel );
156 	void				(*G2API_AttachInstanceToEntNum)			( CGhoul2Info_v &ghoul2, int entityNum, qboolean server );
157 	void				(*G2API_AbsurdSmoothing)				( CGhoul2Info_v &ghoul2, qboolean status );
158 	void				(*G2API_BoltMatrixReconstruction)		( qboolean reconstruct );
159 	void				(*G2API_BoltMatrixSPMethod)				( qboolean spMethod );
160 	void				(*G2API_CleanEntAttachments)			( void );
161 	void				(*G2API_CleanGhoul2Models)				( CGhoul2Info_v **ghoul2Ptr );
162 	void				(*G2API_ClearAttachedInstance)			( int entityNum );
163 	void				(*G2API_CollisionDetect)				( CollisionRecord_t *collRecMap, CGhoul2Info_v &ghoul2, const vec3_t angles, const vec3_t position, int frameNumber, int entNum, vec3_t rayStart, vec3_t rayEnd, vec3_t scale, IHeapAllocator *G2VertSpace, int traceFlags, int useLod, float fRadius );
164 	void				(*G2API_CollisionDetectCache)			( CollisionRecord_t *collRecMap, CGhoul2Info_v &ghoul2, const vec3_t angles, const vec3_t position, int frameNumber, int entNum, vec3_t rayStart, vec3_t rayEnd, vec3_t scale, IHeapAllocator *G2VertSpace, int traceFlags, int useLod, float fRadius );
165 	int					(*G2API_CopyGhoul2Instance)				( CGhoul2Info_v &g2From, CGhoul2Info_v &g2To, int modelIndex );
166 	void				(*G2API_CopySpecificG2Model)			( CGhoul2Info_v &ghoul2From, int modelFrom, CGhoul2Info_v &ghoul2To, int modelTo );
167 	qboolean			(*G2API_DetachG2Model)					( CGhoul2Info *ghlInfo );
168 	qboolean			(*G2API_DoesBoneExist)					( CGhoul2Info_v& ghoul2, int modelIndex, const char *boneName );
169 	void				(*G2API_DuplicateGhoul2Instance)		( CGhoul2Info_v &g2From, CGhoul2Info_v **g2To );
170 	void				(*G2API_FreeSaveBuffer)					( char *buffer );
171 	qboolean			(*G2API_GetAnimFileName)				( CGhoul2Info *ghlInfo, char **filename );
172 	char *				(*G2API_GetAnimFileNameIndex)			( qhandle_t modelIndex );
173 	qboolean			(*G2API_GetAnimRange)					( CGhoul2Info *ghlInfo, const char *boneName, int *startFrame, int *endFrame );
174 	qboolean			(*G2API_GetBoltMatrix)					( CGhoul2Info_v &ghoul2, const int modelIndex, const int boltIndex, mdxaBone_t *matrix, const vec3_t angles, const vec3_t position, const int frameNum, qhandle_t *modelList, vec3_t scale );
175 	qboolean			(*G2API_GetBoneAnim)					( CGhoul2Info_v& ghoul2, int modelIndex, const char *boneName, const int currentTime, float *currentFrame, int *startFrame, int *endFrame, int *flags, float *animSpeed, qhandle_t *modelList );
176 	int					(*G2API_GetBoneIndex)					( CGhoul2Info *ghlInfo, const char *boneName );
177 	int					(*G2API_GetGhoul2ModelFlags)			( CGhoul2Info *ghlInfo );
178 	char *				(*G2API_GetGLAName)						( CGhoul2Info_v &ghoul2, int modelIndex );
179 	const char *		(*G2API_GetModelName)					( CGhoul2Info_v& ghoul2, int modelIndex );
180 	int					(*G2API_GetParentSurface)				( CGhoul2Info *ghlInfo, const int index );
181 	qboolean			(*G2API_GetRagBonePos)					( CGhoul2Info_v &ghoul2, const char *boneName, vec3_t pos, vec3_t entAngles, vec3_t entPos, vec3_t entScale );
182 	int					(*G2API_GetSurfaceIndex)				( CGhoul2Info *ghlInfo, const char *surfaceName );
183 	char *				(*G2API_GetSurfaceName)					( CGhoul2Info_v& ghlInfo, int modelIndex, int surfNumber );
184 	int					(*G2API_GetSurfaceOnOff)				( CGhoul2Info *ghlInfo, const char *surfaceName );
185 	int					(*G2API_GetSurfaceRenderStatus)			( CGhoul2Info_v& ghoul2, int modelIndex, const char *surfaceName );
186 	int					(*G2API_GetTime)						( int argTime );
187 	int					(*G2API_Ghoul2Size)						( CGhoul2Info_v &ghoul2 );
188 	void				(*G2API_GiveMeVectorFromMatrix)			( mdxaBone_t *boltMatrix, Eorientations flags, vec3_t vec );
189 	qboolean			(*G2API_HasGhoul2ModelOnIndex)			( CGhoul2Info_v **ghlRemove, const int modelIndex );
190 	qboolean			(*G2API_HaveWeGhoul2Models)				( CGhoul2Info_v &ghoul2 );
191 	qboolean			(*G2API_IKMove)							( CGhoul2Info_v &ghoul2, int time, sharedIKMoveParams_t *params );
192 	int					(*G2API_InitGhoul2Model)				( CGhoul2Info_v **ghoul2Ptr, const char *fileName, int modelIndex, qhandle_t customSkin, qhandle_t customShader, int modelFlags, int lodBias );
193 	qboolean			(*G2API_IsGhoul2InfovValid)				( CGhoul2Info_v& ghoul2 );
194 	qboolean			(*G2API_IsPaused)						( CGhoul2Info *ghlInfo, const char *boneName );
195 	void				(*G2API_ListBones)						( CGhoul2Info *ghlInfo, int frame );
196 	void				(*G2API_ListSurfaces)					( CGhoul2Info *ghlInfo );
197 	void				(*G2API_LoadGhoul2Models)				( CGhoul2Info_v &ghoul2, char *buffer );
198 	void				(*G2API_LoadSaveCodeDestructGhoul2Info)	( CGhoul2Info_v &ghoul2 );
199 	qboolean			(*G2API_OverrideServerWithClientData)	( CGhoul2Info_v& serverInstance, int modelIndex );
200 	qboolean			(*G2API_PauseBoneAnim)					( CGhoul2Info *ghlInfo, const char *boneName, const int currentTime );
201 	qhandle_t			(*G2API_PrecacheGhoul2Model)			( const char *fileName );
202 	qboolean			(*G2API_RagEffectorGoal)				( CGhoul2Info_v &ghoul2, const char *boneName, vec3_t pos );
203 	qboolean			(*G2API_RagEffectorKick)				( CGhoul2Info_v &ghoul2, const char *boneName, vec3_t velocity );
204 	qboolean			(*G2API_RagForceSolve)					( CGhoul2Info_v &ghoul2, qboolean force );
205 	qboolean			(*G2API_RagPCJConstraint)				( CGhoul2Info_v &ghoul2, const char *boneName, vec3_t min, vec3_t max );
206 	qboolean			(*G2API_RagPCJGradientSpeed)			( CGhoul2Info_v &ghoul2, const char *boneName, const float speed );
207 	qboolean			(*G2API_RemoveBolt)						( CGhoul2Info *ghlInfo, const int index );
208 	qboolean			(*G2API_RemoveBone)						( CGhoul2Info_v& ghoul2, int modelIndex, const char *boneName );
209 	qboolean			(*G2API_RemoveGhoul2Model)				( CGhoul2Info_v **ghlRemove, const int modelIndex );
210 	qboolean			(*G2API_RemoveGhoul2Models)				( CGhoul2Info_v **ghlRemove );
211 	qboolean			(*G2API_RemoveSurface)					( CGhoul2Info *ghlInfo, const int index );
212 	void				(*G2API_ResetRagDoll)					( CGhoul2Info_v &ghoul2 );
213 	qboolean			(*G2API_SaveGhoul2Models)				( CGhoul2Info_v &ghoul2, char **buffer, int *size );
214 	void				(*G2API_SetBoltInfo)					( CGhoul2Info_v &ghoul2, int modelIndex, int boltInfo );
215 	qboolean			(*G2API_SetBoneAngles)					( CGhoul2Info_v &ghoul2, const int modelIndex, const char *boneName, const vec3_t angles, const int flags, const Eorientations up, const Eorientations left, const Eorientations forward, qhandle_t *modelList, int blendTime, int currentTime  );
216 	qboolean			(*G2API_SetBoneAnglesIndex)				( CGhoul2Info *ghlInfo, const int index, const vec3_t angles, const int flags, const Eorientations yaw, const Eorientations pitch, const Eorientations roll, qhandle_t *modelList, int blendTime, int currentTime );
217 	qboolean			(*G2API_SetBoneAnglesMatrix)			( CGhoul2Info *ghlInfo, const char *boneName, const mdxaBone_t &matrix, const int flags, qhandle_t *modelList, int blendTime, int currentTime );
218 	qboolean			(*G2API_SetBoneAnglesMatrixIndex)		( CGhoul2Info *ghlInfo, const int index, const mdxaBone_t &matrix, const int flags, qhandle_t *modelList, int blendTime, int currentTime );
219 	qboolean			(*G2API_SetBoneAnim)					( CGhoul2Info_v &ghoul2, const int modelIndex, const char *boneName, const int startFrame, const int endFrame, const int flags, const float animSpeed, const int currentTime, const float setFrame /*= -1*/, const int blendTime /*= -1*/ );
220 	qboolean			(*G2API_SetBoneAnimIndex)				( CGhoul2Info *ghlInfo, const int index, const int startFrame, const int endFrame, const int flags, const float animSpeed, const int currentTime, const float setFrame, const int blendTime );
221 	qboolean			(*G2API_SetBoneIKState)					( CGhoul2Info_v &ghoul2, int time, const char *boneName, int ikState, sharedSetBoneIKStateParams_t *params );
222 	qboolean			(*G2API_SetGhoul2ModelFlags)			( CGhoul2Info *ghlInfo, const int flags );
223 	void				(*G2API_SetGhoul2ModelIndexes)			( CGhoul2Info_v &ghoul2, qhandle_t *modelList, qhandle_t *skinList );
224 	qboolean			(*G2API_SetLodBias)						( CGhoul2Info *ghlInfo, int lodBias );
225 	qboolean			(*G2API_SetNewOrigin)					( CGhoul2Info_v &ghoul2, const int boltIndex );
226 	void				(*G2API_SetRagDoll)						( CGhoul2Info_v &ghoul2, CRagDollParams *parms );
227 	qboolean			(*G2API_SetRootSurface)					( CGhoul2Info_v &ghoul2, const int modelIndex, const char *surfaceName );
228 	qboolean			(*G2API_SetShader)						( CGhoul2Info *ghlInfo, qhandle_t customShader );
229 	qboolean			(*G2API_SetSkin)						( CGhoul2Info_v& ghoul2, int modelIndex, qhandle_t customSkin, qhandle_t renderSkin );
230 	qboolean			(*G2API_SetSurfaceOnOff)				( CGhoul2Info_v &ghoul2, const char *surfaceName, const int flags );
231 	void				(*G2API_SetTime)						( int currentTime, int clock );
232 	qboolean			(*G2API_SkinlessModel)					( CGhoul2Info_v& ghoul2, int modelIndex );
233 	qboolean			(*G2API_StopBoneAngles)					( CGhoul2Info *ghlInfo, const char *boneName );
234 	qboolean			(*G2API_StopBoneAnglesIndex)			( CGhoul2Info *ghlInfo, const int index );
235 	qboolean			(*G2API_StopBoneAnim)					( CGhoul2Info *ghlInfo, const char *boneName );
236 	qboolean			(*G2API_StopBoneAnimIndex)				( CGhoul2Info *ghlInfo, const int index );
237 
238 	#ifdef _G2_GORE
239 	int					(*G2API_GetNumGoreMarks)				( CGhoul2Info_v& ghoul2, int modelIndex );
240 	void				(*G2API_AddSkinGore)					( CGhoul2Info_v &ghoul2, SSkinGoreData &gore );
241 	void				(*G2API_ClearSkinGore)					( CGhoul2Info_v &ghoul2 );
242 	#endif // _G2_GORE
243 
244 	struct {
245 		float				(*Font_StrLenPixels)					( const char *text, const int iFontIndex, const float scale );
246 	} ext;
247 
248 } refexport_t;
249 
250 //
251 // these are the functions imported by the refresh module
252 //
253 typedef struct refimport_s {
254 	void			(QDECL *Printf)						( int printLevel, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
255 	void			(QDECL *Error)						( int errorLevel, const char *fmt, ...) NORETURN_PTR __attribute__ ((format (printf, 2, 3)));
256 	void			(QDECL *OPrintf)					( const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
257 
258 	// milliseconds should only be used for profiling, never for anything game related. Get time from the refdef
259 	int				(*Milliseconds)						( void );
260 
261 	// memory management (can use tr_subs)
262 	void *			(*Hunk_AllocateTempMemory)			( int size );
263 	void			(*Hunk_FreeTempMemory)				( void *buf );
264 	void *			(*Hunk_Alloc)						( int size, ha_pref preference );
265 	int				(*Hunk_MemoryRemaining)				( void );
266 	void *			(*Z_Malloc)							( int iSize, memtag_t eTag, qboolean bZeroit /*= qfalse*/, int iAlign /*= 4*/); // return memory NOT zero-filled by default
267 	void			(*Z_Free)							( void *ptr );
268 	int				(*Z_MemSize)						( memtag_t eTag );
269 	void			(*Z_MorphMallocTag)					( void *pvBuffer, memtag_t eDesiredTag );
270 
271 	void			(*Cmd_ExecuteString)				( const char *text );
272 	int				(*Cmd_Argc)							( void );
273 	char *			(*Cmd_Argv)							( int arg );
274 	void			(*Cmd_ArgsBuffer)					( char *buffer, int bufferLength );
275 	void			(*Cmd_AddCommand)					( const char *cmd_name, xcommand_t function, const char *cmd_desc );
276 	void			(*Cmd_AddCommandList)				( const cmdList_t *cmdList );
277 	void			(*Cmd_RemoveCommand)				( const char *cmd_name );
278 	void			(*Cmd_RemoveCommandList)			( const cmdList_t *cmdList );
279 	cvar_t *		(*Cvar_Set)							( const char *var_name, const char *value );
280 	cvar_t *		(*Cvar_Get)							( const char *var_name, const char *value, uint32_t flags, const char *var_desc );
281 	cvar_t *		(*Cvar_SetValue)					( const char *name, float value );
282 	void			(*Cvar_CheckRange)					( cvar_t *cv, float minVal, float maxVal, qboolean shouldBeIntegral );
283 	void			(*Cvar_VariableStringBuffer)		( const char *var_name, char *buffer, int bufsize );
284 	char *			(*Cvar_VariableString)				( const char *var_name );
285 	float			(*Cvar_VariableValue)				( const char *var_name );
286 	int				(*Cvar_VariableIntegerValue)		( const char *var_name );
287 	qboolean		(*Sys_LowPhysicalMemory)			( void );
288 	const char *	(*SE_GetString)						( const char * psPackageAndStringReference );
289 	void			(*FS_FreeFile)						( void *buffer );
290 	void			(*FS_FreeFileList)					( char **fileList );
291 	int				(*FS_Read)							( void *buffer, int len, fileHandle_t f );
292 	long			(*FS_ReadFile)						( const char *qpath, void **buffer );
293 	void			(*FS_FCloseFile)					( fileHandle_t f );
294 	long			(*FS_FOpenFileRead)					( const char *qpath, fileHandle_t *file, qboolean uniqueFILE );
295 	fileHandle_t	(*FS_FOpenFileWrite)				( const char *qpath, qboolean safe );
296 	int				(*FS_FOpenFileByMode)				( const char *qpath, fileHandle_t *f, fsMode_t mode );
297 	qboolean		(*FS_FileExists)					( const char *file );
298 	int				(*FS_FileIsInPAK)					( const char *filename, int *pChecksum );
299 	char **			(*FS_ListFiles)						( const char *directory, const char *extension, int *numfiles );
300 	int				(*FS_Write)							( const void *buffer, int len, fileHandle_t f );
301 	void			(*FS_WriteFile)						( const char *qpath, const void *buffer, int size );
302 	void			(*CM_BoxTrace)						( trace_t *results, const vec3_t start, const vec3_t end, const vec3_t mins, const vec3_t maxs, clipHandle_t model, int brushmask, int capsule );
303 	void			(*CM_DrawDebugSurface)				( void (*drawPoly)(int color, int numPoints, float *points) );
304 	bool			(*CM_CullWorldBox)					( const cplane_t *frustum, const vec3pair_t bounds );
305 	byte *			(*CM_ClusterPVS)					( int cluster );
306 	int				(*CM_LeafArea)						( int leafnum );
307 	int				(*CM_LeafCluster)					( int leafnum );
308 	int				(*CM_PointLeafnum)					( const vec3_t p );
309 	int				(*CM_PointContents)					( const vec3_t p, clipHandle_t model );
310 	qboolean		(*Com_TheHunkMarkHasBeenMade)		( void );
311 	void			(*S_RestartMusic)					( void );
312 	qboolean		(*SND_RegisterAudio_LevelLoadEnd)	( qboolean bDeleteEverythingNotUsedThisLevel );
313 	e_status		(*CIN_RunCinematic)					( int handle );
314 	int				(*CIN_PlayCinematic)				( const char *arg0, int xpos, int ypos, int width, int height, int bits );
315 	void			(*CIN_UploadCinematic)				( int handle );
316 	void			(*CL_WriteAVIVideoFrame)			( const byte *imageBuffer, int size );
317 
318 	// g2 data access
319 	char *			(*GetSharedMemory)					( void ); // cl.mSharedMemory
320 
321 	// (c)g vm callbacks
322 	vm_t *			(*GetCurrentVM)						( void );
323 	qboolean		(*CGVMLoaded)						( void );
324 	int				(*CGVM_RagCallback)					( int callType );
325 
326 	// window handling
327 	window_t		(*WIN_Init)                         ( const windowDesc_t *desc, glconfig_t *glConfig );
328 	void			(*WIN_SetGamma)						( glconfig_t *glConfig, byte red[256], byte green[256], byte blue[256] );
329 	void			(*WIN_Present)						( window_t *window );
330 	void            (*WIN_Shutdown)                     ( void );
331 
332 	// OpenGL-specific
333 	void *			(*GL_GetProcAddress)				( const char *name );
334 	qboolean		(*GL_ExtensionSupported)			( const char *extension );
335 
336 	// gpvCachedMapDiskImage
337 	void *			(*CM_GetCachedMapDiskImage)			( void );
338 	void			(*CM_SetCachedMapDiskImage)			( void *ptr );
339 	// gbUsingCachedMapDataRightNow
340 	void			(*CM_SetUsingCache)					( qboolean usingCache );
341 
342 	// even the server will have this, which is a singleton
343 	// so before assigning to this in R_Init, check if it's NULL!
344 	IHeapAllocator *(*GetG2VertSpaceServer)				( void );
345 
346 	// Persistent data store
347 	bool			(*PD_Store)							( const char *name, const void *data, size_t size );
348 	const void *	(*PD_Load)							( const char *name, size_t *size );
349 } refimport_t;
350 
351 // this is the only function actually exported at the linker level
352 // If the module can't init to a valid rendering state, NULL will be
353 // returned.
354 #ifdef DEDICATED // dedicated server will statically compile rd-dedicated
355 	refexport_t *GetRefAPI( int apiVersion, refimport_t *rimp );
356 #else
357 	typedef	refexport_t* (QDECL *GetRefAPI_t) (int apiVersion, refimport_t *rimp);
358 #endif
359 
360 #endif
361 
362