Move some draw segment functions to r_draw_segment

This commit is contained in:
Magnus Norddahl 2016-12-29 01:06:24 +01:00
commit b615b1b497
4 changed files with 31 additions and 44 deletions

View file

@ -46,4 +46,33 @@ namespace swrenderer
ds_p = drawsegs;
}
ptrdiff_t R_NewOpening(ptrdiff_t len)
{
ptrdiff_t res = lastopening;
len = (len + 1) & ~1; // only return DWORD aligned addresses because some code stores fixed_t's and floats in openings...
lastopening += len;
if ((size_t)lastopening > maxopenings)
{
do
maxopenings = maxopenings ? maxopenings * 2 : 16384;
while ((size_t)lastopening > maxopenings);
openings = (short *)M_Realloc(openings, maxopenings * sizeof(*openings));
DPrintf(DMSG_NOTIFY, "MaxOpenings increased to %zu\n", maxopenings);
}
return res;
}
void R_CheckDrawSegs()
{
if (ds_p == &drawsegs[MaxDrawSegs])
{ // [RH] Grab some more drawsegs
size_t newdrawsegs = MaxDrawSegs ? MaxDrawSegs * 2 : 32;
ptrdiff_t firstofs = firstdrawseg - drawsegs;
drawsegs = (drawseg_t *)M_Realloc(drawsegs, newdrawsegs * sizeof(drawseg_t));
firstdrawseg = drawsegs + firstofs;
ds_p = drawsegs + MaxDrawSegs;
MaxDrawSegs = newdrawsegs;
DPrintf(DMSG_NOTIFY, "MaxDrawSegs increased to %zu\n", MaxDrawSegs);
}
}
}