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