ref.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /*
  2. Copyright (C) 1997-2001 Id Software, Inc.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. #include "../qcommon/qcommon.h"
  16. #define MAX_DLIGHTS 32
  17. #define MAX_ENTITIES 128
  18. #define MAX_PARTICLES 4096
  19. #define MAX_LIGHTSTYLES 256
  20. #define POWERSUIT_SCALE 4.0F
  21. #define SHELL_RED_COLOR 0xF2
  22. #define SHELL_GREEN_COLOR 0xD0
  23. #define SHELL_BLUE_COLOR 0xF3
  24. #define SHELL_RG_COLOR 0xDC
  25. //#define SHELL_RB_COLOR 0x86
  26. #define SHELL_RB_COLOR 0x68
  27. #define SHELL_BG_COLOR 0x78
  28. //ROGUE
  29. #define SHELL_DOUBLE_COLOR 0xDF // 223
  30. #define SHELL_HALF_DAM_COLOR 0x90
  31. #define SHELL_CYAN_COLOR 0x72
  32. //ROGUE
  33. #define SHELL_WHITE_COLOR 0xD7
  34. typedef struct entity_s
  35. {
  36. struct model_s *model; // opaque type outside refresh
  37. float angles[3];
  38. /*
  39. ** most recent data
  40. */
  41. float origin[3]; // also used as RF_BEAM's "from"
  42. int frame; // also used as RF_BEAM's diameter
  43. /*
  44. ** previous data for lerping
  45. */
  46. float oldorigin[3]; // also used as RF_BEAM's "to"
  47. int oldframe;
  48. /*
  49. ** misc
  50. */
  51. float backlerp; // 0.0 = current, 1.0 = old
  52. int skinnum; // also used as RF_BEAM's palette index
  53. int lightstyle; // for flashing entities
  54. float alpha; // ignore if RF_TRANSLUCENT isn't set
  55. struct image_s *skin; // NULL for inline skin
  56. int flags;
  57. } entity_t;
  58. #define ENTITY_FLAGS 68
  59. typedef struct
  60. {
  61. vec3_t origin;
  62. vec3_t color;
  63. float intensity;
  64. } dlight_t;
  65. typedef struct
  66. {
  67. vec3_t origin;
  68. int color;
  69. float alpha;
  70. } particle_t;
  71. typedef struct
  72. {
  73. float rgb[3]; // 0.0 - 2.0
  74. float white; // highest of rgb
  75. } lightstyle_t;
  76. typedef struct
  77. {
  78. int x, y, width, height;// in virtual screen coordinates
  79. float fov_x, fov_y;
  80. float vieworg[3];
  81. float viewangles[3];
  82. float blend[4]; // rgba 0-1 full screen blend
  83. float time; // time is uesed to auto animate
  84. int rdflags; // RDF_UNDERWATER, etc
  85. byte *areabits; // if not NULL, only areas with set bits will be drawn
  86. lightstyle_t *lightstyles; // [MAX_LIGHTSTYLES]
  87. int num_entities;
  88. entity_t *entities;
  89. int num_dlights;
  90. dlight_t *dlights;
  91. int num_particles;
  92. particle_t *particles;
  93. } refdef_t;
  94. #define API_VERSION 3
  95. //
  96. // these are the functions exported by the refresh module
  97. //
  98. typedef struct
  99. {
  100. // if api_version is different, the dll cannot be used
  101. int api_version;
  102. // called when the library is loaded
  103. qboolean (*Init) ( void *hinstance, void *wndproc );
  104. // called before the library is unloaded
  105. void (*Shutdown) (void);
  106. // All data that will be used in a level should be
  107. // registered before rendering any frames to prevent disk hits,
  108. // but they can still be registered at a later time
  109. // if necessary.
  110. //
  111. // EndRegistration will free any remaining data that wasn't registered.
  112. // Any model_s or skin_s pointers from before the BeginRegistration
  113. // are no longer valid after EndRegistration.
  114. //
  115. // Skins and images need to be differentiated, because skins
  116. // are flood filled to eliminate mip map edge errors, and pics have
  117. // an implicit "pics/" prepended to the name. (a pic name that starts with a
  118. // slash will not use the "pics/" prefix or the ".pcx" postfix)
  119. void (*BeginRegistration) (char *map);
  120. struct model_s *(*RegisterModel) (char *name);
  121. struct image_s *(*RegisterSkin) (char *name);
  122. struct image_s *(*RegisterPic) (char *name);
  123. void (*SetSky) (char *name, float rotate, vec3_t axis);
  124. void (*EndRegistration) (void);
  125. void (*RenderFrame) (refdef_t *fd);
  126. void (*DrawGetPicSize) (int *w, int *h, char *name); // will return 0 0 if not found
  127. void (*DrawPic) (int x, int y, char *name);
  128. void (*DrawStretchPic) (int x, int y, int w, int h, char *name);
  129. void (*DrawChar) (int x, int y, int c);
  130. void (*DrawTileClear) (int x, int y, int w, int h, char *name);
  131. void (*DrawFill) (int x, int y, int w, int h, int c);
  132. void (*DrawFadeScreen) (void);
  133. // Draw images for cinematic rendering (which can have a different palette). Note that calls
  134. void (*DrawStretchRaw) (int x, int y, int w, int h, int cols, int rows, byte *data);
  135. /*
  136. ** video mode and refresh state management entry points
  137. */
  138. void (*CinematicSetPalette)( const unsigned char *palette); // NULL = game palette
  139. void (*BeginFrame)( float camera_separation );
  140. void (*EndFrame) (void);
  141. void (*AppActivate)( qboolean activate );
  142. } refexport_t;
  143. //
  144. // these are the functions imported by the refresh module
  145. //
  146. typedef struct
  147. {
  148. void (*Sys_Error) (int err_level, char *str, ...);
  149. void (*Cmd_AddCommand) (char *name, void(*cmd)(void));
  150. void (*Cmd_RemoveCommand) (char *name);
  151. int (*Cmd_Argc) (void);
  152. char *(*Cmd_Argv) (int i);
  153. void (*Cmd_ExecuteText) (int exec_when, char *text);
  154. void (*Con_Printf) (int print_level, char *str, ...);
  155. // files will be memory mapped read only
  156. // the returned buffer may be part of a larger pak file,
  157. // or a discrete file from anywhere in the quake search path
  158. // a -1 return means the file does not exist
  159. // NULL can be passed for buf to just determine existance
  160. int (*FS_LoadFile) (char *name, void **buf);
  161. void (*FS_FreeFile) (void *buf);
  162. // gamedir will be the current directory that generated
  163. // files should be stored to, ie: "f:\quake\id1"
  164. char *(*FS_Gamedir) (void);
  165. cvar_t *(*Cvar_Get) (char *name, char *value, int flags);
  166. cvar_t *(*Cvar_Set)( char *name, char *value );
  167. void (*Cvar_SetValue)( char *name, float value );
  168. qboolean (*Vid_GetModeInfo)( int *width, int *height, int mode );
  169. void (*Vid_MenuInit)( void );
  170. void (*Vid_NewWindow)( int width, int height );
  171. } refimport_t;
  172. // this is the only function actually exported at the linker level
  173. typedef refexport_t (*GetRefAPI_t) (refimport_t);