mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 07:11:54 +00:00
- moved RenderScene and RenderTranslucent to hwrenderer.
This commit is contained in:
parent
9b56f407dd
commit
24d6b23042
4 changed files with 102 additions and 98 deletions
|
@ -16,8 +16,6 @@ struct FDrawInfo : public HWDrawInfo
|
|||
void RenderPortal(HWPortal *p, bool stencil) override;
|
||||
|
||||
void CreateScene();
|
||||
void RenderScene(int recursion);
|
||||
void RenderTranslucent();
|
||||
void DrawScene(int drawmode) override;
|
||||
void ProcessScene(bool toscreen = false);
|
||||
void EndDrawScene(sector_t * viewsector);
|
||||
|
|
|
@ -67,7 +67,6 @@ CVAR(Bool, gl_texture, true, 0)
|
|||
CVAR(Bool, gl_no_skyclear, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
CVAR(Float, gl_mask_threshold, 0.5f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
CVAR(Float, gl_mask_sprite_threshold, 0.5f,CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
CVAR(Bool, gl_sort_textures, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
|
||||
|
||||
EXTERN_CVAR (Bool, cl_capfps)
|
||||
EXTERN_CVAR (Bool, r_deathcamera)
|
||||
|
@ -130,99 +129,6 @@ void FDrawInfo::CreateScene()
|
|||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// RenderScene
|
||||
//
|
||||
// Draws the current draw lists for the non GLSL renderer
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void FDrawInfo::RenderScene(int recursion)
|
||||
{
|
||||
const auto &vp = Viewpoint;
|
||||
RenderAll.Clock();
|
||||
|
||||
glDepthMask(true);
|
||||
if (!gl_no_skyclear) screen->mPortalState->RenderFirstSkyPortal(recursion, this);
|
||||
|
||||
screen->mLights->BindBase(gl_RenderState); // not needed for OpenGL but necessary for Vulkan command buffers to do it here!
|
||||
gl_RenderState.EnableFog(true);
|
||||
gl_RenderState.SetRenderStyle(STYLE_Source);
|
||||
|
||||
if (gl_sort_textures)
|
||||
{
|
||||
drawlists[GLDL_PLAINWALLS].SortWalls();
|
||||
drawlists[GLDL_PLAINFLATS].SortFlats();
|
||||
drawlists[GLDL_MASKEDWALLS].SortWalls();
|
||||
drawlists[GLDL_MASKEDFLATS].SortFlats();
|
||||
drawlists[GLDL_MASKEDWALLSOFS].SortWalls();
|
||||
}
|
||||
|
||||
// Part 1: solid geometry. This is set up so that there are no transparent parts
|
||||
glDepthFunc(GL_LESS);
|
||||
gl_RenderState.AlphaFunc(Alpha_GEqual, 0.f);
|
||||
gl_RenderState.ClearDepthBias();
|
||||
|
||||
gl_RenderState.EnableTexture(gl_texture);
|
||||
gl_RenderState.EnableBrightmap(true);
|
||||
drawlists[GLDL_PLAINWALLS].DrawWalls(this, gl_RenderState, false);
|
||||
drawlists[GLDL_PLAINFLATS].DrawFlats(this, gl_RenderState, false);
|
||||
|
||||
|
||||
// Part 2: masked geometry. This is set up so that only pixels with alpha>gl_mask_threshold will show
|
||||
gl_RenderState.AlphaFunc(Alpha_GEqual, gl_mask_threshold);
|
||||
drawlists[GLDL_MASKEDWALLS].DrawWalls(this, gl_RenderState, false);
|
||||
drawlists[GLDL_MASKEDFLATS].DrawFlats(this, gl_RenderState, false);
|
||||
|
||||
// Part 3: masked geometry with polygon offset. This list is empty most of the time so only waste time on it when in use.
|
||||
if (drawlists[GLDL_MASKEDWALLSOFS].Size() > 0)
|
||||
{
|
||||
gl_RenderState.SetDepthBias(-1, -128);
|
||||
drawlists[GLDL_MASKEDWALLSOFS].DrawWalls(this, gl_RenderState, false);
|
||||
gl_RenderState.ClearDepthBias();
|
||||
}
|
||||
|
||||
drawlists[GLDL_MODELS].Draw(this, gl_RenderState, false);
|
||||
|
||||
gl_RenderState.SetRenderStyle(STYLE_Translucent);
|
||||
|
||||
// Part 4: Draw decals (not a real pass)
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
DrawDecals(gl_RenderState, Decals[0]);
|
||||
|
||||
RenderAll.Unclock();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// RenderTranslucent
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void FDrawInfo::RenderTranslucent()
|
||||
{
|
||||
RenderAll.Clock();
|
||||
|
||||
// final pass: translucent stuff
|
||||
gl_RenderState.AlphaFunc(Alpha_GEqual, gl_mask_sprite_threshold);
|
||||
gl_RenderState.SetRenderStyle(STYLE_Translucent);
|
||||
|
||||
gl_RenderState.EnableBrightmap(true);
|
||||
drawlists[GLDL_TRANSLUCENTBORDER].Draw(this, gl_RenderState, true);
|
||||
glDepthMask(false);
|
||||
|
||||
drawlists[GLDL_TRANSLUCENT].DrawSorted(this, gl_RenderState);
|
||||
gl_RenderState.EnableBrightmap(false);
|
||||
|
||||
|
||||
gl_RenderState.AlphaFunc(Alpha_GEqual, 0.5f);
|
||||
glDepthMask(true);
|
||||
|
||||
RenderAll.Unclock();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// gl_drawscene - this function renders the scene from the current
|
||||
|
@ -265,7 +171,10 @@ void FDrawInfo::DrawScene(int drawmode)
|
|||
CreateScene();
|
||||
}
|
||||
|
||||
RenderScene(recursion);
|
||||
glDepthMask(true);
|
||||
if (!gl_no_skyclear) screen->mPortalState->RenderFirstSkyPortal(recursion, this);
|
||||
|
||||
RenderScene(gl_RenderState);
|
||||
|
||||
if (applySSAO && gl_RenderState.GetPassType() == GBUFFER_PASS)
|
||||
{
|
||||
|
@ -283,7 +192,7 @@ void FDrawInfo::DrawScene(int drawmode)
|
|||
recursion++;
|
||||
screen->mPortalState->EndFrame(this);
|
||||
recursion--;
|
||||
RenderTranslucent();
|
||||
RenderTranslucent(gl_RenderState);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
@ -37,10 +37,12 @@
|
|||
#include "hwrenderer/utility/hw_clock.h"
|
||||
#include "hwrenderer/utility/hw_cvars.h"
|
||||
#include "hwrenderer/data/hw_viewpointbuffer.h"
|
||||
#include "hwrenderer/dynlights/hw_lightbuffer.h"
|
||||
#include "hw_clipper.h"
|
||||
|
||||
EXTERN_CVAR(Float, r_visibility)
|
||||
CVAR(Bool, gl_bandedswlight, false, CVAR_ARCHIVE)
|
||||
CVAR(Bool, gl_sort_textures, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
|
||||
sector_t * hw_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool back);
|
||||
|
||||
|
@ -420,3 +422,95 @@ GLDecal *HWDrawInfo::AddDecal(bool onmirror)
|
|||
return decal;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// RenderScene
|
||||
//
|
||||
// Draws the current draw lists for the non GLSL renderer
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void HWDrawInfo::RenderScene(FRenderState &state)
|
||||
{
|
||||
const auto &vp = Viewpoint;
|
||||
RenderAll.Clock();
|
||||
|
||||
state.SetDepthMask(true);
|
||||
|
||||
screen->mLights->BindBase(state); // not needed for OpenGL but necessary for Vulkan command buffers to do it here!
|
||||
state.EnableFog(true);
|
||||
state.SetRenderStyle(STYLE_Source);
|
||||
|
||||
if (gl_sort_textures)
|
||||
{
|
||||
drawlists[GLDL_PLAINWALLS].SortWalls();
|
||||
drawlists[GLDL_PLAINFLATS].SortFlats();
|
||||
drawlists[GLDL_MASKEDWALLS].SortWalls();
|
||||
drawlists[GLDL_MASKEDFLATS].SortFlats();
|
||||
drawlists[GLDL_MASKEDWALLSOFS].SortWalls();
|
||||
}
|
||||
|
||||
// Part 1: solid geometry. This is set up so that there are no transparent parts
|
||||
state.SetDepthFunc(DF_Less);
|
||||
state.AlphaFunc(Alpha_GEqual, 0.f);
|
||||
state.ClearDepthBias();
|
||||
|
||||
state.EnableTexture(gl_texture);
|
||||
state.EnableBrightmap(true);
|
||||
drawlists[GLDL_PLAINWALLS].DrawWalls(this, state, false);
|
||||
drawlists[GLDL_PLAINFLATS].DrawFlats(this, state, false);
|
||||
|
||||
|
||||
// Part 2: masked geometry. This is set up so that only pixels with alpha>gl_mask_threshold will show
|
||||
state.AlphaFunc(Alpha_GEqual, gl_mask_threshold);
|
||||
drawlists[GLDL_MASKEDWALLS].DrawWalls(this, state, false);
|
||||
drawlists[GLDL_MASKEDFLATS].DrawFlats(this, state, false);
|
||||
|
||||
// Part 3: masked geometry with polygon offset. This list is empty most of the time so only waste time on it when in use.
|
||||
if (drawlists[GLDL_MASKEDWALLSOFS].Size() > 0)
|
||||
{
|
||||
state.SetDepthBias(-1, -128);
|
||||
drawlists[GLDL_MASKEDWALLSOFS].DrawWalls(this, state, false);
|
||||
state.ClearDepthBias();
|
||||
}
|
||||
|
||||
drawlists[GLDL_MODELS].Draw(this, state, false);
|
||||
|
||||
state.SetRenderStyle(STYLE_Translucent);
|
||||
|
||||
// Part 4: Draw decals (not a real pass)
|
||||
state.SetDepthFunc(DF_LEqual);
|
||||
DrawDecals(state, Decals[0]);
|
||||
|
||||
RenderAll.Unclock();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// RenderTranslucent
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void HWDrawInfo::RenderTranslucent(FRenderState &state)
|
||||
{
|
||||
RenderAll.Clock();
|
||||
|
||||
// final pass: translucent stuff
|
||||
state.AlphaFunc(Alpha_GEqual, gl_mask_sprite_threshold);
|
||||
state.SetRenderStyle(STYLE_Translucent);
|
||||
|
||||
state.EnableBrightmap(true);
|
||||
drawlists[GLDL_TRANSLUCENTBORDER].Draw(this, state, true);
|
||||
state.SetDepthMask(false);
|
||||
|
||||
drawlists[GLDL_TRANSLUCENT].DrawSorted(this, state);
|
||||
state.EnableBrightmap(false);
|
||||
|
||||
|
||||
state.AlphaFunc(Alpha_GEqual, 0.5f);
|
||||
state.SetDepthMask(true);
|
||||
|
||||
RenderAll.Unclock();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -305,6 +305,9 @@ public:
|
|||
void SetViewArea();
|
||||
int SetFullbrightFlags(player_t *player);
|
||||
|
||||
void RenderScene(FRenderState &state);
|
||||
void RenderTranslucent(FRenderState &state);
|
||||
|
||||
bool DoOneSectorUpper(subsector_t * subsec, float planez, area_t in_area);
|
||||
bool DoOneSectorLower(subsector_t * subsec, float planez, area_t in_area);
|
||||
bool DoFakeBridge(subsector_t * subsec, float planez, area_t in_area);
|
||||
|
|
Loading…
Reference in a new issue