2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
d_iface.h
|
|
|
|
|
|
|
|
Interface header file for rasterization driver modules
|
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _D_IFACE_H
|
|
|
|
#define _D_IFACE_H
|
|
|
|
|
2012-05-17 12:17:48 +00:00
|
|
|
#include "QF/iqm.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/mathlib.h"
|
2001-04-10 06:55:28 +00:00
|
|
|
#include "QF/model.h"
|
2012-02-14 10:47:02 +00:00
|
|
|
#include "QF/render.h"
|
2001-05-10 03:16:29 +00:00
|
|
|
#include "QF/vid.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
#define WARP_WIDTH 320
|
|
|
|
#define WARP_HEIGHT 200
|
|
|
|
|
2012-04-15 05:13:05 +00:00
|
|
|
#define MAX_LBM_HEIGHT 1024
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-05-17 12:17:48 +00:00
|
|
|
typedef struct {
|
|
|
|
struct tex_s **skins;
|
|
|
|
iqmblend_t *blend_palette; // includes base data from iqm
|
|
|
|
int palette_size; // includes base data from iqm
|
|
|
|
iqmvertexarray *position;
|
|
|
|
iqmvertexarray *texcoord;
|
|
|
|
iqmvertexarray *normal;
|
|
|
|
iqmvertexarray *bindices;
|
|
|
|
} swiqm_t;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
float u, v;
|
|
|
|
float s, t;
|
|
|
|
float zi;
|
|
|
|
} emitpoint_t;
|
|
|
|
|
|
|
|
#define PARTICLE_Z_CLIP 8.0
|
|
|
|
|
|
|
|
typedef struct polyvert_s {
|
|
|
|
float u, v, zi, s, t;
|
|
|
|
} polyvert_t;
|
|
|
|
|
|
|
|
typedef struct polydesc_s {
|
|
|
|
int numverts;
|
|
|
|
float nearzi;
|
|
|
|
msurface_t *pcurrentface;
|
|
|
|
polyvert_t *pverts;
|
|
|
|
} polydesc_t;
|
|
|
|
|
|
|
|
// !!! if this is changed, it must be changed in d_ifacea.h too !!!
|
|
|
|
typedef struct finalvert_s {
|
|
|
|
int v[6]; // u, v, s, t, l, 1/z
|
|
|
|
int flags;
|
|
|
|
float reserved;
|
|
|
|
} finalvert_t;
|
|
|
|
|
|
|
|
// !!! if this is changed, it must be changed in d_ifacea.h too !!!
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
void *pskin;
|
|
|
|
int skinwidth;
|
|
|
|
int skinheight;
|
|
|
|
mtriangle_t *ptriangles;
|
|
|
|
finalvert_t *pfinalverts;
|
|
|
|
int numtriangles;
|
|
|
|
int drawtype;
|
|
|
|
int seamfixupX16;
|
|
|
|
} affinetridesc_t;
|
|
|
|
|
|
|
|
// !!! if this is changed, it must be changed in d_ifacea.h too !!!
|
|
|
|
typedef struct {
|
|
|
|
float u, v, zi, color;
|
|
|
|
} screenpart_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int nump;
|
2012-05-21 23:23:22 +00:00
|
|
|
emitpoint_t *pverts; // there's room for an extra element at [nump],
|
2001-02-19 21:15:25 +00:00
|
|
|
// if the driver wants to duplicate element [0] at
|
|
|
|
// element [nump] to avoid dealing with wrapping
|
|
|
|
mspriteframe_t *pspriteframe;
|
[renderer] Clean up use of vup/vright/vpn
This moves the common camera setup code out of the individual drivers,
and completely removes vup/vright/vpn from the non-software renderers.
This has highlighted the craziness around AngleVectors with it putting
+X forward, -Y right and +Z up. The main issue with this is it requires
a 90 degree pre-rotation about the Z axis to get the camera pointing in
the right direction, and that's for the native sw renderer (vulkan needs
a 90 degree pre-rotation about X, and gl and glsl need to invert an
axis, too), though at least it's just a matrix swizzle and vector
negation. However, it does mean the camera matrices can't be used
directly.
Also rename vpn to vfwd (still abbreviated, but fwd is much clearer in
meaning (to me, at least) than pn (plane normal, I guess, but which
way?)).
2022-03-14 00:34:24 +00:00
|
|
|
vec3_t vup, vright, vfwd; // in worldspace
|
2001-02-19 21:15:25 +00:00
|
|
|
float nearzi;
|
|
|
|
} spritedesc_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int u, v;
|
|
|
|
float zi;
|
|
|
|
int color;
|
|
|
|
} zpointdesc_t;
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
extern int r_drawflat;
|
2023-06-13 09:06:11 +00:00
|
|
|
extern int r_framecount; // sequence # of current frame since Quake
|
|
|
|
// started
|
|
|
|
extern bool r_drawpolys; // 1 if driver wants clipped polygons
|
|
|
|
// rather than a span list
|
|
|
|
extern bool r_drawculledpolys; // 1 if driver wants clipped polygons that
|
|
|
|
// have been culled by the edge list
|
|
|
|
extern bool r_worldpolysbacktofront; // 1 if driver wants polygons
|
|
|
|
// delivered back to front rather
|
|
|
|
// than front to back
|
|
|
|
extern bool r_recursiveaffinetriangles; // true if a driver wants to use
|
|
|
|
// recursive triangular subdivison
|
|
|
|
// and vertex drawing via
|
|
|
|
// D_PolysetDrawFinalVerts() past
|
|
|
|
// a certain distance (normally
|
|
|
|
// used only by the software
|
|
|
|
// driver)
|
|
|
|
extern bool r_dowarp;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
extern affinetridesc_t r_affinetridesc;
|
|
|
|
extern spritedesc_t r_spritedesc;
|
|
|
|
extern zpointdesc_t r_zpointdesc;
|
|
|
|
|
|
|
|
extern int d_con_indirect; // if 0, Quake will draw console directly
|
|
|
|
// to vid.buffer; if 1, Quake will
|
|
|
|
// draw console via D_DrawRect. Must be
|
|
|
|
// defined by driver
|
|
|
|
|
2022-03-11 04:10:20 +00:00
|
|
|
extern vec3_t r_pright, r_pup, r_ppn, r_porigin;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
|
2022-03-29 04:08:58 +00:00
|
|
|
void D_Aff8Patch (const byte *pcolormap);
|
2001-02-19 21:15:25 +00:00
|
|
|
void D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height);
|
|
|
|
void D_EndDirectRect (int x, int y, int width, int height);
|
|
|
|
void D_PolysetDraw (void);
|
|
|
|
void D_PolysetDrawFinalVerts (finalvert_t *fv, int numverts);
|
2003-01-06 18:28:13 +00:00
|
|
|
void D_PolysetSetEdgeTable (void);
|
2001-02-19 21:15:25 +00:00
|
|
|
void D_DrawParticle (particle_t *pparticle);
|
|
|
|
void D_DrawPoly (void);
|
2022-03-11 04:10:20 +00:00
|
|
|
void D_DrawSprite (const vec3_t relvieworg);
|
2001-02-19 21:15:25 +00:00
|
|
|
void D_DrawSurfaces (void);
|
|
|
|
void D_DrawZPoint (void);
|
|
|
|
void D_Init (void);
|
|
|
|
void D_Init_Cvars (void);
|
|
|
|
void D_ViewChanged (void);
|
|
|
|
void D_SetupFrame (void);
|
|
|
|
void D_TurnZOn (void);
|
2022-03-25 15:29:34 +00:00
|
|
|
void D_WarpScreen (framebuffer_t *src);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
void D_FillRect (vrect_t *vrect, int color);
|
|
|
|
void D_DrawRect (void);
|
|
|
|
void D_UpdateRects (vrect_t *prect);
|
|
|
|
|
|
|
|
// currently for internal use only, and should be a do-nothing function in
|
|
|
|
// hardware drivers
|
|
|
|
// FIXME: this should go away
|
|
|
|
void D_PolysetUpdateTables (void);
|
|
|
|
|
|
|
|
// these are currently for internal use only, and should not be used by drivers
|
|
|
|
extern byte *r_skysource;
|
|
|
|
|
|
|
|
// transparency types for D_DrawRect ()
|
|
|
|
#define DR_SOLID 0
|
|
|
|
#define DR_TRANSPARENT 1
|
|
|
|
|
|
|
|
// !!! must be kept the same as in quakeasm.h !!!
|
|
|
|
#define TRANSPARENT_COLOR 0xFF
|
|
|
|
|
2022-03-29 04:08:58 +00:00
|
|
|
extern const byte *acolormap; // FIXME: should go away
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
//=======================================================================//
|
|
|
|
|
|
|
|
// callbacks to Quake
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2001-08-25 02:47:11 +00:00
|
|
|
byte *surfdat; // destination for generated surface
|
2001-02-19 21:15:25 +00:00
|
|
|
int rowbytes; // destination logical width in bytes
|
|
|
|
msurface_t *surf; // description for surface to generate
|
|
|
|
fixed8_t lightadj[MAXLIGHTMAPS];
|
|
|
|
// adjust for lightmap levels for dynamic lighting
|
2022-05-26 05:41:08 +00:00
|
|
|
struct texture_s *texture; // corrected for animating textures
|
2001-02-19 21:15:25 +00:00
|
|
|
int surfmip; // mipmapped ratio of surface texels / world pixels
|
|
|
|
int surfwidth; // in mipmapped texels
|
|
|
|
int surfheight; // in mipmapped texels
|
|
|
|
} drawsurf_t;
|
|
|
|
|
|
|
|
extern drawsurf_t r_drawsurf;
|
2022-03-11 07:39:08 +00:00
|
|
|
struct transform_s;
|
2022-10-25 10:36:09 +00:00
|
|
|
void R_DrawSurface (uint32_t render_id);
|
2001-02-19 21:15:25 +00:00
|
|
|
void R_GenTile (msurface_t *psurf, void *pdest);
|
|
|
|
|
2001-05-20 20:38:51 +00:00
|
|
|
// !!! if this is changed, it must be changed in d_iface.h too !!!
|
|
|
|
#define CACHE_SIZE 32 // used to align key data structures
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// !!! if this is changed, it must be changed in d_ifacea.h too !!!
|
|
|
|
#define TURB_TEX_SIZE 64 // base turbulent texture size
|
|
|
|
|
|
|
|
// !!! if this is changed, it must be changed in d_ifacea.h too !!!
|
|
|
|
#define CYCLE 128 // turbulent cycle size
|
|
|
|
|
|
|
|
#define TILE_SIZE 128 // size of textures generated by R_GenTiledSurf
|
|
|
|
|
|
|
|
#define SKYSHIFT 7
|
|
|
|
#define SKYSIZE (1 << SKYSHIFT)
|
|
|
|
#define SKYMASK (SKYSIZE - 1)
|
|
|
|
|
2001-10-28 04:23:37 +00:00
|
|
|
extern float d_zitable[65536];
|
|
|
|
|
2012-02-21 05:10:20 +00:00
|
|
|
extern float r_skyspeed;
|
|
|
|
extern float r_skytime;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
extern int c_surf;
|
|
|
|
|
2022-09-15 05:24:33 +00:00
|
|
|
struct draw_charbuffer_s;
|
|
|
|
void sw_Draw_CharBuffer (int x, int y, struct draw_charbuffer_s *buffer);
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
#endif // _D_IFACE_H
|