Browse Source

ref_soft: Make it draw something, screen settings still wrong

pull/2/head
mittorn 6 years ago
parent
commit
e7785c9ccb
  1. 30
      r_edge.c
  2. 3
      r_glblit.c
  3. 6
      r_local.h
  4. 124
      r_main.c
  5. 44
      r_misc.c
  6. 28
      r_rast.c
  7. 12
      r_scan.c
  8. 43
      r_surf.c

30
r_edge.c

@ -69,6 +69,7 @@ static void (*pdrawfunc)(void); @@ -69,6 +69,7 @@ static void (*pdrawfunc)(void);
edge_t edge_head;
edge_t edge_tail;
edge_t edge_aftertail;
edge_t edge_sentinel;
@ -160,9 +161,15 @@ void R_InsertNewEdges (edge_t *edgestoadd, edge_t *edgelist) @@ -160,9 +161,15 @@ void R_InsertNewEdges (edge_t *edgestoadd, edge_t *edgelist)
{
next_edge = edgestoadd->next;
edgesearch:
if( !edgelist )
{
// gEngfuncs.Con_Printf("NULL edgelist!\n");
//return;
}
if (edgelist->u >= edgestoadd->u)
goto addedge;
edgelist=edgelist->next;
#if 1
if (edgelist->u >= edgestoadd->u)
goto addedge;
edgelist=edgelist->next;
@ -172,6 +179,7 @@ edgesearch: @@ -172,6 +179,7 @@ edgesearch:
if (edgelist->u >= edgestoadd->u)
goto addedge;
edgelist=edgelist->next;
#endif
goto edgesearch;
// insert edgestoadd before edgelist
@ -255,10 +263,14 @@ pushback: @@ -255,10 +263,14 @@ pushback:
// find out where the edge goes in the edge list
pwedge = pedge->prev->prev;
// if( !pwedge )
// return;
while (pwedge->u > pedge->u)
{
pwedge = pwedge->prev;
//if( !pwedge )
//return;
}
// put the edge back into the edge list
@ -647,7 +659,7 @@ void R_ScanEdges (void) @@ -647,7 +659,7 @@ void R_ScanEdges (void)
// clear active edges to just the background edges around the whole screen
// FIXME: most of this only needs to be set up once
edge_head.u = 0; //r_refdef.vrect.x << 20;
edge_head.u = 1 << 20; //r_refdef.vrect.x << 20;
edge_head_u_shift20 = edge_head.u >> 20;
edge_head.u_step = 0;
edge_head.prev = NULL;
@ -655,7 +667,7 @@ void R_ScanEdges (void) @@ -655,7 +667,7 @@ void R_ScanEdges (void)
edge_head.surfs[0] = 0;
edge_head.surfs[1] = 1;
edge_tail.u = 0xFFFFF; // (r_refdef.vrectright << 20) + 0xFFFFF;
edge_tail.u =(gpGlobals->width << 20) + 0xFFFFF; // (r_refdef.vrectright << 20) + 0xFFFFF;
edge_tail_u_shift20 = edge_tail.u >> 20;
edge_tail.u_step = 0;
edge_tail.prev = &edge_head;
@ -689,7 +701,7 @@ void R_ScanEdges (void) @@ -689,7 +701,7 @@ void R_ScanEdges (void)
{
R_InsertNewEdges (newedges[iv], edge_head.next);
}
#if 1
(*pdrawfunc) ();
// flush the span list if we can't be sure we have enough spans left for
@ -704,7 +716,7 @@ void R_ScanEdges (void) @@ -704,7 +716,7 @@ void R_ScanEdges (void)
span_p = basespan_p;
}
#endif
if (removeedges[iv])
R_RemoveEdges (removeedges[iv]);
@ -779,12 +791,12 @@ Simple single color fill with no texture mapping @@ -779,12 +791,12 @@ Simple single color fill with no texture mapping
void D_FlatFillSurface (surf_t *surf, int color)
{
espan_t *span;
byte *pdest;
pixel_t *pdest;
int u, u2;
for (span=surf->spans ; span ; span=span->pnext)
{
pdest = (byte *)d_viewbuffer + r_screenwidth*span->v;
pdest = d_viewbuffer + r_screenwidth*span->v;
u = span->u;
u2 = span->u + span->count - 1;
for ( ; u <= u2 ; u++)
@ -869,7 +881,7 @@ void D_BackgroundSurf (surf_t *s) @@ -869,7 +881,7 @@ void D_BackgroundSurf (surf_t *s)
d_zistepv = 0;
d_ziorigin = -0.9;
D_FlatFillSurface (s, (int)sw_clearcolor->value & 0xFF);
D_FlatFillSurface (s, (int)sw_clearcolor->value & 0xFFFF);
D_DrawZSpans (s->spans);
}
@ -1027,6 +1039,8 @@ void D_SolidSurf (surf_t *s) @@ -1027,6 +1039,8 @@ void D_SolidSurf (surf_t *s)
}
#endif
if( !pface )
return;
// FIXME: make this passed in to D_CacheSurface
pcurrentcache = D_CacheSurface (pface, miplevel);
@ -1078,7 +1092,7 @@ void D_DrawflatSurfaces (void) @@ -1078,7 +1092,7 @@ void D_DrawflatSurfaces (void)
// make a stable color for each surface by taking the low
// bits of the msurface pointer
D_FlatFillSurface (s, (int)s->msurf & 0xFF);
D_FlatFillSurface (s, (int)s->msurf & 0xFFFF);
D_DrawZSpans (s->spans);
}
}

3
r_glblit.c

@ -168,6 +168,9 @@ void R_InitBlit() @@ -168,6 +168,9 @@ void R_InitBlit()
R_BuildScreenMap();
R_BuildBlendMaps();
d_pzbuffer = malloc(vid.width*vid.height*2);
R_InitCaches();
}
void R_BlitScreen()

6
r_local.h

@ -783,11 +783,11 @@ extern cvar_t *r_showhull; @@ -783,11 +783,11 @@ extern cvar_t *r_showhull;
#define DS_SPAN_LIST_END -128
#define NUMSTACKEDGES 2000
#define NUMSTACKEDGES 4000
#define MINEDGES NUMSTACKEDGES
#define NUMSTACKSURFACES 1000
#define NUMSTACKSURFACES 2000
#define MINSURFACES NUMSTACKSURFACES
#define MAXSPANS 3000
#define MAXSPANS 6000
// flags in finalvert_t.flags
#define ALIAS_LEFT_CLIP 0x0001

124
r_main.c

@ -19,6 +19,7 @@ GNU General Public License for more details. @@ -19,6 +19,7 @@ GNU General Public License for more details.
//#include "beamdef.h"
//#include "particledef.h"
#include "entity_types.h"
#include "mod_local.h"
#define IsLiquidContents( cnt ) ( cnt == CONTENTS_WATER || cnt == CONTENTS_SLIME || cnt == CONTENTS_LAVA )
@ -1230,6 +1231,125 @@ void R_EdgeDrawing (void) @@ -1230,6 +1231,125 @@ void R_EdgeDrawing (void)
R_ScanEdges ();
}
#if 0
/*
===============
R_MarkLeaves
Mark the leaves and nodes that are in the PVS for the current leaf
===============
*/
void R_MarkLeaves( void )
{
qboolean novis = false;
qboolean force = false;
mleaf_t *leaf = NULL;
mnode_t *node;
vec3_t test;
int i;
if( !RI.drawWorld ) return;
/*if( FBitSet( r_novis->flags, FCVAR_CHANGED ) || tr.fResetVis )
{
// force recalc viewleaf
ClearBits( r_novis->flags, FCVAR_CHANGED );
tr.fResetVis = false;
RI.viewleaf = NULL;
}*/
VectorCopy( RI.pvsorigin, test );
if( RI.viewleaf != NULL )
{
// merge two leafs that can be a crossed-line contents
if( RI.viewleaf->contents == CONTENTS_EMPTY )
{
VectorSet( test, RI.pvsorigin[0], RI.pvsorigin[1], RI.pvsorigin[2] - 16.0f );
leaf = gEngfuncs.Mod_PointInLeaf( test, WORLDMODEL->nodes );
}
else
{
VectorSet( test, RI.pvsorigin[0], RI.pvsorigin[1], RI.pvsorigin[2] + 16.0f );
leaf = gEngfuncs.Mod_PointInLeaf( test, WORLDMODEL->nodes );
}
if(( leaf->contents != CONTENTS_SOLID ) && ( RI.viewleaf != leaf ))
force = true;
}
if( RI.viewleaf == RI.oldviewleaf && RI.viewleaf != NULL && !force )
return;
// development aid to let you run around
// and see exactly where the pvs ends
//if( sw_lockpvs->value ) return;
RI.oldviewleaf = RI.viewleaf;
tr.visframecount++;
if( RI.drawOrtho || !RI.viewleaf || !WORLDMODEL->visdata )
novis = true;
gEngfuncs.R_FatPVS( RI.pvsorigin, REFPVS_RADIUS, RI.visbytes, FBitSet( RI.params, RP_OLDVIEWLEAF ), novis );
if( force && !novis ) gEngfuncs.R_FatPVS( test, REFPVS_RADIUS, RI.visbytes, true, novis );
for( i = 0; i < WORLDMODEL->numleafs; i++ )
{
if( CHECKVISBIT( RI.visbytes, i ))
{
node = (mnode_t *)&WORLDMODEL->leafs[i+1];
do
{
if( node->visframe == tr.visframecount )
break;
node->visframe = tr.visframecount;
node = node->parent;
} while( node );
}
}
}
#else
/*
===============
R_MarkLeaves
===============
*/
void R_MarkLeaves (void)
{
byte *vis;
mnode_t *node;
int i;
if (r_oldviewcluster == r_viewcluster && !r_novis->value && r_viewcluster != -1)
return;
r_visframecount++;
r_oldviewcluster = r_viewcluster;
gEngfuncs.R_FatPVS( RI.pvsorigin, REFPVS_RADIUS, RI.visbytes, FBitSet( RI.params, RP_OLDVIEWLEAF ), false );
vis = RI.visbytes;
for (i = 0; i < WORLDMODEL->numleafs; i++)
{
if (vis[i>>3] & (1<<(i&7)))
{
node = (mnode_t *) &WORLDMODEL->leafs[i+1];
do
{
if (node->visframe == r_visframecount)
break;
node->visframe = r_visframecount;
node = node->parent;
} while (node);
}
}
}
#endif
/*
================
R_RenderScene
@ -1257,7 +1377,7 @@ void R_RenderScene( void ) @@ -1257,7 +1377,7 @@ void R_RenderScene( void )
// R_SetupGL( true );
R_Clear( ~0 );
//R_MarkLeaves();
R_MarkLeaves();
R_DrawFog ();
// R_PushDlights (r_worldmodel); ??
R_CheckGLFog();
@ -1542,7 +1662,7 @@ qboolean R_Init() @@ -1542,7 +1662,7 @@ qboolean R_Init()
//r_dspeeds = ri.Cvar_Get ("r_dspeeds", "0", 0);
// r_lightlevel = ri.Cvar_Get ("r_lightlevel", "0", 0);
//r_lerpmodels = ri.Cvar_Get( "r_lerpmodels", "1", 0 );
//r_novis = ri.Cvar_Get( "r_novis", "0", 0 );
r_novis = gEngfuncs.Cvar_Get( "r_novis", "0", 0, "" );
// create the window and set up the context
r_temppool = Mem_AllocPool( "ref_sw zone" );

44
r_misc.c

@ -254,55 +254,65 @@ void R_ViewChanged (vrect_t *vr) @@ -254,55 +254,65 @@ void R_ViewChanged (vrect_t *vr)
xOrigin = r_refdef.xOrigin;
yOrigin = r_refdef.yOrigin;
#endif
int fov_x = 2.0 * tan (RI.fov_x/360*M_PI);
int fov_y = 2.0 * tan (RI.fov_y/360*M_PI);
// values for perspective projection
// if math were exact, the values would range from 0.5 to to range+0.5
// hopefully they wll be in the 0.000001 to range+.999999 and truncate
// the polygon rasterization will never render in the first row or column
// but will definately render in the [range] row and column, so adjust the
// buffer origin to get an exact edge to edge fill
xcenter = ((float)r_refdef.vrect.width * XCENTERING) +
r_refdef.vrect.x - 0.5;
aliasxcenter = xcenter * r_aliasuvscale;
ycenter = ((float)r_refdef.vrect.height * YCENTERING) +
r_refdef.vrect.y - 0.5;
aliasycenter = ycenter * r_aliasuvscale;
xscale = r_refdef.vrect.width / r_refdef.horizontalFieldOfView;
aliasxscale = xscale * r_aliasuvscale;
xcenter = ((float)gpGlobals->width * XCENTERING) +
0 - 0.5;
//aliasxcenter = xcenter * r_aliasuvscale;
ycenter = ((float)gpGlobals->height * YCENTERING) +
0 - 0.5;
//aliasycenter = ycenter * r_aliasuvscale;
xscale = gpGlobals->width * 1.5 / fov_x;
//aliasxscale = xscale * r_aliasuvscale;
xscaleinv = 1.0 / xscale;
yscale = xscale;
aliasyscale = yscale * r_aliasuvscale;
//aliasyscale = yscale * r_aliasuvscale;
yscaleinv = 1.0 / yscale;
xscaleshrink = (r_refdef.vrect.width-6)/r_refdef.horizontalFieldOfView;
xscaleshrink = (gpGlobals->width-6)/fov_x;
yscaleshrink = xscaleshrink;
// ???
#define PLANE_ANYZ 5
int xOrigin = r_origin[0];
int yOrigin = r_origin[1];
// left side clip
screenedge[0].normal[0] = -1.0 / (xOrigin*r_refdef.horizontalFieldOfView);
screenedge[0].normal[0] = -1.0 / (xOrigin*fov_x);
screenedge[0].normal[1] = 0;
screenedge[0].normal[2] = 1;
screenedge[0].type = PLANE_ANYZ;
// right side clip
screenedge[1].normal[0] =
1.0 / ((1.0-xOrigin)*r_refdef.horizontalFieldOfView);
1.0 / ((1.0-xOrigin)*fov_x);
screenedge[1].normal[1] = 0;
screenedge[1].normal[2] = 1;
screenedge[1].type = PLANE_ANYZ;
// top side clip
screenedge[2].normal[0] = 0;
screenedge[2].normal[1] = -1.0 / (yOrigin*verticalFieldOfView);
screenedge[2].normal[1] = -1.0 / (yOrigin*fov_y);
screenedge[2].normal[2] = 1;
screenedge[2].type = PLANE_ANYZ;
// bottom side clip
screenedge[3].normal[0] = 0;
screenedge[3].normal[1] = 1.0 / ((1.0-yOrigin)*verticalFieldOfView);
screenedge[3].normal[1] = 1.0 / ((1.0-yOrigin)*fov_y);
screenedge[3].normal[2] = 1;
screenedge[3].type = PLANE_ANYZ;
#endif
for (i=0 ; i<4 ; i++)
VectorNormalize (screenedge[i].normal);

28
r_rast.c

@ -226,6 +226,8 @@ void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1) @@ -226,6 +226,8 @@ void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
int v, v2, ceilv0;
float scale, lzi0, u0, v0;
int side;
if( isnan( pv0->position[1]) )
return;
if (r_lastvertvalid)
{
@ -263,6 +265,13 @@ void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1) @@ -263,6 +265,13 @@ void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
v0 = gpGlobals->height;
ceilv0 = (int) ceil(v0);
if( ceilv0 < 0 )
{
printf("ceilv0 %d %f %f %f %f\n", ceilv0, v0, scale, transformed[1], ycenter );
printf("%f %f %f %f\n", world[1],modelorg[1], local[1], transformed[1] );
}
}
world = &pv1->position[0];
@ -306,7 +315,7 @@ void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1) @@ -306,7 +315,7 @@ void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
// create the edge
if (ceilv0 == r_ceilv1)
if (ceilv0 == r_ceilv1 || ceilv0 < 0 )
{
// we cache unclipped horizontal edges as fully clipped
if (cacheoffset != 0x7FFFFFFF)
@ -330,6 +339,7 @@ void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1) @@ -330,6 +339,7 @@ void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
{
// trailing edge (go from p1 to p2)
v = ceilv0;
if( v < 0 )printf("v0 %d\n", v);
v2 = r_ceilv1 - 1;
edge->surfs[0] = surface_p - surfaces;
@ -343,6 +353,7 @@ void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1) @@ -343,6 +353,7 @@ void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
// leading edge (go from p2 to p1)
v2 = ceilv0 - 1;
v = r_ceilv1;
if( v < 0 )printf("v1 %d\n", v);
edge->surfs[0] = 0;
edge->surfs[1] = surface_p - surfaces;
@ -359,10 +370,12 @@ void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1) @@ -359,10 +370,12 @@ void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
// it to incorrectly extend to the scan, and the extension of the line goes off
// the edge of the screen
// FIXME: is this actually needed?
// if (edge->u < r_refdef.vrect_x_adj_shift20)
// edge->u = r_refdef.vrect_x_adj_shift20;
// if (edge->u > r_refdef.vrectright_adj_shift20)
// edge->u = r_refdef.vrectright_adj_shift20;
int r = (gpGlobals->width<<20) + (1<<19) - 1;
int x = (1<<20) + (1<<19) - 1;
if (edge->u < x)
edge->u = x;
if (edge->u > r)
edge->u = r;
//
// sort the edge in normally
@ -371,6 +384,11 @@ void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1) @@ -371,6 +384,11 @@ void R_EmitEdge (mvertex_t *pv0, mvertex_t *pv1)
if (edge->surfs[0])
u_check++; // sort trailers after leaders
if( v < 0 )
{
printf("v %d\n", v);
v = 0;
}
if (!newedges[v] || newedges[v]->u >= u_check)
{
edge->next = newedges[v];

12
r_scan.c

@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "r_local.h"
unsigned char *r_turb_pbase, *r_turb_pdest;
pixel_t *r_turb_pbase, *r_turb_pdest;
fixed16_t r_turb_s, r_turb_t, r_turb_sstep, r_turb_tstep;
int *r_turb_turb;
int r_turb_spancount;
@ -143,7 +143,7 @@ void Turbulent8 (espan_t *pspan) @@ -143,7 +143,7 @@ void Turbulent8 (espan_t *pspan)
do
{
r_turb_pdest = (unsigned char *)((byte *)d_viewbuffer +
r_turb_pdest = (d_viewbuffer +
(r_screenwidth * pspan->v) + pspan->u);
count = pspan->count;
@ -271,7 +271,7 @@ void NonTurbulent8 (espan_t *pspan) @@ -271,7 +271,7 @@ void NonTurbulent8 (espan_t *pspan)
r_turb_sstep = 0; // keep compiler happy
r_turb_tstep = 0; // ditto
r_turb_pbase = (unsigned char *)cacheblock;
r_turb_pbase = cacheblock;
sdivz16stepu = d_sdivzstepu * 16;
tdivz16stepu = d_tdivzstepu * 16;
@ -279,7 +279,7 @@ void NonTurbulent8 (espan_t *pspan) @@ -279,7 +279,7 @@ void NonTurbulent8 (espan_t *pspan)
do
{
r_turb_pdest = (unsigned char *)((byte *)d_viewbuffer +
r_turb_pdest = (d_viewbuffer +
(r_screenwidth * pspan->v) + pspan->u);
count = pspan->count;
@ -401,7 +401,7 @@ D_DrawSpans16 @@ -401,7 +401,7 @@ D_DrawSpans16
void D_DrawSpans16 (espan_t *pspan)
{
int count, spancount;
unsigned char *pbase, *pdest;
pixel_t *pbase, *pdest;
fixed16_t s, t, snext, tnext, sstep, tstep;
float sdivz, tdivz, zi, z, du, dv, spancountminus1;
float sdivz8stepu, tdivz8stepu, zi8stepu;
@ -417,7 +417,7 @@ void D_DrawSpans16 (espan_t *pspan) @@ -417,7 +417,7 @@ void D_DrawSpans16 (espan_t *pspan)
do
{
pdest = (unsigned char *)((byte *)d_viewbuffer +
pdest = (d_viewbuffer +
(r_screenwidth * pspan->v) + pspan->u);
count = pspan->count;

43
r_surf.c

@ -28,13 +28,13 @@ int lightdelta, lightdeltastep; @@ -28,13 +28,13 @@ int lightdelta, lightdeltastep;
int lightright, lightleftstep, lightrightstep, blockdivshift;
unsigned blockdivmask;
void *prowdestbase;
unsigned char *pbasesource;
pixel_t *pbasesource;
int surfrowbytes; // used by ASM files
unsigned *r_lightptr;
int r_stepback;
int r_lightwidth;
int r_numhblocks, r_numvblocks;
unsigned char *r_source, *r_sourcemax;
pixel_t *r_source, *r_sourcemax;
void R_DrawSurfaceBlock8_mip0 (void);
void R_DrawSurfaceBlock8_mip1 (void);
@ -188,18 +188,19 @@ R_DrawSurface @@ -188,18 +188,19 @@ R_DrawSurface
*/
void R_DrawSurface (void)
{
unsigned char *basetptr;
pixel_t *basetptr;
int smax, tmax, twidth;
int u;
int soffset, basetoffset, texwidth;
int horzblockstep;
unsigned char *pcolumndest;
pixel_t *pcolumndest;
void (*pblockdrawer)(void);
image_t *mt;
surfrowbytes = r_drawsurf.rowbytes;
mt = r_drawsurf.image;
r_drawsurf.surfmip = 0;
r_source = mt->pixels[r_drawsurf.surfmip];
@ -219,7 +220,7 @@ void R_DrawSurface (void) @@ -219,7 +220,7 @@ void R_DrawSurface (void)
//==============================
pblockdrawer = surfmiptable[r_drawsurf.surfmip];
pblockdrawer = surfmiptable[0];
// TODO: only needs to be set when there is a display settings change
horzblockstep = blocksize;
@ -272,7 +273,7 @@ R_DrawSurfaceBlock8_mip0 @@ -272,7 +273,7 @@ R_DrawSurfaceBlock8_mip0
void R_DrawSurfaceBlock8_mip0 (void)
{
int v, i, b, lightstep, lighttemp, light;
unsigned char pix, *psource, *prowdest;
pixel_t pix, *psource, *prowdest;
psource = pbasesource;
prowdest = prowdestbase;
@ -281,11 +282,11 @@ void R_DrawSurfaceBlock8_mip0 (void) @@ -281,11 +282,11 @@ void R_DrawSurfaceBlock8_mip0 (void)
{
// FIXME: make these locals?
// FIXME: use delta rather than both right and left, like ASM?
lightleft = r_lightptr[0];
lightright = r_lightptr[1];
r_lightptr += r_lightwidth;
lightleftstep = (r_lightptr[0] - lightleft) >> 4;
lightrightstep = (r_lightptr[1] - lightright) >> 4;
//lightleft = r_lightptr[0];
//lightright = r_lightptr[1];
//r_lightptr += r_lightwidth;
//lightleftstep = (r_lightptr[0] - lightleft) >> 4;
//lightrightstep = (r_lightptr[1] - lightright) >> 4;
for (i=0 ; i<16 ; i++)
{
@ -297,14 +298,15 @@ void R_DrawSurfaceBlock8_mip0 (void) @@ -297,14 +298,15 @@ void R_DrawSurfaceBlock8_mip0 (void)
for (b=15; b>=0; b--)
{
pix = psource[b];
prowdest[b] = ((unsigned char *)vid.colormap)
[(light & 0xFF00) + pix];
prowdest[b] = pix;
//((unsigned char *)vid.colormap)
//[(light & 0xFF00) + pix];
light += lightstep;
}
psource += sourcetstep;
lightright += lightrightstep;
lightleft += lightleftstep;
//lightright += lightrightstep;
//lightleft += lightleftstep;
prowdest += surfrowbytes;
}
@ -489,7 +491,7 @@ void R_InitCaches (void) @@ -489,7 +491,7 @@ void R_InitCaches (void)
{
size = SURFCACHE_SIZE_AT_320X240;
pix = vid.width*vid.height;
pix =1920 * 1080 * 16;
if (pix > 64000)
size += (pix-64000)*3;
}
@ -543,10 +545,10 @@ surfcache_t *D_SCAlloc (int width, int size) @@ -543,10 +545,10 @@ surfcache_t *D_SCAlloc (int width, int size)
surfcache_t *new;
qboolean wrapped_this_time;
if ((width < 0) || (width > 256))
if ((width < 0) )// || (width > 256))
gEngfuncs.Host_Error ("D_SCAlloc: bad cache width %d\n", width);
if ((size <= 0) || (size > 0x10000))
if ((size <= 0) || (size > 0x10000000))
gEngfuncs.Host_Error ("D_SCAlloc: bad cache size %d\n", size);
size = (int)&((surfcache_t *)0)->data[size];
@ -674,11 +676,10 @@ D_CacheSurface @@ -674,11 +676,10 @@ D_CacheSurface
surfcache_t *D_CacheSurface (msurface_t *surface, int miplevel)
{
surfcache_t *cache;
//
// if the surface is animating or flashing, flush the cache
//
r_drawsurf.image = R_GetTexture(R_TextureAnimation (surface->texinfo->texture->gl_texturenum));
r_drawsurf.image = R_GetTexture(R_TextureAnimation (surface)->gl_texturenum);
/// todo: port this
//r_drawsurf.lightadj[0] = r_newrefdef.lightstyles[surface->styles[0]].white*128;
@ -715,7 +716,7 @@ surfcache_t *D_CacheSurface (msurface_t *surface, int miplevel) @@ -715,7 +716,7 @@ surfcache_t *D_CacheSurface (msurface_t *surface, int miplevel)
if (!cache) // if a texture just animated, don't reallocate it
{
cache = D_SCAlloc (r_drawsurf.surfwidth,
r_drawsurf.surfwidth * r_drawsurf.surfheight);
r_drawsurf.surfwidth * r_drawsurf.surfheight * 2);
CACHESPOT(surface)[miplevel] = cache;
cache->owner = &CACHESPOT(surface)[miplevel];
cache->mipscale = surfscale;

Loading…
Cancel
Save