r_local.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850
  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 <stdio.h>
  16. #include <stdlib.h>
  17. #include <string.h>
  18. #include <math.h>
  19. #include <stdarg.h>
  20. #include "../client/ref.h"
  21. #define REF_VERSION "SOFT 0.01"
  22. // up / down
  23. #define PITCH 0
  24. // left / right
  25. #define YAW 1
  26. // fall over
  27. #define ROLL 2
  28. /*
  29. skins will be outline flood filled and mip mapped
  30. pics and sprites with alpha will be outline flood filled
  31. pic won't be mip mapped
  32. model skin
  33. sprite frame
  34. wall texture
  35. pic
  36. */
  37. typedef enum
  38. {
  39. it_skin,
  40. it_sprite,
  41. it_wall,
  42. it_pic,
  43. it_sky
  44. } imagetype_t;
  45. typedef struct image_s
  46. {
  47. char name[MAX_QPATH]; // game path, including extension
  48. imagetype_t type;
  49. int width, height;
  50. qboolean transparent; // true if any 255 pixels in image
  51. int registration_sequence; // 0 = free
  52. byte *pixels[4]; // mip levels
  53. } image_t;
  54. //===================================================================
  55. typedef unsigned char pixel_t;
  56. typedef struct vrect_s
  57. {
  58. int x,y,width,height;
  59. struct vrect_s *pnext;
  60. } vrect_t;
  61. typedef struct
  62. {
  63. pixel_t *buffer; // invisible buffer
  64. pixel_t *colormap; // 256 * VID_GRADES size
  65. pixel_t *alphamap; // 256 * 256 translucency map
  66. int rowbytes; // may be > width if displayed in a window
  67. // can be negative for stupid dibs
  68. int width;
  69. int height;
  70. } viddef_t;
  71. typedef enum
  72. {
  73. rserr_ok,
  74. rserr_invalid_fullscreen,
  75. rserr_invalid_mode,
  76. rserr_unknown
  77. } rserr_t;
  78. extern viddef_t vid;
  79. // !!! if this is changed, it must be changed in asm_draw.h too !!!
  80. typedef struct
  81. {
  82. vrect_t vrect; // subwindow in video for refresh
  83. // FIXME: not need vrect next field here?
  84. vrect_t aliasvrect; // scaled Alias version
  85. int vrectright, vrectbottom; // right & bottom screen coords
  86. int aliasvrectright, aliasvrectbottom; // scaled Alias versions
  87. float vrectrightedge; // rightmost right edge we care about,
  88. // for use in edge list
  89. float fvrectx, fvrecty; // for floating-point compares
  90. float fvrectx_adj, fvrecty_adj; // left and top edges, for clamping
  91. int vrect_x_adj_shift20; // (vrect.x + 0.5 - epsilon) << 20
  92. int vrectright_adj_shift20; // (vrectright + 0.5 - epsilon) << 20
  93. float fvrectright_adj, fvrectbottom_adj;
  94. // right and bottom edges, for clamping
  95. float fvrectright; // rightmost edge, for Alias clamping
  96. float fvrectbottom; // bottommost edge, for Alias clamping
  97. float horizontalFieldOfView; // at Z = 1.0, this many X is visible
  98. // 2.0 = 90 degrees
  99. float xOrigin; // should probably always be 0.5
  100. float yOrigin; // between be around 0.3 to 0.5
  101. vec3_t vieworg;
  102. vec3_t viewangles;
  103. int ambientlight;
  104. } oldrefdef_t;
  105. extern oldrefdef_t r_refdef;
  106. #include "r_model.h"
  107. #define CACHE_SIZE 32
  108. /*
  109. ====================================================
  110. CONSTANTS
  111. ====================================================
  112. */
  113. #define VID_CBITS 6
  114. #define VID_GRADES (1 << VID_CBITS)
  115. // r_shared.h: general refresh-related stuff shared between the refresh and the
  116. // driver
  117. #define MAXVERTS 64 // max points in a surface polygon
  118. #define MAXWORKINGVERTS (MAXVERTS+4) // max points in an intermediate
  119. // polygon (while processing)
  120. // !!! if this is changed, it must be changed in d_ifacea.h too !!!
  121. #define MAXHEIGHT 1200
  122. #define MAXWIDTH 1600
  123. #define INFINITE_DISTANCE 0x10000 // distance that's always guaranteed to
  124. // be farther away than anything in
  125. // the scene
  126. // d_iface.h: interface header file for rasterization driver modules
  127. #define WARP_WIDTH 320
  128. #define WARP_HEIGHT 240
  129. #define MAX_LBM_HEIGHT 480
  130. #define PARTICLE_Z_CLIP 8.0
  131. // !!! must be kept the same as in quakeasm.h !!!
  132. #define TRANSPARENT_COLOR 0xFF
  133. // !!! if this is changed, it must be changed in d_ifacea.h too !!!
  134. #define TURB_TEX_SIZE 64 // base turbulent texture size
  135. // !!! if this is changed, it must be changed in d_ifacea.h too !!!
  136. #define CYCLE 128 // turbulent cycle size
  137. #define SCANBUFFERPAD 0x1000
  138. #define DS_SPAN_LIST_END -128
  139. #define NUMSTACKEDGES 2000
  140. #define MINEDGES NUMSTACKEDGES
  141. #define NUMSTACKSURFACES 1000
  142. #define MINSURFACES NUMSTACKSURFACES
  143. #define MAXSPANS 3000
  144. // flags in finalvert_t.flags
  145. #define ALIAS_LEFT_CLIP 0x0001
  146. #define ALIAS_TOP_CLIP 0x0002
  147. #define ALIAS_RIGHT_CLIP 0x0004
  148. #define ALIAS_BOTTOM_CLIP 0x0008
  149. #define ALIAS_Z_CLIP 0x0010
  150. #define ALIAS_XY_CLIP_MASK 0x000F
  151. #define SURFCACHE_SIZE_AT_320X240 1024*768
  152. #define BMODEL_FULLY_CLIPPED 0x10 // value returned by R_BmodelCheckBBox ()
  153. // if bbox is trivially rejected
  154. #define XCENTERING (1.0 / 2.0)
  155. #define YCENTERING (1.0 / 2.0)
  156. #define CLIP_EPSILON 0.001
  157. #define BACKFACE_EPSILON 0.01
  158. // !!! if this is changed, it must be changed in asm_draw.h too !!!
  159. #define NEAR_CLIP 0.01
  160. #define MAXALIASVERTS 2000 // TODO: tune this
  161. #define ALIAS_Z_CLIP_PLANE 4
  162. // turbulence stuff
  163. #define AMP 8*0x10000
  164. #define AMP2 3
  165. #define SPEED 20
  166. /*
  167. ====================================================
  168. TYPES
  169. ====================================================
  170. */
  171. typedef struct
  172. {
  173. float u, v;
  174. float s, t;
  175. float zi;
  176. } emitpoint_t;
  177. /*
  178. ** if you change this structure be sure to change the #defines
  179. ** listed after it!
  180. */
  181. #define SMALL_FINALVERT 0
  182. #if SMALL_FINALVERT
  183. typedef struct finalvert_s {
  184. short u, v, s, t;
  185. int l;
  186. int zi;
  187. int flags;
  188. float xyz[3]; // eye space
  189. } finalvert_t;
  190. #define FINALVERT_V0 0
  191. #define FINALVERT_V1 2
  192. #define FINALVERT_V2 4
  193. #define FINALVERT_V3 6
  194. #define FINALVERT_V4 8
  195. #define FINALVERT_V5 12
  196. #define FINALVERT_FLAGS 16
  197. #define FINALVERT_X 20
  198. #define FINALVERT_Y 24
  199. #define FINALVERT_Z 28
  200. #define FINALVERT_SIZE 32
  201. #else
  202. typedef struct finalvert_s {
  203. int u, v, s, t;
  204. int l;
  205. int zi;
  206. int flags;
  207. float xyz[3]; // eye space
  208. } finalvert_t;
  209. #define FINALVERT_V0 0
  210. #define FINALVERT_V1 4
  211. #define FINALVERT_V2 8
  212. #define FINALVERT_V3 12
  213. #define FINALVERT_V4 16
  214. #define FINALVERT_V5 20
  215. #define FINALVERT_FLAGS 24
  216. #define FINALVERT_X 28
  217. #define FINALVERT_Y 32
  218. #define FINALVERT_Z 36
  219. #define FINALVERT_SIZE 40
  220. #endif
  221. typedef struct
  222. {
  223. void *pskin;
  224. int pskindesc;
  225. int skinwidth;
  226. int skinheight;
  227. dtriangle_t *ptriangles;
  228. finalvert_t *pfinalverts;
  229. int numtriangles;
  230. int drawtype;
  231. int seamfixupX16;
  232. qboolean do_vis_thresh;
  233. int vis_thresh;
  234. } affinetridesc_t;
  235. typedef struct
  236. {
  237. byte *surfdat; // destination for generated surface
  238. int rowbytes; // destination logical width in bytes
  239. msurface_t *surf; // description for surface to generate
  240. fixed8_t lightadj[MAXLIGHTMAPS];
  241. // adjust for lightmap levels for dynamic lighting
  242. image_t *image;
  243. int surfmip; // mipmapped ratio of surface texels / world pixels
  244. int surfwidth; // in mipmapped texels
  245. int surfheight; // in mipmapped texels
  246. } drawsurf_t;
  247. typedef struct {
  248. int ambientlight;
  249. int shadelight;
  250. float *plightvec;
  251. } alight_t;
  252. // clipped bmodel edges
  253. typedef struct bedge_s
  254. {
  255. mvertex_t *v[2];
  256. struct bedge_s *pnext;
  257. } bedge_t;
  258. // !!! if this is changed, it must be changed in asm_draw.h too !!!
  259. typedef struct clipplane_s
  260. {
  261. vec3_t normal;
  262. float dist;
  263. struct clipplane_s *next;
  264. byte leftedge;
  265. byte rightedge;
  266. byte reserved[2];
  267. } clipplane_t;
  268. typedef struct surfcache_s
  269. {
  270. struct surfcache_s *next;
  271. struct surfcache_s **owner; // NULL is an empty chunk of memory
  272. int lightadj[MAXLIGHTMAPS]; // checked for strobe flush
  273. int dlight;
  274. int size; // including header
  275. unsigned width;
  276. unsigned height; // DEBUG only needed for debug
  277. float mipscale;
  278. image_t *image;
  279. byte data[4]; // width*height elements
  280. } surfcache_t;
  281. // !!! if this is changed, it must be changed in asm_draw.h too !!!
  282. typedef struct espan_s
  283. {
  284. int u, v, count;
  285. struct espan_s *pnext;
  286. } espan_t;
  287. // used by the polygon drawer (R_POLY.C) and sprite setup code (R_SPRITE.C)
  288. typedef struct
  289. {
  290. int nump;
  291. emitpoint_t *pverts;
  292. byte *pixels; // image
  293. int pixel_width; // image width
  294. int pixel_height; // image height
  295. vec3_t vup, vright, vpn; // in worldspace, for plane eq
  296. float dist;
  297. float s_offset, t_offset;
  298. float viewer_position[3];
  299. void (*drawspanlet)( void );
  300. int stipple_parity;
  301. } polydesc_t;
  302. // FIXME: compress, make a union if that will help
  303. // insubmodel is only 1, flags is fewer than 32, spanstate could be a byte
  304. typedef struct surf_s
  305. {
  306. struct surf_s *next; // active surface stack in r_edge.c
  307. struct surf_s *prev; // used in r_edge.c for active surf stack
  308. struct espan_s *spans; // pointer to linked list of spans to draw
  309. int key; // sorting key (BSP order)
  310. int last_u; // set during tracing
  311. int spanstate; // 0 = not in span
  312. // 1 = in span
  313. // -1 = in inverted span (end before
  314. // start)
  315. int flags; // currentface flags
  316. msurface_t *msurf;
  317. entity_t *entity;
  318. float nearzi; // nearest 1/z on surface, for mipmapping
  319. qboolean insubmodel;
  320. float d_ziorigin, d_zistepu, d_zistepv;
  321. int pad[2]; // to 64 bytes
  322. } surf_t;
  323. // !!! if this is changed, it must be changed in asm_draw.h too !!!
  324. typedef struct edge_s
  325. {
  326. fixed16_t u;
  327. fixed16_t u_step;
  328. struct edge_s *prev, *next;
  329. unsigned short surfs[2];
  330. struct edge_s *nextremove;
  331. float nearzi;
  332. medge_t *owner;
  333. } edge_t;
  334. /*
  335. ====================================================
  336. VARS
  337. ====================================================
  338. */
  339. extern int d_spanpixcount;
  340. extern int r_framecount; // sequence # of current frame since Quake
  341. // started
  342. extern float r_aliasuvscale; // scale-up factor for screen u and v
  343. // on Alias vertices passed to driver
  344. extern qboolean r_dowarp;
  345. extern affinetridesc_t r_affinetridesc;
  346. extern vec3_t r_pright, r_pup, r_ppn;
  347. void D_DrawSurfaces (void);
  348. void R_DrawParticle( void );
  349. void D_ViewChanged (void);
  350. void D_WarpScreen (void);
  351. void R_PolysetUpdateTables (void);
  352. extern void *acolormap; // FIXME: should go away
  353. //=======================================================================//
  354. // callbacks to Quake
  355. extern drawsurf_t r_drawsurf;
  356. void R_DrawSurface (void);
  357. extern int c_surf;
  358. extern byte r_warpbuffer[WARP_WIDTH * WARP_HEIGHT];
  359. extern float scale_for_mip;
  360. extern qboolean d_roverwrapped;
  361. extern surfcache_t *sc_rover;
  362. extern surfcache_t *d_initial_rover;
  363. extern float d_sdivzstepu, d_tdivzstepu, d_zistepu;
  364. extern float d_sdivzstepv, d_tdivzstepv, d_zistepv;
  365. extern float d_sdivzorigin, d_tdivzorigin, d_ziorigin;
  366. extern fixed16_t sadjust, tadjust;
  367. extern fixed16_t bbextents, bbextentt;
  368. void D_DrawSpans16 (espan_t *pspans);
  369. void D_DrawZSpans (espan_t *pspans);
  370. void Turbulent8 (espan_t *pspan);
  371. void NonTurbulent8 (espan_t *pspan); //PGM
  372. surfcache_t *D_CacheSurface (msurface_t *surface, int miplevel);
  373. extern int d_vrectx, d_vrecty, d_vrectright_particle, d_vrectbottom_particle;
  374. extern int d_pix_min, d_pix_max, d_pix_shift;
  375. extern pixel_t *d_viewbuffer;
  376. extern short *d_pzbuffer;
  377. extern unsigned int d_zrowbytes, d_zwidth;
  378. extern short *zspantable[MAXHEIGHT];
  379. extern int d_scantable[MAXHEIGHT];
  380. extern int d_minmip;
  381. extern float d_scalemip[3];
  382. //===================================================================
  383. extern int cachewidth;
  384. extern pixel_t *cacheblock;
  385. extern int r_screenwidth;
  386. extern int r_drawnpolycount;
  387. extern int sintable[1280];
  388. extern int intsintable[1280];
  389. extern int blanktable[1280]; // PGM
  390. extern vec3_t vup, base_vup;
  391. extern vec3_t vpn, base_vpn;
  392. extern vec3_t vright, base_vright;
  393. extern surf_t *surfaces, *surface_p, *surf_max;
  394. // surfaces are generated in back to front order by the bsp, so if a surf
  395. // pointer is greater than another one, it should be drawn in front
  396. // surfaces[1] is the background, and is used as the active surface stack.
  397. // surfaces[0] is a dummy, because index 0 is used to indicate no surface
  398. // attached to an edge_t
  399. //===================================================================
  400. extern vec3_t sxformaxis[4]; // s axis transformed into viewspace
  401. extern vec3_t txformaxis[4]; // t axis transformed into viewspac
  402. extern float xcenter, ycenter;
  403. extern float xscale, yscale;
  404. extern float xscaleinv, yscaleinv;
  405. extern float xscaleshrink, yscaleshrink;
  406. extern void TransformVector (vec3_t in, vec3_t out);
  407. extern void SetUpForLineScan(fixed8_t startvertu, fixed8_t startvertv,
  408. fixed8_t endvertu, fixed8_t endvertv);
  409. extern int ubasestep, errorterm, erroradjustup, erroradjustdown;
  410. //===========================================================================
  411. extern cvar_t *sw_aliasstats;
  412. extern cvar_t *sw_clearcolor;
  413. extern cvar_t *sw_drawflat;
  414. extern cvar_t *sw_draworder;
  415. extern cvar_t *sw_maxedges;
  416. extern cvar_t *sw_maxsurfs;
  417. extern cvar_t *sw_mipcap;
  418. extern cvar_t *sw_mipscale;
  419. extern cvar_t *sw_mode;
  420. extern cvar_t *sw_reportsurfout;
  421. extern cvar_t *sw_reportedgeout;
  422. extern cvar_t *sw_stipplealpha;
  423. extern cvar_t *sw_surfcacheoverride;
  424. extern cvar_t *sw_waterwarp;
  425. extern cvar_t *r_fullbright;
  426. extern cvar_t *r_lefthand;
  427. extern cvar_t *r_drawentities;
  428. extern cvar_t *r_drawworld;
  429. extern cvar_t *r_dspeeds;
  430. extern cvar_t *r_lerpmodels;
  431. extern cvar_t *r_speeds;
  432. extern cvar_t *r_lightlevel; //FIXME HACK
  433. extern cvar_t *vid_fullscreen;
  434. extern cvar_t *vid_gamma;
  435. extern clipplane_t view_clipplanes[4];
  436. extern int *pfrustum_indexes[4];
  437. //=============================================================================
  438. void R_RenderWorld (void);
  439. //=============================================================================
  440. extern mplane_t screenedge[4];
  441. extern vec3_t r_origin;
  442. extern entity_t r_worldentity;
  443. extern model_t *currentmodel;
  444. extern entity_t *currententity;
  445. extern vec3_t modelorg;
  446. extern vec3_t r_entorigin;
  447. extern float verticalFieldOfView;
  448. extern float xOrigin, yOrigin;
  449. extern int r_visframecount;
  450. extern msurface_t *r_alpha_surfaces;
  451. //=============================================================================
  452. void R_ClearPolyList (void);
  453. void R_DrawPolyList (void);
  454. //
  455. // current entity info
  456. //
  457. extern qboolean insubmodel;
  458. void R_DrawAlphaSurfaces( void );
  459. void R_DrawSprite (void);
  460. void R_DrawBeam( entity_t *e );
  461. void R_RenderFace (msurface_t *fa, int clipflags);
  462. void R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf);
  463. void R_TransformPlane (mplane_t *p, float *normal, float *dist);
  464. void R_TransformFrustum (void);
  465. void R_DrawSurfaceBlock16 (void);
  466. void R_DrawSurfaceBlock8 (void);
  467. #if id386
  468. void R_DrawSurfaceBlock8_mip0 (void);
  469. void R_DrawSurfaceBlock8_mip1 (void);
  470. void R_DrawSurfaceBlock8_mip2 (void);
  471. void R_DrawSurfaceBlock8_mip3 (void);
  472. #endif
  473. void R_GenSkyTile (void *pdest);
  474. void R_GenSkyTile16 (void *pdest);
  475. void R_Surf8Patch (void);
  476. void R_Surf16Patch (void);
  477. void R_DrawSubmodelPolygons (model_t *pmodel, int clipflags, mnode_t *topnode);
  478. void R_DrawSolidClippedSubmodelPolygons (model_t *pmodel, mnode_t *topnode);
  479. void R_AddPolygonEdges (emitpoint_t *pverts, int numverts, int miplevel);
  480. surf_t *R_GetSurf (void);
  481. void R_AliasDrawModel (void);
  482. void R_BeginEdgeFrame (void);
  483. void R_ScanEdges (void);
  484. void D_DrawSurfaces (void);
  485. void R_InsertNewEdges (edge_t *edgestoadd, edge_t *edgelist);
  486. void R_StepActiveU (edge_t *pedge);
  487. void R_RemoveEdges (edge_t *pedge);
  488. void R_PushDlights (model_t *model);
  489. extern void R_Surf8Start (void);
  490. extern void R_Surf8End (void);
  491. extern void R_Surf16Start (void);
  492. extern void R_Surf16End (void);
  493. extern void R_EdgeCodeStart (void);
  494. extern void R_EdgeCodeEnd (void);
  495. extern void R_RotateBmodel (void);
  496. extern int c_faceclip;
  497. extern int r_polycount;
  498. extern int r_wholepolycount;
  499. extern int ubasestep, errorterm, erroradjustup, erroradjustdown;
  500. extern fixed16_t sadjust, tadjust;
  501. extern fixed16_t bbextents, bbextentt;
  502. extern mvertex_t *r_ptverts, *r_ptvertsmax;
  503. extern float entity_rotation[3][3];
  504. extern int r_currentkey;
  505. extern int r_currentbkey;
  506. void R_InitTurb (void);
  507. void R_DrawParticles (void);
  508. void R_SurfacePatch (void);
  509. extern int r_amodels_drawn;
  510. extern edge_t *auxedges;
  511. extern int r_numallocatededges;
  512. extern edge_t *r_edges, *edge_p, *edge_max;
  513. extern edge_t *newedges[MAXHEIGHT];
  514. extern edge_t *removeedges[MAXHEIGHT];
  515. // FIXME: make stack vars when debugging done
  516. extern edge_t edge_head;
  517. extern edge_t edge_tail;
  518. extern edge_t edge_aftertail;
  519. extern int r_aliasblendcolor;
  520. extern float aliasxscale, aliasyscale, aliasxcenter, aliasycenter;
  521. extern int r_outofsurfaces;
  522. extern int r_outofedges;
  523. extern mvertex_t *r_pcurrentvertbase;
  524. extern int r_maxvalidedgeoffset;
  525. typedef struct
  526. {
  527. finalvert_t *a, *b, *c;
  528. } aliastriangleparms_t;
  529. extern aliastriangleparms_t aliastriangleparms;
  530. void R_DrawTriangle( void );
  531. //void R_DrawTriangle (finalvert_t *index0, finalvert_t *index1, finalvert_t *index2);
  532. void R_AliasClipTriangle (finalvert_t *index0, finalvert_t *index1, finalvert_t *index2);
  533. extern float r_time1;
  534. extern float da_time1, da_time2;
  535. extern float dp_time1, dp_time2, db_time1, db_time2, rw_time1, rw_time2;
  536. extern float se_time1, se_time2, de_time1, de_time2, dv_time1, dv_time2;
  537. extern int r_frustum_indexes[4*6];
  538. extern int r_maxsurfsseen, r_maxedgesseen, r_cnumsurfs;
  539. extern qboolean r_surfsonstack;
  540. extern mleaf_t *r_viewleaf;
  541. extern int r_viewcluster, r_oldviewcluster;
  542. extern int r_clipflags;
  543. extern int r_dlightframecount;
  544. extern qboolean r_fov_greater_than_90;
  545. extern image_t *r_notexture_mip;
  546. extern model_t *r_worldmodel;
  547. void R_PrintAliasStats (void);
  548. void R_PrintTimes (void);
  549. void R_PrintDSpeeds (void);
  550. void R_AnimateLight (void);
  551. void R_LightPoint (vec3_t p, vec3_t color);
  552. void R_SetupFrame (void);
  553. void R_cshift_f (void);
  554. void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1);
  555. void R_ClipEdge (mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip);
  556. void R_SplitEntityOnNode2 (mnode_t *node);
  557. extern refdef_t r_newrefdef;
  558. extern surfcache_t *sc_rover, *sc_base;
  559. extern void *colormap;
  560. //====================================================================
  561. float R_DLightPoint (vec3_t p);
  562. void R_NewMap (void);
  563. void R_Register (void);
  564. void R_UnRegister (void);
  565. void Draw_InitLocal (void);
  566. qboolean R_Init( void *hInstance, void *wndProc );
  567. void R_Shutdown (void);
  568. void R_InitCaches (void);
  569. void D_FlushCaches (void);
  570. void R_ScreenShot_f( void );
  571. void R_BeginRegistration (char *map);
  572. struct model_s *R_RegisterModel (char *name);
  573. void R_EndRegistration (void);
  574. void R_RenderFrame (refdef_t *fd);
  575. struct image_s *Draw_FindPic (char *name);
  576. void Draw_GetPicSize (int *w, int *h, char *name);
  577. void Draw_Pic (int x, int y, char *name);
  578. void Draw_StretchPic (int x, int y, int w, int h, char *name);
  579. void Draw_StretchRaw (int x, int y, int w, int h, int cols, int rows, byte *data);
  580. void Draw_Char (int x, int y, int c);
  581. void Draw_TileClear (int x, int y, int w, int h, char *name);
  582. void Draw_Fill (int x, int y, int w, int h, int c);
  583. void Draw_FadeScreen (void);
  584. void Draw_GetPalette (void);
  585. void R_BeginFrame( float camera_separation );
  586. void R_CinematicSetPalette( const unsigned char *palette );
  587. extern unsigned d_8to24table[256]; // base
  588. void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length);
  589. void Sys_SetFPCW (void);
  590. void LoadPCX (char *filename, byte **pic, byte **palette, int *width, int *height);
  591. void R_InitImages (void);
  592. void R_ShutdownImages (void);
  593. image_t *R_FindImage (char *name, imagetype_t type);
  594. void R_FreeUnusedImages (void);
  595. void R_GammaCorrectAndSetPalette( const unsigned char *pal );
  596. extern mtexinfo_t *sky_texinfo[6];
  597. void R_InitSkyBox (void);
  598. typedef struct swstate_s
  599. {
  600. qboolean fullscreen;
  601. int prev_mode; // last valid SW mode
  602. byte gammatable[256];
  603. byte currentpalette[1024];
  604. } swstate_t;
  605. void R_IMFlatShadedQuad( vec3_t a, vec3_t b, vec3_t c, vec3_t d, int color, float alpha );
  606. extern swstate_t sw_state;
  607. /*
  608. ====================================================================
  609. IMPORTED FUNCTIONS
  610. ====================================================================
  611. */
  612. extern refimport_t ri;
  613. /*
  614. ====================================================================
  615. IMPLEMENTATION FUNCTIONS
  616. ====================================================================
  617. */
  618. void SWimp_BeginFrame( float camera_separation );
  619. void SWimp_EndFrame (void);
  620. int SWimp_Init( void *hInstance, void *wndProc );
  621. void SWimp_SetPalette( const unsigned char *palette);
  622. void SWimp_Shutdown( void );
  623. rserr_t SWimp_SetMode( int *pwidth, int *pheight, int mode, qboolean fullscreen );
  624. void SWimp_AppActivate( qboolean active );