tr_public.h 6.7 KB

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