while (1) diff--;

This commit is contained in:
Bill Currie 2001-08-29 01:28:03 +00:00
parent aa3442f8b0
commit b0c7ac9867
10 changed files with 171 additions and 114 deletions

View file

@ -40,8 +40,7 @@ static int miplevel;
float scale_for_mip;
extern int screenwidth;
int ubasestep, errorterm, erroradjustup, erroradjustdown;
int vstartscan;
int ubasestep, errorterm, erroradjustup, erroradjustdown, vstartscan;
vec3_t transformed_modelorg;
@ -73,8 +72,8 @@ D_MipLevelForScale (float scale)
return lmiplevel;
}
// FIXME: clean this up
void
D_DrawSolidSurface (surf_t *surf, int color)
{
@ -111,10 +110,8 @@ void
D_CalcGradients (msurface_t *pface)
{
mplane_t *pplane;
float mipscale;
vec3_t p_temp1;
vec3_t p_saxis, p_taxis;
float t;
float mipscale, t;
vec3_t p_temp1, p_saxis, p_taxis;
pplane = pface->plane;
@ -141,10 +138,10 @@ D_CalcGradients (msurface_t *pface)
t = 0x10000 * mipscale;
sadjust = ((fixed16_t) (DotProduct (p_temp1, p_saxis) * 0x10000 + 0.5)) -
((pface->texturemins[0] << 16) >> miplevel)
+ pface->texinfo->vecs[0][3] * t;
+ pface->texinfo->vecs[0][3] * t;
tadjust = ((fixed16_t) (DotProduct (p_temp1, p_taxis) * 0x10000 + 0.5)) -
((pface->texturemins[1] << 16) >> miplevel)
+ pface->texinfo->vecs[1][3] * t;
+ pface->texinfo->vecs[1][3] * t;
// -1 (-epsilon) so we never wander off the edge of the texture
bbextents = ((pface->extents[0] << 16) >> miplevel) - 1;
@ -175,7 +172,7 @@ D_DrawSurfaces (void)
d_zistepv = s->d_zistepv;
d_ziorigin = s->d_ziorigin;
D_DrawSolidSurface (s, (int) ((long) s->data & 0xFF));
D_DrawSolidSurface (s, ((int) s->data & 0xFF));
D_DrawZSpans (s->spans);
}
} else {
@ -198,8 +195,7 @@ D_DrawSurfaces (void)
D_DrawZSpans (s->spans);
} else if (s->flags & SURF_DRAWBACKGROUND) {
// set up a gradient for the background surface that places
// it
// effectively at infinity distance from the viewpoint
// it effectively at infinity distance from the viewpoint
d_zistepu = 0;
d_zistepv = 0;
d_ziorigin = -0.9;

View file

@ -32,7 +32,6 @@
#include "QF/cvar.h"
#include "QF/render.h"
#include "QF/vid.h"
#include "compat.h"
#include "d_local.h"
@ -108,7 +107,7 @@ D_SetupFrame (void)
if (r_dowarp)
d_viewbuffer = r_warpbuffer;
else
d_viewbuffer = (void *) (byte *) vid.buffer;
d_viewbuffer = vid.buffer;
if (r_dowarp)
screenwidth = WARP_WIDTH;

View file

@ -66,12 +66,12 @@ D_Patch (void)
void
D_ViewChanged (void)
{
int rowbytes;
int rowpixels;
if (r_dowarp)
rowbytes = WARP_WIDTH;
rowpixels = WARP_WIDTH;
else
rowbytes = vid.rowbytes;
rowpixels = vid.rowbytes / r_pixbytes;
scale_for_mip = xscale;
if (yscale > xscale)
@ -104,7 +104,7 @@ D_ViewChanged (void)
int i;
for (i = 0; i < vid.height; i++) {
d_scantable[i] = i * rowbytes;
d_scantable[i] = i * rowpixels;
zspantable[i] = d_pzbuffer + i * d_zwidth;
}
}

View file

@ -37,14 +37,14 @@
void
D_EndParticles (void)
{
// not used by software driver
// not used by software driver
}
void
D_StartParticles (void)
{
// not used by software driver
// not used by software driver
}

View file

@ -38,8 +38,7 @@
// TODO: put in span spilling to shrink list size
// !!! if this is changed, it must be changed in d_polysa.s too !!!
#define DPS_MAXSPANS MAXHEIGHT+1
// 1 extra for spanpackage that marks end
#define DPS_MAXSPANS MAXHEIGHT+1 // +1 for spanpackage marking end
// !!! if this is changed, it must be changed in asm_draw.h too !!!
typedef struct {
@ -87,8 +86,8 @@ edgetable edgetables[12] = {
};
// FIXME: some of these can become statics
int a_sstepxfrac, a_tstepxfrac, r_lstepx, a_ststepxwhole;
int r_sstepx, r_tstepx, r_lstepy, r_sstepy, r_tstepy;
int a_sstepxfrac, a_tstepxfrac, a_ststepxwhole;
int r_sstepx, r_tstepx, r_lstepx, r_lstepy, r_sstepy, r_tstepy;
int r_zistepx, r_zistepy;
int d_aspancount, d_countextrastep;
@ -247,13 +246,12 @@ D_DrawNonSubdiv (void)
index1 = pfv + ptri->vertindex[1];
index2 = pfv + ptri->vertindex[2];
d_xdenom = (index0->v[1] - index1->v[1]) *
(index0->v[0] - index2->v[0]) -
d_xdenom =
(index0->v[1] - index1->v[1]) * (index0->v[0] - index2->v[0]) -
(index0->v[0] - index1->v[0]) * (index0->v[1] - index2->v[1]);
if (d_xdenom >= 0) {
if (d_xdenom >= 0)
continue;
}
r_p0[0] = index0->v[0]; // u
r_p0[1] = index0->v[1]; // v
@ -454,7 +452,7 @@ D_PolysetSetUpForLineScan (fixed8_t startvertu, fixed8_t startvertv,
int tm, tn;
adivtab_t *ptemp;
// TODO: implement x86 version
// TODO: implement x86 version
errorterm = -1;
@ -493,9 +491,9 @@ D_PolysetCalcGradients (int skinwidth)
ystepdenominv = -xstepdenominv;
// ceil () for light so positive steps are exaggerated, negative steps
// diminished, pushing us away from underflow toward overflow. Underflow is
// very visible, overflow is very unlikely, because of ambient lighting
// ceil () for light so positive steps are exaggerated, negative steps
// diminished, pushing us away from underflow toward overflow. Underflow
// is very visible, overflow is very unlikely, because of ambient lighting
t0 = r_p0[4] - r_p2[4];
t1 = r_p1[4] - r_p2[4];
r_lstepx = (int)
@ -851,8 +849,8 @@ D_PolysetSetEdgeTable (void)
{
int edgetableindex;
edgetableindex = 0; // assume the vertices are already in
// top to bottom order
// assume the vertices are already in top to bottom order
edgetableindex = 0;
// determine which edges are right & left, and the order in which
// to rasterize them

View file

@ -31,19 +31,19 @@
#endif
#include "QF/cvar.h"
#include "QF/render.h"
#include "QF/render.h"
#include "QF/sys.h"
#include "d_local.h"
#include "r_local.h"
static int miplevel;
static int miplevel;
float scale_for_mip;
extern int screenwidth;
int ubasestep, errorterm, erroradjustup, erroradjustdown, vstartscan;
float scale_for_mip;
extern int screenwidth;
int ubasestep, errorterm, erroradjustup, erroradjustdown, vstartscan;
vec3_t transformed_modelorg;
vec3_t transformed_modelorg;
void
@ -52,6 +52,7 @@ D_DrawPoly (void)
// this driver takes spans, not polygons
}
int
D_MipLevelForScale (float scale)
{
@ -134,6 +135,7 @@ D_DrawSolidSurface (surf_t *surf, int color)
}
}
void
D_CalcGradients (msurface_t *pface)
{
@ -165,24 +167,26 @@ D_CalcGradients (msurface_t *pface)
t = 0x10000 * mipscale;
sadjust = ((fixed16_t) (DotProduct (p_temp1, p_saxis) * 0x10000 + 0.5)) -
((pface->texturemins[0] << 16) >> miplevel) +
pface->texinfo->vecs[0][3] * t;
((pface->texturemins[0] << 16) >> miplevel)
+ pface->texinfo->vecs[0][3] * t;
tadjust = ((fixed16_t) (DotProduct (p_temp1, p_taxis) * 0x10000 + 0.5)) -
((pface->texturemins[1] << 16) >> miplevel) +
pface->texinfo->vecs[1][3] * t;
((pface->texturemins[1] << 16) >> miplevel)
+ pface->texinfo->vecs[1][3] * t;
// -1 (-epsilon) so we never wander off the edge of the texture
bbextents = ((pface->extents[0] << 16) >> miplevel) - 1;
bbextentt = ((pface->extents[1] << 16) >> miplevel) - 1;
}
void
D_DrawSurfaces (void)
{
surf_t *s;
msurface_t *pface;
surfcache_t *pcurrentcache;
vec3_t local_modelorg, world_transformed_modelorg;
vec3_t world_transformed_modelorg;
vec3_t local_modelorg;
currententity = &r_worldentity;
TransformVector (modelorg, transformed_modelorg);
@ -198,7 +202,7 @@ D_DrawSurfaces (void)
d_zistepv = s->d_zistepv;
d_ziorigin = s->d_ziorigin;
D_DrawSolidSurface (s, ((int)&s->data) & 0xFF);
D_DrawSolidSurface (s, ((int) s->data & 0xFF));
D_DrawZSpans (s->spans);
}
} else {
@ -213,8 +217,9 @@ D_DrawSurfaces (void)
d_ziorigin = s->d_ziorigin;
if (s->flags & SURF_DRAWSKY) {
if (!r_skymade)
if (!r_skymade) {
R_MakeSky ();
}
D_DrawSkyScans (s->spans);
D_DrawZSpans (s->spans);
@ -230,8 +235,8 @@ D_DrawSurfaces (void)
} else if (s->flags & SURF_DRAWTURB) {
pface = s->data;
miplevel = 0;
cacheblock = (void *)((byte *) pface->texinfo->texture +
pface->texinfo->texture->offsets[0]);
cacheblock = ((byte *) pface->texinfo->texture +
pface->texinfo->texture->offsets[0]);
cachewidth = 64;
if (s->insubmodel) {
@ -256,6 +261,7 @@ D_DrawSurfaces (void)
// restore the old drawing state
// FIXME: we don't want to do this every time!
// TODO: speed up
currententity = &r_worldentity;
VectorCopy (world_transformed_modelorg,
transformed_modelorg);
@ -270,8 +276,7 @@ D_DrawSurfaces (void)
// FIXME: we don't want to do all this for every polygon!
// TODO: store once at start of frame
currententity = s->entity; // FIXME: make this passed in
// to
// R_RotateBmodel ()
// to R_RotateBmodel ()
VectorSubtract (r_origin, currententity->origin,
local_modelorg);
TransformVector (local_modelorg, transformed_modelorg);
@ -287,7 +292,7 @@ D_DrawSurfaces (void)
// FIXME: make this passed in to D_CacheSurface
pcurrentcache = D_CacheSurface (pface, miplevel);
cacheblock = (void *) pcurrentcache->data;
cacheblock = (byte *) pcurrentcache->data;
cachewidth = pcurrentcache->width;
D_CalcGradients (pface);
@ -300,6 +305,7 @@ D_DrawSurfaces (void)
// restore the old drawing state
// FIXME: we don't want to do this every time!
// TODO: speed up
VectorCopy (world_transformed_modelorg,
transformed_modelorg);
VectorCopy (base_vpn, vpn);

View file

@ -30,29 +30,25 @@
# include "config.h"
#endif
#include "QF/cvar.h"
#include "QF/render.h"
// #include "QF/vid.h"
#include "QF/cvar.h"
#include "QF/render.h"
#include "compat.h"
#include "d_local.h"
// #include "r_cvar.h"
#include "compat.h"
#include "d_local.h"
#include "r_cvar.h"
#define NUM_MIPS 4
cvar_t *d_mipcap;
cvar_t *d_mipscale;
surfcache_t *d_initial_rover;
qboolean d_roverwrapped;
int d_minmip;
float d_scalemip[NUM_MIPS - 1];
qboolean d_roverwrapped;
int d_minmip;
float d_scalemip[NUM_MIPS - 1];
static float basemip[NUM_MIPS - 1] = { 1.0, 0.5 * 0.8, 0.25 * 0.8 };
extern int d_aflatcolor;
extern int d_aflatcolor;
float d_zitable[65536];
float d_zitable[65536];
void
@ -89,14 +85,11 @@ D_CopyRects (vrect_t *prects, int transparent)
console); Quake will then draw into wherever the driver points vid.buffer
and will call this function before swapping buffers
*/
// UNUSED (prects);
// UNUSED (transparent);
}
void
D_EnableBackBufferAccess (void)
{
VID_LockBuffer ();
}
@ -118,9 +111,9 @@ D_SetupFrame (void)
int i;
if (r_dowarp)
d_viewbuffer = (void *) r_warpbuffer;
d_viewbuffer = r_warpbuffer;
else
d_viewbuffer = (void *) vid.buffer;
d_viewbuffer = vid.buffer;
if (r_dowarp)
screenwidth = WARP_WIDTH;
@ -142,5 +135,4 @@ void
D_UpdateRects (vrect_t *prect)
{
// the software driver draws these directly to the vid buffer
// UNUSED (prect);
}

View file

@ -50,7 +50,7 @@ D_Patch (void)
void
D_ViewChanged (void)
{
int rowpixels;
int rowpixels;
if (r_dowarp)
rowpixels = WARP_WIDTH;

View file

@ -42,18 +42,20 @@ D_EndParticles (void)
// not used by software driver
}
void
D_StartParticles (void)
{
// not used by software driver
}
void
D_DrawParticle (particle_t *pparticle)
{
vec3_t local, transformed;
float zi;
short *pz;
short *pz;
int i, izi, pix, count, u, v;
// transform point

View file

@ -33,12 +33,12 @@
#include "QF/sys.h"
#include "r_local.h"
#include "d_local.h"
#include "r_local.h"
// TODO: put in span spilling to shrink list size
// !!! if this is changed, it must be changed in d_polysa.s too !!!
#define DPS_MAXSPANS MAXHEIGHT+1 // +1 for spanpackage marking end
#define DPS_MAXSPANS MAXHEIGHT+1 // +1 for spanpackage marking end
// !!! if this is changed, it must be changed in asm_draw.h too !!!
typedef struct {
@ -62,11 +62,12 @@ typedef struct {
} edgetable;
int r_p0[6], r_p1[6], r_p2[6];
int d_aflatcolor;
int d_xdenom;
byte *d_pcolormap;
int d_aflatcolor;
int d_xdenom;
edgetable *pedgetable;
edgetable edgetables[12] = {
@ -85,7 +86,7 @@ edgetable edgetables[12] = {
};
// FIXME: some of these can become statics
//int a_sstepxfrac, a_tstepxfrac, a_ststepxwhole;
int a_sstepxfrac, a_tstepxfrac, a_ststepxwhole;
int r_sstepx, r_tstepx, r_lstepx, r_lstepy, r_sstepy, r_tstepy;
int r_zistepx, r_zistepy;
int d_aspancount, d_countextrastep;
@ -156,7 +157,7 @@ D_DrawNonSubdiv (void)
index1 = pfv + ptri->vertindex[1];
index2 = pfv + ptri->vertindex[2];
d_xdenom =
d_xdenom =
(index0->v[1] - index1->v[1]) * (index0->v[0] - index2->v[0]) -
(index0->v[0] - index1->v[0]) * (index0->v[1] - index2->v[1]);
@ -352,8 +353,9 @@ D_PolysetCalcGradients (int skinwidth)
// a_ststepxwhole = skinwidth * (r_tstepx >> 16) + (r_sstepx >> 16);
}
/*
#if 0
byte gelmap[256];
void
InitGel (byte * palette)
{
@ -365,10 +367,10 @@ InitGel (byte * palette)
r =
(palette[i * 3] + palette[i * 3 + 1] +
palette[i * 3 + 2]) / (16 * 3);
gelmap[i] = *//* 64 *//* 0 + r;
gelmap[i] = /* 64 */ 0 + r;
}
}
*/
#endif
void
D_PolysetDrawSpans (spanpackage_t * pspanpackage)
@ -627,7 +629,7 @@ done32: ;
/*
D_PolysetFillSpans
*/
/*
#if 0
void
D_PolysetFillSpans (spanpackage_t * pspanpackage)
{
@ -704,11 +706,9 @@ D_PolysetFillSpans (spanpackage_t * pspanpackage)
Sys_Error("D_PolysetFillSpans: unsupported r_pixbytes %i\n", r_pixbytes);
}
}
*/
#endif
/*
D_RasterizeAliasPolySmooth
*/
void
D_RasterizeAliasPolySmooth (void)
{
@ -725,19 +725,13 @@ D_RasterizeAliasPolySmooth (void)
initialleftheight = pleftbottom[1] - plefttop[1];
initialrightheight = prightbottom[1] - prighttop[1];
//
// set the s, t, and light gradients, which are consistent across the triangle
// because being a triangle, things are affine
//
// set the s, t, and light gradients, which are consistent across the
// triangle, because being a triangle, things are affine
D_PolysetCalcGradients (r_affinetridesc.skinwidth);
//
// rasterize the polygon
//
//
// scan out the top (and possibly only) part of the left edge
//
// scan out the top (and possibly only) part of the left edge
D_PolysetSetUpForLineScan (plefttop[0], plefttop[1],
pleftbottom[0], pleftbottom[1]);
@ -763,9 +757,9 @@ D_RasterizeAliasPolySmooth (void)
// TODO: can reuse partial expressions here
// for negative steps in x along left edge, bias toward overflow rather than
// underflow (sort of turning the floor () we did in the gradient calcs into
// ceil (), but plus a little bit)
// for negative steps in x along left edge, bias toward overflow rather
// than underflow (sort of turning the floor () we did in the gradient
// calcs into ceil (), but plus a little bit)
if (ubasestep < 0)
working_lstepx = r_lstepx - 1;
else
@ -789,9 +783,7 @@ D_RasterizeAliasPolySmooth (void)
D_PolysetScanLeftEdge (initialleftheight);
//
// scan out the bottom part of the left edge, if it exists
//
// scan out the bottom part of the left edge, if it exists
if (pedgetable->numleftedges == 2) {
int height;
@ -847,8 +839,8 @@ D_RasterizeAliasPolySmooth (void)
D_PolysetScanLeftEdge (height);
}
// scan out the top (and possibly only) part of the right edge, updating the
// count field
// scan out the top (and possibly only) part of the right edge, updating
// the count field
d_pedgespanpackage = a_spans;
D_PolysetSetUpForLineScan (prighttop[0], prighttop[1],
@ -860,7 +852,7 @@ D_RasterizeAliasPolySmooth (void)
// spanpackages
D_PolysetDrawSpans (a_spans);
// scan out the bottom part of the right edge, if it exists
// scan out the bottom part of the right edge, if it exists
if (pedgetable->numrightedges == 2) {
int height;
spanpackage_t *pstart;
@ -886,9 +878,6 @@ D_RasterizeAliasPolySmooth (void)
}
/*
D_PolysetSetEdgeTable
*/
void
D_PolysetSetEdgeTable (void)
{
@ -897,10 +886,8 @@ D_PolysetSetEdgeTable (void)
// assume the vertices are already in top to bottom order
edgetableindex = 0;
//
// determine which edges are right & left, and the order in which
// to rasterize them
//
// determine which edges are right & left, and the order in which
// to rasterize them
if (r_p0[1] >= r_p1[1]) {
if (r_p0[1] == r_p1[1]) {
if (r_p0[1] < r_p2[1])
@ -909,8 +896,9 @@ D_PolysetSetEdgeTable (void)
pedgetable = &edgetables[5];
return;
} else
} else {
edgetableindex = 1;
}
}
if (r_p0[1] == r_p2[1]) {
@ -937,3 +925,79 @@ D_PolysetSetEdgeTable (void)
pedgetable = &edgetables[edgetableindex];
}
#if 0
void
D_PolysetRecursiveDrawLine (int *lp1, int *lp2)
{
int d;
int new[6];
int ofs;
d = lp2[0] - lp1[0];
if (d < -1 || d > 1)
goto split;
d = lp2[1] - lp1[1];
if (d < -1 || d > 1)
goto split;
return; // line is completed
split:
// split this edge
new[0] = (lp1[0] + lp2[0]) >> 1;
new[1] = (lp1[1] + lp2[1]) >> 1;
new[5] = (lp1[5] + lp2[5]) >> 1;
new[2] = (lp1[2] + lp2[2]) >> 1;
new[3] = (lp1[3] + lp2[3]) >> 1;
new[4] = (lp1[4] + lp2[4]) >> 1;
// draw the point
ofs = d_scantable[new[1]] + new[0];
if (new[5] > d_pzbuffer[ofs]) {
int pix;
d_pzbuffer[ofs] = new[5];
pix = skintable[new[3] >> 16][new[2] >> 16];
// pix = ((byte *)acolormap)[pix + (new[4] & 0xFF00)];
d_viewbuffer[ofs] = pix;
}
// recursively continue
D_PolysetRecursiveDrawLine (lp1, new);
D_PolysetRecursiveDrawLine (new, lp2);
}
void
D_PolysetRecursiveTriangle2 (int *lp1, int *lp2, int *lp3)
{
int d;
int new[4];
d = lp2[0] - lp1[0];
if (d < -1 || d > 1)
goto split;
d = lp2[1] - lp1[1];
if (d < -1 || d > 1)
goto split;
return;
split:
// split this edge
new[0] = (lp1[0] + lp2[0]) >> 1;
new[1] = (lp1[1] + lp2[1]) >> 1;
new[5] = (lp1[5] + lp2[5]) >> 1;
new[2] = (lp1[2] + lp2[2]) >> 1;
new[3] = (lp1[3] + lp2[3]) >> 1;
new[4] = (lp1[4] + lp2[4]) >> 1;
D_PolysetRecursiveDrawLine (new, lp3);
// recursively continue
D_PolysetRecursiveTriangle (lp1, new, lp3);
D_PolysetRecursiveTriangle (new, lp2, lp3);
}
#endif