2017-01-03 06:17:54 +00:00
|
|
|
//
|
|
|
|
// Copyright (C) 1993-1996 by id Software, Inc.
|
|
|
|
//
|
|
|
|
// This source is available for distribution and/or modification
|
|
|
|
// only under the terms of the DOOM Source Code License as
|
|
|
|
// published by id Software. All rights reserved.
|
|
|
|
//
|
|
|
|
// The source is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
|
|
|
|
// for more details.
|
|
|
|
//
|
2016-12-28 06:04:13 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "templates.h"
|
|
|
|
#include "doomdef.h"
|
|
|
|
#include "m_bbox.h"
|
|
|
|
#include "i_system.h"
|
|
|
|
#include "p_lnspec.h"
|
|
|
|
#include "p_setup.h"
|
|
|
|
#include "a_sharedglobal.h"
|
|
|
|
#include "g_level.h"
|
|
|
|
#include "p_effect.h"
|
|
|
|
#include "doomstat.h"
|
|
|
|
#include "r_state.h"
|
|
|
|
#include "v_palette.h"
|
|
|
|
#include "r_sky.h"
|
|
|
|
#include "po_man.h"
|
|
|
|
#include "r_data/colormaps.h"
|
2017-01-03 06:13:40 +00:00
|
|
|
#include "d_net.h"
|
|
|
|
#include "swrenderer/r_memory.h"
|
|
|
|
#include "swrenderer/drawers/r_draw.h"
|
|
|
|
#include "swrenderer/scene/r_3dfloors.h"
|
2017-01-11 19:42:39 +00:00
|
|
|
#include "swrenderer/scene/r_opaque_pass.h"
|
2017-01-03 18:25:00 +00:00
|
|
|
#include "swrenderer/scene/r_portal.h"
|
2017-01-03 06:13:40 +00:00
|
|
|
#include "swrenderer/line/r_wallsetup.h"
|
|
|
|
#include "swrenderer/line/r_walldraw.h"
|
2017-01-03 18:16:37 +00:00
|
|
|
#include "swrenderer/line/r_fogboundary.h"
|
2016-12-31 11:45:07 +00:00
|
|
|
#include "swrenderer/segments/r_drawsegment.h"
|
2017-01-11 14:41:42 +00:00
|
|
|
#include "swrenderer/things/r_visiblesprite.h"
|
2017-01-12 15:21:46 +00:00
|
|
|
#include "swrenderer/scene/r_light.h"
|
|
|
|
#include "swrenderer/scene/r_viewport.h"
|
2017-01-11 14:41:42 +00:00
|
|
|
|
2016-12-28 06:04:13 +00:00
|
|
|
namespace swrenderer
|
|
|
|
{
|
2017-01-26 07:01:44 +00:00
|
|
|
DrawSegmentList *DrawSegmentList::Instance()
|
2016-12-30 04:01:42 +00:00
|
|
|
{
|
2017-01-26 07:01:44 +00:00
|
|
|
static DrawSegmentList instance;
|
|
|
|
return &instance;
|
2016-12-30 04:01:42 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 07:01:44 +00:00
|
|
|
void DrawSegmentList::Deinit()
|
2016-12-30 04:01:42 +00:00
|
|
|
{
|
|
|
|
if (drawsegs != nullptr)
|
|
|
|
{
|
|
|
|
M_Free(drawsegs);
|
|
|
|
drawsegs = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-26 07:01:44 +00:00
|
|
|
void DrawSegmentList::Clear()
|
2016-12-28 06:04:13 +00:00
|
|
|
{
|
2016-12-30 04:01:42 +00:00
|
|
|
if (drawsegs == nullptr)
|
2016-12-28 06:04:13 +00:00
|
|
|
{
|
|
|
|
MaxDrawSegs = 256; // [RH] Default. Increased as needed.
|
2017-01-26 06:03:27 +00:00
|
|
|
firstdrawseg = drawsegs = (DrawSegment *)M_Malloc (MaxDrawSegs * sizeof(DrawSegment));
|
2016-12-28 06:04:13 +00:00
|
|
|
}
|
|
|
|
FirstInterestingDrawseg = 0;
|
|
|
|
InterestingDrawsegs.Clear ();
|
|
|
|
ds_p = drawsegs;
|
|
|
|
}
|
|
|
|
|
2017-01-26 07:01:44 +00:00
|
|
|
DrawSegment *DrawSegmentList::Add()
|
2016-12-30 04:01:42 +00:00
|
|
|
{
|
|
|
|
if (ds_p == &drawsegs[MaxDrawSegs])
|
|
|
|
{ // [RH] Grab some more drawsegs
|
|
|
|
size_t newdrawsegs = MaxDrawSegs ? MaxDrawSegs * 2 : 32;
|
|
|
|
ptrdiff_t firstofs = firstdrawseg - drawsegs;
|
2017-01-26 06:03:27 +00:00
|
|
|
drawsegs = (DrawSegment *)M_Realloc(drawsegs, newdrawsegs * sizeof(DrawSegment));
|
2016-12-30 04:01:42 +00:00
|
|
|
firstdrawseg = drawsegs + firstofs;
|
|
|
|
ds_p = drawsegs + MaxDrawSegs;
|
|
|
|
MaxDrawSegs = newdrawsegs;
|
|
|
|
DPrintf(DMSG_NOTIFY, "MaxDrawSegs increased to %zu\n", MaxDrawSegs);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ds_p++;
|
|
|
|
}
|
2016-12-28 06:04:13 +00:00
|
|
|
}
|