rename and slight cleanup

This commit is contained in:
Alug committed 2024-10-26 19:29:46 +02:00
1 parent c59e8387ca
commit 9dd45440c0
3 files changed
+36 -24

No files matched your search

+15 -16
View File
@@ -1535,7 +1535,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap);
}
if ((gr_midtexture && HWR_BlendMidtextureSurface(&Surf)) || gr_portal == GRPORTAL_STENCIL || gr_portal == GRPORTAL_DEPTH || gl_drawing_stencil)
if ((gr_midtexture && HWR_BlendMidtextureSurface(&Surf)) || gl_portal_state == GRPORTAL_STENCIL || gl_portal_state == GRPORTAL_DEPTH || gl_drawing_stencil)
{
sector_t *front, *back;
INT32 repeats;
@@ -1552,7 +1552,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
if (gr_sidedef->repeatcnt)
repeats = 1 + gr_sidedef->repeatcnt;
else if (gr_linedef->flags & ML_EFFECT5 || gr_portal == GRPORTAL_STENCIL || gr_portal == GRPORTAL_DEPTH)
else if (gr_linedef->flags & ML_EFFECT5 || gl_portal_state == GRPORTAL_STENCIL || gl_portal_state == GRPORTAL_DEPTH)
{
fixed_t high, low;
@@ -2291,7 +2291,7 @@ static void HWR_AddLine(seg_t *line)
return;
}
if (gr_portal == GRPORTAL_STENCIL || gr_portal == GRPORTAL_DEPTH)
if (gl_portal_state == GRPORTAL_STENCIL || gl_portal_state == GRPORTAL_DEPTH)
goto doaddline;
if (line->linedef->special == 40)
@@ -2304,9 +2304,9 @@ static void HWR_AddLine(seg_t *line)
line2 = P_FindSpecialLineFromTag(40, line->linedef->tag, line2);
if (line2 >= 0) // found it!
{
if (gr_portal == GRPORTAL_SEARCH)
if (gl_portal_state == GRPORTAL_SEARCH)
HWR_Portal_Add2Lines(line->linedef-lines, line2, line);
else if (gr_portal == GRPORTAL_INSIDE)
else if (gl_portal_state == GRPORTAL_INSIDE)
dont_draw = true;
}
}
@@ -2338,7 +2338,7 @@ doaddline:
return;
}
if (gr_portal != GRPORTAL_SEARCH && !dont_draw)// no need to do this during the portal check
if (gl_portal_state != GRPORTAL_SEARCH && !dont_draw)// no need to do this during the portal check
HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D
return;
@@ -2804,7 +2804,7 @@ static void HWR_Subsector(size_t num)
gr_frontsector = R_FakeFlat(gr_frontsector, &tempsec, &floorlightlevel,
&ceilinglightlevel, false);
if (gr_portal == GRPORTAL_SEARCH)
if (gl_portal_state == GRPORTAL_SEARCH)
{
skipSprites = true;
goto skip_stuff_for_portals;// hopefully this goto is okay
@@ -5029,19 +5029,18 @@ void HWR_SetStencilState(int state, int level)
// Renders the current viewpoint, though takes portal arguments for recursive portals.
void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *player, int stencil_level, boolean allow_portals)
{
gl_portallist_t portallist;
gl_portal_t *portal;
const boolean skybox = (skyboxmo[0] && cv_skybox.value);
const boolean useportals = cv_grportals.value && gr_maphasportals && allow_portals;
portallist.base = portallist.cap = NULL;
HWR_Portal_InitList();
if (useportals && stencil_level < cv_maxportals.value) // if recursion limit is not reached
{
// search for portals in current frame
currentportallist = &portallist;
gr_portal = GRPORTAL_SEARCH;
HWR_SetPortalState(GRPORTAL_SEARCH);
HWR_ClearClipper();
@@ -5060,10 +5059,10 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl
{
HWR_RenderPortal(portal, rootportal, fpov, player, stencil_level);
}
gr_portal = GRPORTAL_INSIDE;// when portal walls are encountered in following bsp traversal, nothing should be drawn
HWR_SetPortalState(GRPORTAL_INSIDE); // when portal walls are encountered in following bsp traversal, nothing should be drawn
}
else
gr_portal = GRPORTAL_OFF;// there may be portals and they need to be drawn as regural walls
HWR_SetPortalState(GRPORTAL_OFF); // there may be portals and they need to be drawn as regural walls
// draw normal things in current frame in current incremented stencil buffer area
HWR_SetStencilState(HWR_STENCIL_NORMAL, stencil_level);
@@ -5103,16 +5102,16 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl
// HAYA: Save the old portal state, and turn portals off while normally rendering the BSP tree.
// This fixes specific effects not working, such as horizon lines.
int oldgl_portal_state = gr_portal;
SINT8 oldgl_portal_state = gl_portal_state;
if (gr_portal != GRPORTAL_OFF) // if we already haven't hit the recursion limit or we already ended our portal shenanigans
gr_portal = GRPORTAL_INSIDE; // TURN IT OFF
if (gl_portal_state != GRPORTAL_OFF) // if we already haven't hit the recursion limit or we already ended our portal shenanigans
HWR_SetPortalState(GRPORTAL_INSIDE); // TURN IT OFF
// Recursively "render" the BSP tree.
HWR_RenderBSPNode((INT32)numnodes-1);
// woo we back
gr_portal = oldgl_portal_state;
HWR_SetPortalState(oldgl_portal_state);
if (allow_portals) // looks weird, but this is only true when its not skybox rendering skipping precip in skyboxes like software does
HWR_AddPrecipitationSprites();
+6 -4
View File
@@ -28,7 +28,9 @@
#include "hw_main.h"
#include "hw_portal.h"
SINT8 gr_portal = GRPORTAL_OFF;
SINT8 gl_portal_state = GRPORTAL_OFF;
gl_portallist_t portallist;
gl_portallist_t *currentportallist;
// More precise version of R_PointToAngle2 using floats and atan2.
@@ -184,7 +186,7 @@ void HWR_RenderPortalSeg(gl_portal_t* portal, SINT8 state)
{
gl_drawing_stencil = true; // do not draw outside of the stencil buffer, idiot.
// set our portal state and prepare to render the seg
gr_portal = state;
HWR_SetPortalState(state);
gr_curline = portal->seg;
gr_frontsector = portal->seg->frontsector;
gr_backsector = portal->seg->backsector;
@@ -231,10 +233,10 @@ void HWR_RenderPortal(gl_portal_t* portal, gl_portal_t* rootportal, const float
HWR_RenderPortalSeg(portal, GRPORTAL_DEPTH);
}
void HWR_FreePortalList(gl_portallist_t portallist)
void HWR_FreePortalList(gl_portallist_t freelist)
{
// free memory from portal list allocated by calls to Add2Lines
gl_portal_t *gl_portal_temp = portallist.base;
gl_portal_t *gl_portal_temp = freelist.base;
while (gl_portal_temp)
{
gl_portal_t *nextportal = gl_portal_temp->next;
+15 -4
View File
@@ -8,8 +8,8 @@
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file r_portal.h
/// \brief Software renderer portal struct, functions, linked list extern.
/// \file hw_portal.h
/// \brief OpenGL renderer portal struct, functions, linked list extern.
#ifndef __HW_PORTAL__
#define __HW_PORTAL__
@@ -31,8 +31,6 @@ enum
GRPORTAL_INSIDE,
};
extern SINT8 gr_portal;
typedef struct gl_portal_s
{
struct gl_portal_s *next;
@@ -57,9 +55,22 @@ typedef struct gl_portallist_s
gl_portal_t *cap;
} gl_portallist_t;
extern SINT8 gl_portal_state;
// new thing
extern gl_portallist_t portallist;
extern gl_portallist_t *currentportallist;
static inline void HWR_Portal_InitList (void)
{
portallist.base = portallist.cap = NULL;
}
static inline void HWR_SetPortalState (SINT8 state)
{
gl_portal_state = state;
}
// Adds an entry to the clipper for portal rendering
void HWR_PortalClipping(gl_portal_t *portal);