OpenMoHAA ..
Loading...
Searching...
No Matches
tr_public.h
1/*
2===========================================================================
3Copyright (C) 1999-2005 Id Software, Inc.
4
5This file is part of Quake III Arena source code.
6
7Quake III Arena source code is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 2 of the License,
10or (at your option) any later version.
11
12Quake III Arena source code is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with Quake III Arena source code; if not, write to the Free Software
19Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20===========================================================================
21*/
22#ifndef __TR_PUBLIC_H
23#define __TR_PUBLIC_H
24
25#include "tr_types.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31#define REF_API_VERSION 14
32
33typedef struct dtiki_s dtiki_t;
34typedef struct skelAnimFrame_s skelAnimFrame_t;
35
36
37//
38// these are the functions exported by the refresh module
39//
40typedef struct {
41 // called before the library is unloaded
42 // if the system is just reconfiguring, pass destroyWindow = qfalse,
43 // which will keep the screen from flashing to the desktop.
44 void (*Shutdown)( qboolean destroyWindow );
45
46 // All data that will be used in a level should be
47 // registered before rendering any frames to prevent disk hits,
48 // but they can still be registered at a later time
49 // if necessary.
50 //
51 // BeginRegistration makes any existing media pointers invalid
52 // and returns the current gl configuration, including screen width
53 // and height, which can be used by the client to intelligently
54 // size display elements
55 void (*BeginRegistration)( glconfig_t *config );
56 qhandle_t (*RegisterModel)( const char *name );
57 qhandle_t (*RegisterSkin)( const char *name );
58 qhandle_t (*RegisterShader)( const char *name );
59 qhandle_t (*RegisterShaderNoMip)( const char *name );
60 void (*LoadWorld)( const char *name );
61
62 // the vis data is a large enough block of data that we go to the trouble
63 // of sharing it with the clipmodel subsystem
64 void (*SetWorldVisData)( const byte *vis );
65
66 // EndRegistration will draw a tiny polygon with each texture, forcing
67 // them to be loaded into card memory
68 void (*EndRegistration)( void );
69
70 // a scene is built up by calls to R_ClearScene and the various R_Add functions.
71 // Nothing is drawn until R_RenderScene is called.
72 void (*ClearScene)( void );
73 void (*AddRefEntityToScene)( const refEntity_t *re, int parentEntityNumber );
74 qboolean(*AddPolyToScene)( qhandle_t hShader , int numVerts, const polyVert_t *verts, int num );
75 int (*LightForPoint)( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir );
76 void (*AddLightToScene)( const vec3_t org, float intensity, float r, float g, float b, int type );
77 void (*AddAdditiveLightToScene)( const vec3_t org, float intensity, float r, float g, float b );
78 void (*RenderScene)( const refdef_t *fd );
79
80 void (*SetColor)( const float *rgba ); // NULL = 1,1,1,1
81
82 // Draw images for cinematic rendering, pass as 32 bit rgba
83 void (*DrawStretchRaw) (int x, int y, int w, int h, int cols, int rows, int components, const byte* data);
84 void (*UploadCinematic) (int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty);
85
86 void (*BeginFrame)( stereoFrame_t stereoFrame );
87
88 // if the pointers are not NULL, timing info will be returned
89 void (*EndFrame)( int *frontEndMsec, int *backEndMsec );
90
91
92 int (*MarkFragments)( int numPoints, const vec3_t *points, const vec3_t projection,
93 int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer, float fRadiusSquared );
94
95 int (*LerpTag)( orientation_t *tag, qhandle_t model, int startFrame, int endFrame,
96 float frac, const char *tagName );
97 void (*ModelBounds)( qhandle_t model, vec3_t mins, vec3_t maxs );
98
99#ifdef __USEA3D
100 void (*A3D_RenderGeometry) (void *pVoidA3D, void *pVoidGeom, void *pVoidMat, void *pVoidGeomStatus);
101#endif
102 void (*RegisterFont)(const char *fontName, int pointSize, fontInfo_t *font);
103 void (*RemapShader)(const char *oldShader, const char *newShader, const char *offsetTime);
104 qboolean (*GetEntityToken)( char *buffer, int size );
105 qboolean (*inPVS)( const vec3_t p1, const vec3_t p2 );
106
107 void (*TakeVideoFrame)( int h, int w, byte* captureBuffer, byte *encodeBuffer, qboolean motionJpeg );
108
109 //
110 // non-ioq3
111 //
112 qhandle_t(*SpawnEffectModel)(const char* name, vec3_t pos, vec3_t axis[3]);
113 qhandle_t(*RegisterServerModel)(const char* name);
114 void (*UnregisterServerModel)(qhandle_t model);
115 qhandle_t(*RefreshShaderNoMip)(const char* name);
116 void (*FreeModels)();
117
118 void (*PrintBSPFileSizes)();
119 int (*MapVersion)();
120
121 void (*AddRefSpriteToScene)(const refEntity_t* ent);
122 void (*AddTerrainMarkToScene)(int terrainIndex, qhandle_t hShader, int numVerts, const polyVert_t* verts, int renderfx);
123
124 refEntity_t* (*GetRenderEntity)(int entityNumber);
125 void (*SavePerformanceCounters)();
126
127 void (*Set2DWindow)(int x, int y, int w, int h, float left, float right, float bottom, float top, float n, float f);
128 void (*DrawStretchPic) ( float x, float y, float w, float h,
129 float s1, float t1, float s2, float t2, qhandle_t hShader ); // 0 = white
130 void (*DrawStretchPic2)(float x, float y, float w, float h, float s1, float t1, float s2, float t2, float sx, float sy, qhandle_t hShader);
131 void (*DrawTilePic)(float x, float y, float w, float h, qhandle_t hShader);
132 void (*DrawTilePicOffset)(float x, float y, float w, float h, qhandle_t hShader, int offsetX, int offsetY);
133 void (*DrawTrianglePic)(const vec2_t vPoints[3], const vec2_t vTexCoords[3], qhandle_t hShader);
134 void (*DrawBackground)(int cols, int rows, int bgr, uint8_t* data);
135
136 void (*DebugLine)(const vec3_t start, const vec3_t end, float r, float g, float b, float alpha);
137 void (*DrawBox)(float x, float y, float w, float h);
138 void (*AddBox)(float x, float y, float w, float h);
139
140 void (*Scissor)(int x, int y, int width, int height);
141 void (*DrawLineLoop)(const vec2_t* points, int count, int stippleFactor, int stippleMask);
142
143 int (*MarkFragmentsForInlineModel)(clipHandle_t bmodel, const vec3_t vAngles, const vec3_t vOrigin, int numPoints,
144 const vec3_t* points, const vec3_t projection, int maxPoints, vec3_t pointBuffer,
145 int maxFragments, markFragment_t* fragmentBuffer, float fRadiusSquared);
146
147 void (*GetInlineModelBounds)(int index, vec3_t mins, vec3_t maxs);
148 void (*GetLightingForDecal)(vec3_t light, const vec3_t facing, const vec3_t origin);
149 void (*GetLightingForSmoke)(vec3_t light, const vec3_t origin);
150 int (*R_GatherLightSources)(const vec3_t pos, vec3_t* lightPos, vec3_t* lightIntensity, int maxLights);
151
152 float (*ModelRadius)(qhandle_t handle);
153
154 dtiki_t* (*R_Model_GetHandle)(qhandle_t handle);
155 void (*DrawString)(fontheader_t* font, const char* text, float x, float y, int maxLen, const float *pvVirtualScreen);
156 float (*GetFontHeight)(const fontheader_t* font);
157 float (*GetFontStringWidth)(const fontheader_t* font, const char* string);
158 fontheader_t* (*LoadFont)(const char* name);
159 void (*SwipeBegin)(float thisTime, float life, qhandle_t hShader);
160 void (*SwipePoint)(vec3_t point1, vec3_t point2, float time);
161 void (*SwipeEnd)();
162 void (*SetRenderTime)(int t);
163 float (*Noise)(float x, float y, float z, double t);
164 qboolean (*SetMode)(int mode, const glconfig_t* glConfig);
165 void (*SetFullscreen)(qboolean fullScreen);
166 int (*GetShaderWidth)(qhandle_t hShader);
167 int (*GetShaderHeight)(qhandle_t hShader);
168 const char* (*GetShaderName)(qhandle_t hShader);
169 const char* (*GetModelName)(qhandle_t hModel);
170 const char* (*GetGraphicsInfo)();
171 void (*ForceUpdatePose)(refEntity_t* model);
172 orientation_t (*TIKI_Orientation)(refEntity_t* model, int tagNum);
173 qboolean (*TIKI_IsOnGround)(refEntity_t* model, int tagNum, float threshold);
174 void (*SetFrameNumber)(int frameNumber);
175
176 qboolean (*ImageExists)(const char* name);
177 int (*CountTextureMemory)();
178
179 qboolean (*LoadRawImage)(const char *name, byte **pic, int *width, int *height);
180 void (*FreeRawImage)(byte *pic);
181
182 void (*Set2DInitialShaderTime)(float startTime);
184
185//
186// these are the functions imported by the refresh module
187//
188typedef struct {
189 // print message on the local console
190 void (QDECL *Printf)( int printLevel, const char *fmt, ...) Q_PRINTF_FUNC(2, 3);
191
192 // abort the game
193 void (QDECL *Error)( int errorLevel, const char *fmt, ...) Q_NO_RETURN Q_PRINTF_FUNC(2, 3);
194
195 // milliseconds should only be used for profiling, never
196 // for anything game related. Get time from the refdef
197 int (*Milliseconds)( void );
198
199 // stack based memory allocation for per-level things that
200 // won't be freed
201#ifdef HUNK_DEBUG
202 void *(*Hunk_AllocDebug)( int size, ha_pref pref, char *label, char *file, int line );
203#else
204 void *(*Hunk_Alloc)( int size, ha_pref pref );
205#endif
206 void *(*Hunk_AllocateTempMemory)( int size );
207 void (*Hunk_FreeTempMemory)( void *block );
208
209 // dynamic memory allocator for things that need to be freed
210 void *(*Malloc)( int bytes );
211 void (*Free)( void *buf );
212
213 cvar_t *(*Cvar_Get)( const char *name, const char *value, int flags );
214 void (*Cvar_Set)( const char *name, const char *value );
215 void (*Cvar_SetValue) (const char *name, float value);
216 void (*Cvar_CheckRange)( cvar_t *cv, float minVal, float maxVal, qboolean shouldBeIntegral );
217 void (*Cvar_SetDescription)( cvar_t *cv, const char *description );
218
219 int (*Cvar_VariableIntegerValue) (const char *var_name);
220
221 void (*Cmd_AddCommand)( const char *name, void(*cmd)(void) );
222 void (*Cmd_RemoveCommand)( const char *name );
223
224 int (*Cmd_Argc) (void);
225 char *(*Cmd_Argv) (int i);
226
227 void (*Cmd_ExecuteText) (int exec_when, const char *text);
228
229 byte *(*CM_ClusterPVS)(int cluster);
230
231 // visualization for debugging collision detection
232 void (*CM_DrawDebugSurface)( void (*drawPoly)(int color, int numPoints, float *points) );
233
234 // a -1 return means the file does not exist
235 // NULL can be passed for buf to just determine existence
236 int (*FS_FileIsInPAK)( const char *name, int *pCheckSum );
237 long (*FS_ReadFile)( const char *name, void **buf );
238 void (*FS_FreeFile)( void *buf );
239 char ** (*FS_ListFiles)( const char *name, const char *extension, int *numfilesfound );
240 void (*FS_FreeFileList)( char **filelist );
241 void (*FS_WriteFile)( const char *qpath, const void *buffer, int size );
242 qboolean (*FS_FileExists)( const char *file );
243
244 // cinematic stuff
245 void (*CIN_UploadCinematic)(int handle);
246 int (*CIN_PlayCinematic)( const char *arg0, int xpos, int ypos, int width, int height, int bits);
247 e_status (*CIN_RunCinematic) (int handle);
248
249 void (*CL_WriteAVIVideoFrame)( const byte *buffer, int size );
250
251 // input event handling
252 void (*IN_Init)( void *windowData );
253 void (*IN_Shutdown)( void );
254 void (*IN_Restart)( void );
255
256 // math
257 long (*ftol)(float f);
258
259 // system stuff
260 void (*Sys_SetEnv)( const char *name, const char *value );
261 void (*Sys_GLimpSafeInit)( void );
262 void (*Sys_GLimpInit)( void );
263 qboolean (*Sys_LowPhysicalMemory)( void );
264
265 //
266 // non-ioq3
267 //
268 const char* (*LV_ConvertString)(const char* string);
269 void (*Hunk_Clear)();
270 void (*Clear)();
271 void (*Cvar_SetDefault)(cvar_t* var, const char* varValue);
272
273 long (*FS_OpenFile)(const char* qpath, fileHandle_t *file, qboolean uniqueFILE, qboolean quiet);
274 fileHandle_t (*FS_OpenFileWrite)(const char* filename);
275 size_t (*FS_Read)(void* buffer, size_t len, fileHandle_t fileHandle);
276 size_t (*FS_Write)(const void* buffer, size_t len, fileHandle_t h);
277 void (*FS_CloseFile)(fileHandle_t fileHandle);
278 int (*FS_Seek)(fileHandle_t fileHandle, long offset, int origin);
279 long (*FS_ReadFileEx)(const char* qpath, void** buffer, qboolean quiet);
280 void (*FS_CanonicalFilename)(char* filename);
281
282 void (*CM_BoxTrace)(trace_t* results, const vec3_t start, const vec3_t end, const vec3_t mins, const vec3_t maxs, int model, int brushMask, int cylinder);
283 int (*CM_TerrainSquareType)(int terrainPatch, int i, int j);
284 char* (*CM_EntityString)();
285 const char* (*CM_MapTime)();
286 int (*CG_PermanentMark)(vec3_t origin, vec3_t dir, float orientation, float sScale, float tScale, float red, float green, float blue, float alpha, qboolean doLighting, float sCenter, float tCenter, markFragment_t* markFragments, void* polyVerts);
287 int (*CG_PermanentTreadMarkDecal)(treadMark_t* treadMark, qboolean startSegment, qboolean doLighting, markFragment_t* markFragments, void* polyVerts);
288 int (*CG_PermanentUpdateTreadMark)(treadMark_t* treadMark, float alpha, float minSegment, float maxSegment, float maxOffset, float texScale);
289 void (*CG_ProcessInitCommands)(dtiki_t* tiki, refEntity_t* ent);
290 void (*CG_EndTiki)(dtiki_t* tiki);
291 void (*SetPerformanceCounters)(int totalTris, int totalVerts, int totalTexels, int worldTris, int worldVerts, int characterLights);
292
293 debugline_t** DebugLines;
294 int* numDebugLines;
295 debugstring_t** DebugStrings;
296 int* numDebugStrings;
297
298 orientation_t (*TIKI_OrientationInternal)(dtiki_t *tiki, int entNum, int tagNum, float scale);
299 qboolean (*TIKI_IsOnGroundInternal)(dtiki_t *tiki, int entNum, int tagNum, float thresHold);
300 void (*TIKI_SetPoseInternal)(
301 void *skeletor, const frameInfo_t *frameInfo, const int *boneTag, const vec4_t *boneQuat, float actionWeight
302 );
303 void *(*TIKI_Alloc)(size_t size);
304 float (*GetRadiusInternal)(dtiki_t *tiki, int entNum, float scale);
305 float (*GetCentroidRadiusInternal)(dtiki_t *tiki, int entNum, float scale, vec3_t centroid);
306 void (*GetFrameInternal)(dtiki_t *tiki, int entNum, skelAnimFrame_t *newFrame);
307
308 void (*UI_LoadResource)(const char *name);
309
310 int (*CM_PointLeafnum)(const vec3_t p);
311 int (*CM_LeafCluster)(int leafnum);
312
313 //
314 // TIKI imports
315 //
316 void (*TIKI_CalcLodConsts)(lodControl_t *LOD);
317 void (*TIKI_CalculateBounds)(dtiki_t *pmdl, float scale, vec3_t mins, vec3_t maxs);
318 dtiki_t *(*TIKI_FindTiki)(const char *path);
319 dtiki_t *(*TIKI_RegisterTikiFlags)(const char *path, qboolean use);
320 void *(*TIKI_GetSkeletor)(dtiki_t *tiki, int entnum);
321 skelHeaderGame_t *(*TIKI_GetSkel)(int index);
322 void (*TIKI_GetSkelAnimFrame)(dtiki_t *tiki, skelBoneCache_t *bones, float *radius, vec3_t *mins, vec3_t *maxes);
323 float (*TIKI_GlobalRadius)(dtiki_t *pmdl);
324 skelcache_t *(*TIKI_FindSkelByHeader)(skelHeaderGame_t *skelmodel);
325 int (*TIKI_GetNumChannels)(dtiki_t *tiki);
326 int (*TIKI_GetLocalChannel)(dtiki_t *tiki, int channel);
327 int (*TIKI_GetLocalFromGlobal)(dtiki_t *tiki, int channel);
328
329 //
330 // Skeletor imports
331 //
332 int (*SKEL_GetMorphWeightFrame)(void *skeletor, int index, float time, int *data);
333 int (*SKEL_GetBoneParent)(void *skeletor, int boneIndex);
335
336
337// this is the only function actually exported at the linker level
338// If the module can't init to a valid rendering state, NULL will be
339// returned.
340#ifdef USE_RENDERER_DLOPEN
341typedef refexport_t* (QDECL *GetRefAPI_t) (int apiVersion, refimport_t * rimp);
342#else
343refexport_t*GetRefAPI( int apiVersion, refimport_t *rimp );
344#endif
345
346qboolean R_ImageExists(const char* name);
347
348#ifdef __cplusplus
349}
350#endif
351
352#endif // __TR_PUBLIC_H
Definition q_shared.h:2094
Definition q_shared.h:2104
Definition tiki_shared.h:176
Definition q_shared.h:2180
Definition tr_types.h:244
Definition q_shared.h:1493
Definition q_shared.h:1524
Definition tr_types.h:67
Definition tr_types.h:95
Definition tr_types.h:162
Definition tr_public.h:40
Definition tr_public.h:188
Definition skeletor.h:42
Definition tiki_shared.h:403
Definition tiki_shared.h:426
Definition q_shared.h:1452