mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
make r_drawsurf local
This commit is contained in:
parent
aec8f3fc8b
commit
2b9b039139
3 changed files with 30 additions and 30 deletions
|
@ -352,8 +352,6 @@ void R_PolysetUpdateTables(void);
|
||||||
|
|
||||||
// callbacks to Quake
|
// callbacks to Quake
|
||||||
|
|
||||||
extern drawsurf_t r_drawsurf;
|
|
||||||
|
|
||||||
extern int c_surf;
|
extern int c_surf;
|
||||||
|
|
||||||
extern pixel_t *r_warpbuffer;
|
extern pixel_t *r_warpbuffer;
|
||||||
|
|
|
@ -275,7 +275,7 @@ R_AddDynamicLights
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
R_AddDynamicLights (void)
|
R_AddDynamicLights (drawsurf_t* drawsurf)
|
||||||
{
|
{
|
||||||
msurface_t *surf;
|
msurface_t *surf;
|
||||||
int lnum;
|
int lnum;
|
||||||
|
@ -289,7 +289,7 @@ R_AddDynamicLights (void)
|
||||||
dlight_t *dl;
|
dlight_t *dl;
|
||||||
int negativeLight; //PGM
|
int negativeLight; //PGM
|
||||||
|
|
||||||
surf = r_drawsurf.surf;
|
surf = drawsurf->surf;
|
||||||
smax = (surf->extents[0]>>4)+1;
|
smax = (surf->extents[0]>>4)+1;
|
||||||
tmax = (surf->extents[1]>>4)+1;
|
tmax = (surf->extents[1]>>4)+1;
|
||||||
tex = surf->texinfo;
|
tex = surf->texinfo;
|
||||||
|
@ -376,14 +376,15 @@ R_BuildLightMap
|
||||||
Combine and scale multiple lightmaps into the 8.8 format in blocklights
|
Combine and scale multiple lightmaps into the 8.8 format in blocklights
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
void R_BuildLightMap (void)
|
void
|
||||||
|
R_BuildLightMap (drawsurf_t* drawsurf)
|
||||||
{
|
{
|
||||||
int smax, tmax;
|
int smax, tmax;
|
||||||
int i, size;
|
int i, size;
|
||||||
byte *lightmap;
|
byte *lightmap;
|
||||||
msurface_t *surf;
|
msurface_t *surf;
|
||||||
|
|
||||||
surf = r_drawsurf.surf;
|
surf = drawsurf->surf;
|
||||||
|
|
||||||
smax = (surf->extents[0]>>4)+1;
|
smax = (surf->extents[0]>>4)+1;
|
||||||
tmax = (surf->extents[1]>>4)+1;
|
tmax = (surf->extents[1]>>4)+1;
|
||||||
|
@ -412,7 +413,7 @@ void R_BuildLightMap (void)
|
||||||
{
|
{
|
||||||
unsigned scale;
|
unsigned scale;
|
||||||
|
|
||||||
scale = r_drawsurf.lightadj[maps]; // 8.8 fraction
|
scale = drawsurf->lightadj[maps]; // 8.8 fraction
|
||||||
for (i=0 ; i<size ; i++)
|
for (i=0 ; i<size ; i++)
|
||||||
blocklights[i] += lightmap[i] * scale;
|
blocklights[i] += lightmap[i] * scale;
|
||||||
lightmap += size; // skip to next lightmap
|
lightmap += size; // skip to next lightmap
|
||||||
|
@ -421,7 +422,7 @@ void R_BuildLightMap (void)
|
||||||
|
|
||||||
// add all the dynamic lights
|
// add all the dynamic lights
|
||||||
if (surf->dlightframe == r_framecount)
|
if (surf->dlightframe == r_framecount)
|
||||||
R_AddDynamicLights ();
|
R_AddDynamicLights (drawsurf);
|
||||||
|
|
||||||
// bound, invert, and shift
|
// bound, invert, and shift
|
||||||
for (i=0 ; i<size ; i++)
|
for (i=0 ; i<size ; i++)
|
||||||
|
|
|
@ -21,7 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "header/local.h"
|
#include "header/local.h"
|
||||||
|
|
||||||
drawsurf_t r_drawsurf;
|
|
||||||
static int lightleft, blocksize, sourcetstep;
|
static int lightleft, blocksize, sourcetstep;
|
||||||
static int lightright, lightleftstep, lightrightstep, blockdivshift;
|
static int lightright, lightleftstep, lightrightstep, blockdivshift;
|
||||||
static void *prowdestbase;
|
static void *prowdestbase;
|
||||||
|
@ -34,7 +33,7 @@ static unsigned *r_lightptr;
|
||||||
|
|
||||||
static void R_DrawSurfaceBlock8_anymip (int level, int surfrowbytes);
|
static void R_DrawSurfaceBlock8_anymip (int level, int surfrowbytes);
|
||||||
|
|
||||||
void R_BuildLightMap (void);
|
void R_BuildLightMap (drawsurf_t *drawsurf);
|
||||||
extern unsigned blocklights[1024]; // allow some very large lightmaps
|
extern unsigned blocklights[1024]; // allow some very large lightmaps
|
||||||
|
|
||||||
static float surfscale;
|
static float surfscale;
|
||||||
|
@ -75,7 +74,7 @@ R_DrawSurface
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
R_DrawSurface (void)
|
R_DrawSurface (drawsurf_t *drawsurf)
|
||||||
{
|
{
|
||||||
unsigned char *basetptr;
|
unsigned char *basetptr;
|
||||||
int smax, tmax, twidth;
|
int smax, tmax, twidth;
|
||||||
|
@ -85,45 +84,45 @@ R_DrawSurface (void)
|
||||||
unsigned char *pcolumndest;
|
unsigned char *pcolumndest;
|
||||||
image_t *mt;
|
image_t *mt;
|
||||||
|
|
||||||
mt = r_drawsurf.image;
|
mt = drawsurf->image;
|
||||||
|
|
||||||
r_source = mt->pixels[r_drawsurf.surfmip];
|
r_source = mt->pixels[drawsurf->surfmip];
|
||||||
|
|
||||||
// the fractional light values should range from 0 to (VID_GRADES - 1) << 16
|
// the fractional light values should range from 0 to (VID_GRADES - 1) << 16
|
||||||
// from a source range of 0 - 255
|
// from a source range of 0 - 255
|
||||||
|
|
||||||
texwidth = mt->width >> r_drawsurf.surfmip;
|
texwidth = mt->width >> drawsurf->surfmip;
|
||||||
|
|
||||||
blocksize = 16 >> r_drawsurf.surfmip;
|
blocksize = 16 >> drawsurf->surfmip;
|
||||||
blockdivshift = NUM_MIPS - r_drawsurf.surfmip;
|
blockdivshift = NUM_MIPS - drawsurf->surfmip;
|
||||||
|
|
||||||
r_lightwidth = (r_drawsurf.surf->extents[0]>>4)+1;
|
r_lightwidth = (drawsurf->surf->extents[0]>>4)+1;
|
||||||
|
|
||||||
r_numhblocks = r_drawsurf.surfwidth >> blockdivshift;
|
r_numhblocks = drawsurf->surfwidth >> blockdivshift;
|
||||||
r_numvblocks = r_drawsurf.surfheight >> blockdivshift;
|
r_numvblocks = drawsurf->surfheight >> blockdivshift;
|
||||||
|
|
||||||
//==============================
|
//==============================
|
||||||
|
|
||||||
// TODO: only needs to be set when there is a display settings change
|
// TODO: only needs to be set when there is a display settings change
|
||||||
horzblockstep = blocksize;
|
horzblockstep = blocksize;
|
||||||
|
|
||||||
smax = mt->width >> r_drawsurf.surfmip;
|
smax = mt->width >> drawsurf->surfmip;
|
||||||
twidth = texwidth;
|
twidth = texwidth;
|
||||||
tmax = mt->height >> r_drawsurf.surfmip;
|
tmax = mt->height >> drawsurf->surfmip;
|
||||||
sourcetstep = texwidth;
|
sourcetstep = texwidth;
|
||||||
r_stepback = tmax * twidth;
|
r_stepback = tmax * twidth;
|
||||||
|
|
||||||
r_sourcemax = r_source + (tmax * smax);
|
r_sourcemax = r_source + (tmax * smax);
|
||||||
|
|
||||||
soffset = r_drawsurf.surf->texturemins[0];
|
soffset = drawsurf->surf->texturemins[0];
|
||||||
basetoffset = r_drawsurf.surf->texturemins[1];
|
basetoffset = drawsurf->surf->texturemins[1];
|
||||||
|
|
||||||
// << 16 components are to guarantee positive values for %
|
// << 16 components are to guarantee positive values for %
|
||||||
soffset = ((soffset >> r_drawsurf.surfmip) + (smax << SHIFT16XYZ)) % smax;
|
soffset = ((soffset >> drawsurf->surfmip) + (smax << SHIFT16XYZ)) % smax;
|
||||||
basetptr = &r_source[((((basetoffset >> r_drawsurf.surfmip)
|
basetptr = &r_source[((((basetoffset >> drawsurf->surfmip)
|
||||||
+ (tmax << SHIFT16XYZ)) % tmax) * twidth)];
|
+ (tmax << SHIFT16XYZ)) % tmax) * twidth)];
|
||||||
|
|
||||||
pcolumndest = r_drawsurf.surfdat;
|
pcolumndest = drawsurf->surfdat;
|
||||||
|
|
||||||
for (u=0 ; u<r_numhblocks; u++)
|
for (u=0 ; u<r_numhblocks; u++)
|
||||||
{
|
{
|
||||||
|
@ -133,7 +132,7 @@ R_DrawSurface (void)
|
||||||
|
|
||||||
pbasesource = basetptr + soffset;
|
pbasesource = basetptr + soffset;
|
||||||
|
|
||||||
R_DrawSurfaceBlock8_anymip(NUM_MIPS - r_drawsurf.surfmip, r_drawsurf.rowbytes);
|
R_DrawSurfaceBlock8_anymip(NUM_MIPS - drawsurf->surfmip, drawsurf->rowbytes);
|
||||||
|
|
||||||
soffset = soffset + blocksize;
|
soffset = soffset + blocksize;
|
||||||
if (soffset >= smax)
|
if (soffset >= smax)
|
||||||
|
@ -338,6 +337,8 @@ D_SCAlloc (int width, int size)
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
|
static drawsurf_t r_drawsurf;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
================
|
================
|
||||||
D_CacheSurface
|
D_CacheSurface
|
||||||
|
@ -346,7 +347,7 @@ D_CacheSurface
|
||||||
surfcache_t *
|
surfcache_t *
|
||||||
D_CacheSurface (msurface_t *surface, int miplevel)
|
D_CacheSurface (msurface_t *surface, int miplevel)
|
||||||
{
|
{
|
||||||
surfcache_t *cache;
|
surfcache_t *cache;
|
||||||
|
|
||||||
//
|
//
|
||||||
// if the surface is animating or flashing, flush the cache
|
// if the surface is animating or flashing, flush the cache
|
||||||
|
@ -412,10 +413,10 @@ D_CacheSurface (msurface_t *surface, int miplevel)
|
||||||
c_surf++;
|
c_surf++;
|
||||||
|
|
||||||
// calculate the lightings
|
// calculate the lightings
|
||||||
R_BuildLightMap ();
|
R_BuildLightMap (&r_drawsurf);
|
||||||
|
|
||||||
// rasterize the surface into the cache
|
// rasterize the surface into the cache
|
||||||
R_DrawSurface ();
|
R_DrawSurface (&r_drawsurf);
|
||||||
|
|
||||||
return cache;
|
return cache;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue