tr_public.h (6835B)
1 /* 2 =========================================================================== 3 Copyright (C) 1999-2005 Id Software, Inc. 4 5 This file is part of Quake III Arena source code. 6 7 Quake III Arena source code is free software; you can redistribute it 8 and/or modify it under the terms of the GNU General Public License as 9 published by the Free Software Foundation; either version 2 of the License, 10 or (at your option) any later version. 11 12 Quake III Arena source code is distributed in the hope that it will be 13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with Foobar; if not, write to the Free Software 19 Foundation, 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 "../cgame/tr_types.h" 26 27 #define REF_API_VERSION 8 28 29 // 30 // these are the functions exported by the refresh module 31 // 32 typedef struct { 33 // called before the library is unloaded 34 // if the system is just reconfiguring, pass destroyWindow = qfalse, 35 // which will keep the screen from flashing to the desktop. 36 void (*Shutdown)( qboolean destroyWindow ); 37 38 // All data that will be used in a level should be 39 // registered before rendering any frames to prevent disk hits, 40 // but they can still be registered at a later time 41 // if necessary. 42 // 43 // BeginRegistration makes any existing media pointers invalid 44 // and returns the current gl configuration, including screen width 45 // and height, which can be used by the client to intelligently 46 // size display elements 47 void (*BeginRegistration)( glconfig_t *config ); 48 qhandle_t (*RegisterModel)( const char *name ); 49 qhandle_t (*RegisterSkin)( const char *name ); 50 qhandle_t (*RegisterShader)( const char *name ); 51 qhandle_t (*RegisterShaderNoMip)( const char *name ); 52 void (*LoadWorld)( const char *name ); 53 54 // the vis data is a large enough block of data that we go to the trouble 55 // of sharing it with the clipmodel subsystem 56 void (*SetWorldVisData)( const byte *vis ); 57 58 // EndRegistration will draw a tiny polygon with each texture, forcing 59 // them to be loaded into card memory 60 void (*EndRegistration)( void ); 61 62 // a scene is built up by calls to R_ClearScene and the various R_Add functions. 63 // Nothing is drawn until R_RenderScene is called. 64 void (*ClearScene)( void ); 65 void (*AddRefEntityToScene)( const refEntity_t *re ); 66 void (*AddPolyToScene)( qhandle_t hShader , int numVerts, const polyVert_t *verts, int num ); 67 int (*LightForPoint)( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir ); 68 void (*AddLightToScene)( const vec3_t org, float intensity, float r, float g, float b ); 69 void (*AddAdditiveLightToScene)( const vec3_t org, float intensity, float r, float g, float b ); 70 void (*RenderScene)( const refdef_t *fd ); 71 72 void (*SetColor)( const float *rgba ); // NULL = 1,1,1,1 73 void (*DrawStretchPic) ( float x, float y, float w, float h, 74 float s1, float t1, float s2, float t2, qhandle_t hShader ); // 0 = white 75 76 // Draw images for cinematic rendering, pass as 32 bit rgba 77 void (*DrawStretchRaw) (int x, int y, int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty); 78 void (*UploadCinematic) (int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty); 79 80 void (*BeginFrame)( stereoFrame_t stereoFrame ); 81 82 // if the pointers are not NULL, timing info will be returned 83 void (*EndFrame)( int *frontEndMsec, int *backEndMsec ); 84 85 86 int (*MarkFragments)( int numPoints, const vec3_t *points, const vec3_t projection, 87 int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer ); 88 89 int (*LerpTag)( orientation_t *tag, qhandle_t model, int startFrame, int endFrame, 90 float frac, const char *tagName ); 91 void (*ModelBounds)( qhandle_t model, vec3_t mins, vec3_t maxs ); 92 93 #ifdef __USEA3D 94 void (*A3D_RenderGeometry) (void *pVoidA3D, void *pVoidGeom, void *pVoidMat, void *pVoidGeomStatus); 95 #endif 96 void (*RegisterFont)(const char *fontName, int pointSize, fontInfo_t *font); 97 void (*RemapShader)(const char *oldShader, const char *newShader, const char *offsetTime); 98 qboolean (*GetEntityToken)( char *buffer, int size ); 99 qboolean (*inPVS)( const vec3_t p1, const vec3_t p2 ); 100 } refexport_t; 101 102 // 103 // these are the functions imported by the refresh module 104 // 105 typedef struct { 106 // print message on the local console 107 void (QDECL *Printf)( int printLevel, const char *fmt, ...); 108 109 // abort the game 110 void (QDECL *Error)( int errorLevel, const char *fmt, ...); 111 112 // milliseconds should only be used for profiling, never 113 // for anything game related. Get time from the refdef 114 int (*Milliseconds)( void ); 115 116 // stack based memory allocation for per-level things that 117 // won't be freed 118 #ifdef HUNK_DEBUG 119 void *(*Hunk_AllocDebug)( int size, ha_pref pref, char *label, char *file, int line ); 120 #else 121 void *(*Hunk_Alloc)( int size, ha_pref pref ); 122 #endif 123 void *(*Hunk_AllocateTempMemory)( int size ); 124 void (*Hunk_FreeTempMemory)( void *block ); 125 126 // dynamic memory allocator for things that need to be freed 127 void *(*Malloc)( int bytes ); 128 void (*Free)( void *buf ); 129 130 cvar_t *(*Cvar_Get)( const char *name, const char *value, int flags ); 131 void (*Cvar_Set)( const char *name, const char *value ); 132 133 void (*Cmd_AddCommand)( const char *name, void(*cmd)(void) ); 134 void (*Cmd_RemoveCommand)( const char *name ); 135 136 int (*Cmd_Argc) (void); 137 char *(*Cmd_Argv) (int i); 138 139 void (*Cmd_ExecuteText) (int exec_when, const char *text); 140 141 // visualization for debugging collision detection 142 void (*CM_DrawDebugSurface)( void (*drawPoly)(int color, int numPoints, float *points) ); 143 144 // a -1 return means the file does not exist 145 // NULL can be passed for buf to just determine existance 146 int (*FS_FileIsInPAK)( const char *name, int *pCheckSum ); 147 int (*FS_ReadFile)( const char *name, void **buf ); 148 void (*FS_FreeFile)( void *buf ); 149 char ** (*FS_ListFiles)( const char *name, const char *extension, int *numfilesfound ); 150 void (*FS_FreeFileList)( char **filelist ); 151 void (*FS_WriteFile)( const char *qpath, const void *buffer, int size ); 152 qboolean (*FS_FileExists)( const char *file ); 153 154 // cinematic stuff 155 void (*CIN_UploadCinematic)(int handle); 156 int (*CIN_PlayCinematic)( const char *arg0, int xpos, int ypos, int width, int height, int bits); 157 e_status (*CIN_RunCinematic) (int handle); 158 159 } refimport_t; 160 161 162 // this is the only function actually exported at the linker level 163 // If the module can't init to a valid rendering state, NULL will be 164 // returned. 165 refexport_t*GetRefAPI( int apiVersion, refimport_t *rimp ); 166 167 #endif // __TR_PUBLIC_H