OpenMoHAA 0.82.0
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);
182
183//
184// these are the functions imported by the refresh module
185//
186typedef struct {
187 // print message on the local console
188 void (QDECL *Printf)( int printLevel, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
189
190 // abort the game
191 void (QDECL *Error)( int errorLevel, const char *fmt, ...) __attribute__ ((noreturn, format (printf, 2, 3)));
192
193 // milliseconds should only be used for profiling, never
194 // for anything game related. Get time from the refdef
195 int (*Milliseconds)( void );
196
197 // stack based memory allocation for per-level things that
198 // won't be freed
199#ifdef HUNK_DEBUG
200 void *(*Hunk_AllocDebug)( int size, ha_pref pref, char *label, char *file, int line );
201#else
202 void *(*Hunk_Alloc)( int size, ha_pref pref );
203#endif
204 void *(*Hunk_AllocateTempMemory)( int size );
205 void (*Hunk_FreeTempMemory)( void *block );
206
207 // dynamic memory allocator for things that need to be freed
208 void *(*Malloc)( int bytes );
209 void (*Free)( void *buf );
210
211 cvar_t *(*Cvar_Get)( const char *name, const char *value, int flags );
212 void (*Cvar_Set)( const char *name, const char *value );
213 void (*Cvar_SetValue) (const char *name, float value);
214 void (*Cvar_CheckRange)( cvar_t *cv, float minVal, float maxVal, qboolean shouldBeIntegral );
215 void (*Cvar_SetDescription)( cvar_t *cv, const char *description );
216
217 int (*Cvar_VariableIntegerValue) (const char *var_name);
218
219 void (*Cmd_AddCommand)( const char *name, void(*cmd)(void) );
220 void (*Cmd_RemoveCommand)( const char *name );
221
222 int (*Cmd_Argc) (void);
223 char *(*Cmd_Argv) (int i);
224
225 void (*Cmd_ExecuteText) (int exec_when, const char *text);
226
227 byte *(*CM_ClusterPVS)(int cluster);
228
229 // visualization for debugging collision detection
230 void (*CM_DrawDebugSurface)( void (*drawPoly)(int color, int numPoints, float *points) );
231
232 // a -1 return means the file does not exist
233 // NULL can be passed for buf to just determine existence
234 int (*FS_FileIsInPAK)( const char *name, int *pCheckSum );
235 long (*FS_ReadFile)( const char *name, void **buf );
236 void (*FS_FreeFile)( void *buf );
237 char ** (*FS_ListFiles)( const char *name, const char *extension, int *numfilesfound );
238 void (*FS_FreeFileList)( char **filelist );
239 void (*FS_WriteFile)( const char *qpath, const void *buffer, int size );
240 qboolean (*FS_FileExists)( const char *file );
241
242 // cinematic stuff
243 void (*CIN_UploadCinematic)(int handle);
244 int (*CIN_PlayCinematic)( const char *arg0, int xpos, int ypos, int width, int height, int bits);
245 e_status (*CIN_RunCinematic) (int handle);
246
247 void (*CL_WriteAVIVideoFrame)( const byte *buffer, int size );
248
249 // input event handling
250 void (*IN_Init)( void *windowData );
251 void (*IN_Shutdown)( void );
252 void (*IN_Restart)( void );
253
254 // math
255 long (*ftol)(float f);
256
257 // system stuff
258 void (*Sys_SetEnv)( const char *name, const char *value );
259 void (*Sys_GLimpSafeInit)( void );
260 void (*Sys_GLimpInit)( void );
261 qboolean (*Sys_LowPhysicalMemory)( void );
262
263 //
264 // non-ioq3
265 //
266 const char* (*LV_ConvertString)(const char* string);
267 void (*Hunk_Clear)();
268 void (*Clear)();
269 void (*Cvar_SetDefault)(cvar_t* var, const char* varValue);
270
271 long (*FS_OpenFile)(const char* qpath, fileHandle_t *file, qboolean uniqueFILE, qboolean quiet);
272 fileHandle_t (*FS_OpenFileWrite)(const char* filename);
273 size_t (*FS_Read)(void* buffer, size_t len, fileHandle_t fileHandle);
274 size_t (*FS_Write)(const void* buffer, size_t len, fileHandle_t h);
275 void (*FS_CloseFile)(fileHandle_t fileHandle);
276 int (*FS_Seek)(fileHandle_t fileHandle, long offset, int origin);
277 long (*FS_ReadFileEx)(const char* qpath, void** buffer, qboolean quiet);
278 void (*FS_CanonicalFilename)(char* filename);
279
280 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);
281 int (*CM_TerrainSquareType)(int terrainPatch, int i, int j);
282 char* (*CM_EntityString)();
283 const char* (*CM_MapTime)();
284 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);
285 int (*CG_PermanentTreadMarkDecal)(treadMark_t* treadMark, qboolean startSegment, qboolean doLighting, markFragment_t* markFragments, void* polyVerts);
286 int (*CG_PermanentUpdateTreadMark)(treadMark_t* treadMark, float alpha, float minSegment, float maxSegment, float maxOffset, float texScale);
287 void (*CG_ProcessInitCommands)(dtiki_t* tiki, refEntity_t* ent);
288 void (*CG_EndTiki)(dtiki_t* tiki);
289 void (*SetPerformanceCounters)(int totalTris, int totalVerts, int totalTexels, int worldTris, int worldVerts, int characterLights);
290
291 debugline_t** DebugLines;
292 int* numDebugLines;
293 debugstring_t** DebugStrings;
294 int* numDebugStrings;
295
296 orientation_t (*TIKI_OrientationInternal)(dtiki_t *tiki, int entNum, int tagNum, float scale);
297 qboolean (*TIKI_IsOnGroundInternal)(dtiki_t *tiki, int entNum, int tagNum, float thresHold);
298 void (*TIKI_SetPoseInternal)(
299 void *skeletor, const frameInfo_t *frameInfo, const int *boneTag, const vec4_t *boneQuat, float actionWeight
300 );
301 void *(*TIKI_Alloc)(size_t size);
302 float (*GetRadiusInternal)(dtiki_t *tiki, int entNum, float scale);
303 float (*GetCentroidRadiusInternal)(dtiki_t *tiki, int entNum, float scale, vec3_t centroid);
304 void (*GetFrameInternal)(dtiki_t *tiki, int entNum, skelAnimFrame_t *newFrame);
305
306 void (*UI_LoadResource)(const char *name);
307
308 int (*CM_PointLeafnum)(const vec3_t p);
309 int (*CM_LeafCluster)(int leafnum);
310
311 //
312 // TIKI imports
313 //
314 void (*TIKI_CalcLodConsts)(lodControl_t *LOD);
315 void (*TIKI_CalculateBounds)(dtiki_t *pmdl, float scale, vec3_t mins, vec3_t maxs);
316 dtiki_t *(*TIKI_FindTiki)(const char *path);
317 dtiki_t *(*TIKI_RegisterTikiFlags)(const char *path, qboolean use);
318 void *(*TIKI_GetSkeletor)(dtiki_t *tiki, int entnum);
319 skelHeaderGame_t *(*TIKI_GetSkel)(int index);
320 void (*TIKI_GetSkelAnimFrame)(dtiki_t *tiki, skelBoneCache_t *bones, float *radius, vec3_t *mins, vec3_t *maxes);
321 float (*TIKI_GlobalRadius)(dtiki_t *pmdl);
322 skelcache_t *(*TIKI_FindSkelByHeader)(skelHeaderGame_t *skelmodel);
323 int (*TIKI_GetNumChannels)(dtiki_t *tiki);
324 int (*TIKI_GetLocalChannel)(dtiki_t *tiki, int channel);
325 int (*TIKI_GetLocalFromGlobal)(dtiki_t *tiki, int channel);
326
327 //
328 // Skeletor imports
329 //
330 int (*SKEL_GetMorphWeightFrame)(void *skeletor, int index, float time, int *data);
331 int (*SKEL_GetBoneParent)(void *skeletor, int boneIndex);
333
334
335// this is the only function actually exported at the linker level
336// If the module can't init to a valid rendering state, NULL will be
337// returned.
338#ifdef USE_RENDERER_DLOPEN
339typedef refexport_t* (QDECL *GetRefAPI_t) (int apiVersion, refimport_t * rimp);
340#else
341refexport_t*GetRefAPI( int apiVersion, refimport_t *rimp );
342#endif
343
344qboolean R_ImageExists(const char* name);
345
346#ifdef __cplusplus
347}
348#endif
349
350#endif // __TR_PUBLIC_H
Definition q_shared.h:2095
Definition q_shared.h:2105
Definition tiki_shared.h:176
Definition q_shared.h:2181
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:186
Definition skeletor.h:42
Definition tiki_shared.h:403
Definition tiki_shared.h:426
Definition q_shared.h:1452