- started adding a SceneDrawer class to the OpenGL renderer.
This will eventually hold all the global variables for the rendering.
This commit is contained in:
parent
8e2ebe15fe
commit
0aa0db637c
11 changed files with 145 additions and 141 deletions
|
|
@ -38,31 +38,26 @@
|
|||
#include "gl/renderer/gl_renderer.h"
|
||||
#include "gl/data/gl_data.h"
|
||||
#include "gl/data/gl_vertexbuffer.h"
|
||||
#include "gl/scene/gl_clipper.h"
|
||||
#include "gl/scene/gl_scenedrawer.h"
|
||||
#include "gl/scene/gl_portal.h"
|
||||
#include "gl/scene/gl_wall.h"
|
||||
#include "gl/utility/gl_clock.h"
|
||||
|
||||
EXTERN_CVAR(Bool, gl_render_segs)
|
||||
|
||||
Clipper clipper;
|
||||
|
||||
|
||||
CVAR(Bool, gl_render_things, true, 0)
|
||||
CVAR(Bool, gl_render_walls, true, 0)
|
||||
CVAR(Bool, gl_render_flats, true, 0)
|
||||
|
||||
extern fixed_t viewx, viewy;
|
||||
|
||||
static void UnclipSubsector(subsector_t *sub)
|
||||
void GLSceneDrawer::UnclipSubsector(subsector_t *sub)
|
||||
{
|
||||
int count = sub->numlines;
|
||||
seg_t * seg = sub->firstline;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
angle_t startAngle = seg->v2->GetClipAngle();
|
||||
angle_t endAngle = seg->v1->GetClipAngle();
|
||||
angle_t startAngle = clipper.GetClipAngle(seg->v2);
|
||||
angle_t endAngle = clipper.GetClipAngle(seg->v1);
|
||||
|
||||
// Back side, i.e. backface culling - read: endAngle >= startAngle!
|
||||
if (startAngle-endAngle >= ANGLE_180)
|
||||
|
|
@ -82,11 +77,7 @@ static void UnclipSubsector(subsector_t *sub)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
// making these 2 variables global instead of passing them as function parameters is faster.
|
||||
static subsector_t *currentsubsector;
|
||||
static sector_t *currentsector;
|
||||
|
||||
static void AddLine (seg_t *seg, bool portalclip)
|
||||
void GLSceneDrawer::AddLine (seg_t *seg, bool portalclip)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
if (seg->linedef->Index() == 38)
|
||||
|
|
@ -95,7 +86,6 @@ static void AddLine (seg_t *seg, bool portalclip)
|
|||
}
|
||||
#endif
|
||||
|
||||
angle_t startAngle, endAngle;
|
||||
sector_t * backsector = NULL;
|
||||
sector_t bs;
|
||||
|
||||
|
|
@ -105,8 +95,8 @@ static void AddLine (seg_t *seg, bool portalclip)
|
|||
if (clipres == GLPortal::PClip_InFront) return;
|
||||
}
|
||||
|
||||
startAngle = seg->v2->GetClipAngle();
|
||||
endAngle = seg->v1->GetClipAngle();
|
||||
angle_t startAngle = clipper.GetClipAngle(seg->v2);
|
||||
angle_t endAngle = clipper.GetClipAngle(seg->v1);
|
||||
|
||||
// Back side, i.e. backface culling - read: endAngle >= startAngle!
|
||||
if (startAngle-endAngle<ANGLE_180)
|
||||
|
|
@ -202,7 +192,7 @@ static void AddLine (seg_t *seg, bool portalclip)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static void PolySubsector(subsector_t * sub)
|
||||
void GLSceneDrawer::PolySubsector(subsector_t * sub)
|
||||
{
|
||||
int count = sub->numlines;
|
||||
seg_t * line = sub->firstline;
|
||||
|
|
@ -226,7 +216,7 @@ static void PolySubsector(subsector_t * sub)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static void RenderPolyBSPNode (void *node)
|
||||
void GLSceneDrawer::RenderPolyBSPNode (void *node)
|
||||
{
|
||||
while (!((size_t)node & 1)) // Keep going until found a subsector
|
||||
{
|
||||
|
|
@ -259,7 +249,7 @@ static void RenderPolyBSPNode (void *node)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static void AddPolyobjs(subsector_t *sub)
|
||||
void GLSceneDrawer::AddPolyobjs(subsector_t *sub)
|
||||
{
|
||||
if (sub->BSP == NULL || sub->BSP->bDirty)
|
||||
{
|
||||
|
|
@ -287,7 +277,7 @@ static void AddPolyobjs(subsector_t *sub)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static inline void AddLines(subsector_t * sub, sector_t * sector)
|
||||
void GLSceneDrawer::AddLines(subsector_t * sub, sector_t * sector)
|
||||
{
|
||||
currentsector = sector;
|
||||
currentsubsector = sub;
|
||||
|
|
@ -331,7 +321,7 @@ inline bool PointOnLine(const DVector2 &pos, const line_t *line)
|
|||
return fabs(v) <= EQUAL_EPSILON;
|
||||
}
|
||||
|
||||
static inline void AddSpecialPortalLines(subsector_t * sub, sector_t * sector, line_t *line)
|
||||
void GLSceneDrawer::AddSpecialPortalLines(subsector_t * sub, sector_t * sector, line_t *line)
|
||||
{
|
||||
currentsector = sector;
|
||||
currentsubsector = sub;
|
||||
|
|
@ -359,9 +349,8 @@ static inline void AddSpecialPortalLines(subsector_t * sub, sector_t * sector, l
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static inline void RenderThings(subsector_t * sub, sector_t * sector)
|
||||
void GLSceneDrawer::RenderThings(subsector_t * sub, sector_t * sector)
|
||||
{
|
||||
|
||||
SetupSprite.Clock();
|
||||
sector_t * sec=sub->sector;
|
||||
// Handle all things in sector.
|
||||
|
|
@ -414,7 +403,7 @@ static inline void RenderThings(subsector_t * sub, sector_t * sector)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static void DoSubsector(subsector_t * sub)
|
||||
void GLSceneDrawer::DoSubsector(subsector_t * sub)
|
||||
{
|
||||
unsigned int i;
|
||||
sector_t * sector;
|
||||
|
|
@ -559,7 +548,7 @@ static void DoSubsector(subsector_t * sub)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void gl_RenderBSPNode (void *node)
|
||||
void GLSceneDrawer::RenderBSPNode (void *node)
|
||||
{
|
||||
if (numnodes == 0)
|
||||
{
|
||||
|
|
@ -574,7 +563,7 @@ void gl_RenderBSPNode (void *node)
|
|||
int side = R_PointOnSide(viewx, viewy, bsp);
|
||||
|
||||
// Recursively divide front space (toward the viewer).
|
||||
gl_RenderBSPNode (bsp->children[side]);
|
||||
RenderBSPNode (bsp->children[side]);
|
||||
|
||||
// Possibly divide back space (away from the viewer).
|
||||
side ^= 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue