mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-25 13:41:05 +00:00
- removed old RenderStyle management.
This commit is contained in:
parent
8ffeb7812f
commit
a3aaa5cc8b
12 changed files with 22 additions and 157 deletions
|
@ -1049,7 +1049,6 @@ set (PCH_SOURCES
|
|||
gl/renderer/gl_renderer.cpp
|
||||
gl/renderer/gl_renderstate.cpp
|
||||
gl/renderer/gl_renderbuffers.cpp
|
||||
gl/renderer/gl_lightdata.cpp
|
||||
gl/renderer/gl_postprocess.cpp
|
||||
gl/renderer/gl_postprocessstate.cpp
|
||||
gl/renderer/gl_stereo3d.cpp
|
||||
|
|
|
@ -1,91 +0,0 @@
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright(C) 2002-2016 Christoph Oelckers
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see http://www.gnu.org/licenses/
|
||||
//
|
||||
//--------------------------------------------------------------------------
|
||||
//
|
||||
/*
|
||||
** gl_light.cpp
|
||||
** Light level / fog management / dynamic lights
|
||||
**
|
||||
**/
|
||||
|
||||
#include "gl_load/gl_system.h"
|
||||
#include "gl_load/gl_interface.h"
|
||||
#include "hwrenderer/utility/hw_cvars.h"
|
||||
#include "gl/renderer/gl_lightdata.h"
|
||||
#include "gl/renderer/gl_renderstate.h"
|
||||
#include "gl/shaders/gl_shader.h"
|
||||
#include "gl/scene/gl_portal.h"
|
||||
#include "p_local.h"
|
||||
#include "r_sky.h"
|
||||
|
||||
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Sets render state to draw the given render style
|
||||
// includes: Texture mode, blend equation and blend mode
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void gl_GetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblending,
|
||||
int *tm, int *sb, int *db, int *be)
|
||||
{
|
||||
static int blendstyles[] = { GL_ZERO, GL_ONE, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR, };
|
||||
static int renderops[] = { 0, GL_FUNC_ADD, GL_FUNC_SUBTRACT, GL_FUNC_REVERSE_SUBTRACT, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1 };
|
||||
|
||||
int srcblend = blendstyles[style.SrcAlpha%STYLEALPHA_MAX];
|
||||
int dstblend = blendstyles[style.DestAlpha%STYLEALPHA_MAX];
|
||||
int blendequation = renderops[style.BlendOp&15];
|
||||
int texturemode = drawopaque? TM_OPAQUE : TM_NORMAL;
|
||||
|
||||
if (style.Flags & STYLEF_RedIsAlpha)
|
||||
{
|
||||
texturemode = TM_ALPHATEXTURE;
|
||||
}
|
||||
else if (style.Flags & STYLEF_ColorIsFixed)
|
||||
{
|
||||
texturemode = TM_STENCIL;
|
||||
}
|
||||
else if (style.Flags & STYLEF_InvertSource)
|
||||
{
|
||||
texturemode = TM_INVERSE;
|
||||
}
|
||||
|
||||
if (blendequation == -1)
|
||||
{
|
||||
srcblend = GL_DST_COLOR;
|
||||
dstblend = GL_ONE_MINUS_SRC_ALPHA;
|
||||
blendequation = GL_FUNC_ADD;
|
||||
}
|
||||
|
||||
if (allowcolorblending && srcblend == GL_SRC_ALPHA && dstblend == GL_ONE && blendequation == GL_FUNC_ADD)
|
||||
{
|
||||
srcblend = GL_SRC_COLOR;
|
||||
}
|
||||
|
||||
*tm = texturemode;
|
||||
*be = blendequation;
|
||||
*sb = srcblend;
|
||||
*db = dstblend;
|
||||
}
|
||||
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
#ifndef __GL_LIGHTDATA
|
||||
#define __GL_LIGHTDATA
|
||||
|
||||
#include "v_palette.h"
|
||||
#include "r_defs.h"
|
||||
#include "r_data/renderstyle.h"
|
||||
#include "hwrenderer/utility/hw_lighting.h"
|
||||
#include "r_data/colormaps.h"
|
||||
|
||||
void gl_GetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblending,
|
||||
int *tm, int *sb, int *db, int *be);
|
||||
|
||||
|
||||
#endif
|
|
@ -33,7 +33,6 @@
|
|||
#include "gl/system/gl_framebuffer.h"
|
||||
#include "hwrenderer/utility/hw_cvars.h"
|
||||
#include "gl/system/gl_debug.h"
|
||||
#include "gl/renderer/gl_lightdata.h"
|
||||
#include "gl/renderer/gl_renderstate.h"
|
||||
#include "gl/renderer/gl_renderbuffers.h"
|
||||
#include "gl/renderer/gl_renderer.h"
|
||||
|
|
|
@ -45,7 +45,6 @@
|
|||
#include "gl/scene/gl_portal.h"
|
||||
#include "gl/system/gl_debug.h"
|
||||
#include "gl/renderer/gl_renderer.h"
|
||||
#include "gl/renderer/gl_lightdata.h"
|
||||
#include "gl/renderer/gl_renderstate.h"
|
||||
#include "gl/renderer/gl_renderbuffers.h"
|
||||
#include "gl/data/gl_vertexbuffer.h"
|
||||
|
@ -457,13 +456,7 @@ void FGLRenderer::Draw2D(F2DDrawer *drawer)
|
|||
{
|
||||
|
||||
int gltrans = -1;
|
||||
int tm, sb, db, be;
|
||||
// The texture mode being returned here cannot be used, because the higher level code
|
||||
// already manipulated the data so that some cases will not be handled correctly.
|
||||
// Since we already get a proper mode from the calling code this doesn't really matter.
|
||||
gl_GetRenderStyle(cmd.mRenderStyle, false, false, &tm, &sb, &db, &be);
|
||||
gl_RenderState.BlendEquation(be);
|
||||
gl_RenderState.BlendFunc(sb, db);
|
||||
gl_RenderState.SetRenderStyle(cmd.mRenderStyle);
|
||||
gl_RenderState.EnableBrightmap(!(cmd.mRenderStyle.Flags & STYLEF_ColorIsFixed));
|
||||
gl_RenderState.EnableFog(2); // Special 2D mode 'fog'.
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#ifndef __GL_DRAWINFO_H
|
||||
#define __GL_DRAWINFO_H
|
||||
|
||||
#include "gl/renderer/gl_lightdata.h"
|
||||
#include "hwrenderer/scene/hw_drawlist.h"
|
||||
#include "hwrenderer/scene/hw_weapon.h"
|
||||
#include "hwrenderer/scene/hw_viewpointuniforms.h"
|
||||
|
|
|
@ -36,13 +36,13 @@
|
|||
#include "g_levellocals.h"
|
||||
|
||||
#include "gl_load/gl_interface.h"
|
||||
#include "gl/renderer/gl_lightdata.h"
|
||||
#include "gl/renderer/gl_renderer.h"
|
||||
#include "gl/renderer/gl_renderstate.h"
|
||||
#include "gl/data/gl_vertexbuffer.h"
|
||||
#include "hwrenderer/scene/hw_clipper.h"
|
||||
#include "gl/scene/gl_portal.h"
|
||||
#include "gl/data/gl_viewpointbuffer.h"
|
||||
#include "hwrenderer/utility/hw_lighting.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
#include "gl/system/gl_framebuffer.h"
|
||||
#include "gl/system/gl_debug.h"
|
||||
#include "hwrenderer/utility/hw_cvars.h"
|
||||
#include "gl/renderer/gl_lightdata.h"
|
||||
#include "gl/renderer/gl_renderstate.h"
|
||||
#include "gl/renderer/gl_renderbuffers.h"
|
||||
#include "gl/data/gl_vertexbuffer.h"
|
||||
|
@ -178,11 +177,6 @@ void FDrawInfo::RenderScene(int recursion)
|
|||
|
||||
|
||||
// Part 2: masked geometry. This is set up so that only pixels with alpha>gl_mask_threshold will show
|
||||
if (!gl_texture)
|
||||
{
|
||||
gl_RenderState.EnableTexture(true);
|
||||
gl_RenderState.SetTextureMode(TM_STENCIL);
|
||||
}
|
||||
gl_RenderState.AlphaFunc(Alpha_GEqual, gl_mask_threshold);
|
||||
drawlists[GLDL_MASKEDWALLS].DrawWalls(this, gl_RenderState, false);
|
||||
drawlists[GLDL_MASKEDFLATS].DrawFlats(this, gl_RenderState, false);
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
|
||||
#include "gl_load/gl_interface.h"
|
||||
#include "gl/data/gl_vertexbuffer.h"
|
||||
#include "gl/renderer/gl_lightdata.h"
|
||||
#include "gl/renderer/gl_renderer.h"
|
||||
#include "gl/renderer/gl_renderstate.h"
|
||||
#include "gl/scene/gl_drawinfo.h"
|
||||
|
|
|
@ -43,25 +43,15 @@
|
|||
#include "gl_load/gl_interface.h"
|
||||
#include "hwrenderer/utility/hw_cvars.h"
|
||||
#include "hwrenderer/scene/hw_drawstructs.h"
|
||||
#include "gl/renderer/gl_lightdata.h"
|
||||
#include "gl/renderer/gl_renderstate.h"
|
||||
#include "gl/renderer/gl_renderer.h"
|
||||
#include "gl/scene/gl_drawinfo.h"
|
||||
#include "gl/models/gl_models.h"
|
||||
#include "gl/dynlights/gl_lightbuffer.h"
|
||||
#include "hwrenderer/utility/hw_lighting.h"
|
||||
|
||||
extern uint32_t r_renderercaps;
|
||||
|
||||
void gl_SetRenderStyle(FRenderStyle style, bool drawopaque, bool allowcolorblending)
|
||||
{
|
||||
int tm, sb, db, be;
|
||||
|
||||
gl_GetRenderStyle(style, drawopaque, allowcolorblending, &tm, &sb, &db, &be);
|
||||
gl_RenderState.BlendEquation(be);
|
||||
gl_RenderState.BlendFunc(sb, db);
|
||||
gl_RenderState.SetTextureMode(tm);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
@ -87,10 +77,16 @@ void FDrawInfo::DrawSprite(GLSprite *sprite, int pass)
|
|||
gl_RenderState.EnableBrightmap(false);
|
||||
}
|
||||
|
||||
gl_SetRenderStyle(RenderStyle, false,
|
||||
// The rest of the needed checks are done inside gl_SetRenderStyle
|
||||
sprite->trans > 1.f - FLT_EPSILON && gl_usecolorblending && !isFullbrightScene() && sprite->actor &&
|
||||
sprite->fullbright && sprite->gltexture && !sprite->gltexture->tex->GetTranslucency());
|
||||
// Optionally use STYLE_ColorBlend in place of STYLE_Add for fullbright items.
|
||||
if (RenderStyle == LegacyRenderStyles[STYLE_Add] && sprite->trans > 1.f - FLT_EPSILON &&
|
||||
gl_usecolorblending && !isFullbrightScene() && sprite->actor &&
|
||||
sprite->fullbright && sprite->gltexture && !sprite->gltexture->tex->GetTranslucency())
|
||||
{
|
||||
RenderStyle = LegacyRenderStyles[STYLE_ColorBlend];
|
||||
}
|
||||
|
||||
gl_RenderState.SetRenderStyle(RenderStyle);
|
||||
gl_RenderState.SetTextureMode(RenderStyle);
|
||||
|
||||
if (sprite->hw_styleflags == STYLEHW_NoAlphaTest)
|
||||
{
|
||||
|
@ -130,14 +126,9 @@ void FDrawInfo::DrawSprite(GLSprite *sprite, int pass)
|
|||
}
|
||||
else if (sprite->modelframe == nullptr)
|
||||
{
|
||||
int tm, sb, db, be;
|
||||
|
||||
// This still needs to set the texture mode. As blend mode it will always use GL_ONE/GL_ZERO
|
||||
gl_GetRenderStyle(RenderStyle, false, false, &tm, &sb, &db, &be);
|
||||
gl_RenderState.SetTextureMode(tm);
|
||||
|
||||
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||
glPolygonOffset(-1.0f, -128.0f);
|
||||
gl_RenderState.SetTextureMode(RenderStyle);
|
||||
gl_RenderState.SetDepthBias(-1, -128);
|
||||
}
|
||||
if (RenderStyle.BlendOp != STYLEOP_Shadow)
|
||||
{
|
||||
|
@ -252,8 +243,7 @@ void FDrawInfo::DrawSprite(GLSprite *sprite, int pass)
|
|||
}
|
||||
if (sprite->polyoffset)
|
||||
{
|
||||
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||
glPolygonOffset(-1.0f, -128.0f);
|
||||
gl_RenderState.SetDepthBias(-1, -128);
|
||||
}
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, sprite->vertexindex, 4);
|
||||
|
@ -285,19 +275,16 @@ void FDrawInfo::DrawSprite(GLSprite *sprite, int pass)
|
|||
if (pass==GLPASS_TRANSLUCENT)
|
||||
{
|
||||
gl_RenderState.EnableBrightmap(true);
|
||||
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
gl_RenderState.BlendEquation(GL_FUNC_ADD);
|
||||
gl_RenderState.SetRenderStyle(STYLE_Translucent);
|
||||
gl_RenderState.SetTextureMode(TM_NORMAL);
|
||||
if (sprite->actor != nullptr && (sprite->actor->renderflags & RF_SPRITETYPEMASK) == RF_FLATSPRITE)
|
||||
{
|
||||
glPolygonOffset(0.0f, 0.0f);
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
gl_RenderState.ClearDepthBias();
|
||||
}
|
||||
}
|
||||
else if (sprite->modelframe == nullptr)
|
||||
{
|
||||
glPolygonOffset(0.0f, 0.0f);
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
gl_RenderState.ClearDepthBias();
|
||||
}
|
||||
|
||||
gl_RenderState.SetObjectColor(0xffffffff);
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
|
||||
#include "gl_load/gl_interface.h"
|
||||
#include "hwrenderer/utility/hw_cvars.h"
|
||||
#include "gl/renderer/gl_lightdata.h"
|
||||
#include "gl/renderer/gl_renderstate.h"
|
||||
#include "gl/renderer/gl_renderer.h"
|
||||
#include "gl/data/gl_vertexbuffer.h"
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include "hwrenderer/utility/hw_cvars.h"
|
||||
#include "hwrenderer/scene/hw_weapon.h"
|
||||
#include "gl/renderer/gl_renderer.h"
|
||||
#include "gl/renderer/gl_lightdata.h"
|
||||
#include "gl/renderer/gl_renderstate.h"
|
||||
#include "gl/data/gl_vertexbuffer.h"
|
||||
#include "gl/scene/gl_drawinfo.h"
|
||||
|
@ -56,7 +55,8 @@ void FDrawInfo::DrawPSprite (HUDSprite *huds)
|
|||
{
|
||||
SetColor(huds->lightlevel, 0, huds->cm, huds->alpha, true);
|
||||
}
|
||||
gl_SetRenderStyle(huds->RenderStyle, false, false);
|
||||
gl_RenderState.SetRenderStyle(huds->RenderStyle);
|
||||
gl_RenderState.SetTextureMode(huds->RenderStyle);
|
||||
gl_RenderState.SetObjectColor(huds->ObjectColor);
|
||||
gl_RenderState.SetDynLight(huds->dynrgb[0], huds->dynrgb[1], huds->dynrgb[2]);
|
||||
gl_RenderState.EnableBrightmap(!(huds->RenderStyle.Flags & STYLEF_ColorIsFixed));
|
||||
|
@ -76,6 +76,7 @@ void FDrawInfo::DrawPSprite (HUDSprite *huds)
|
|||
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, huds->mx, 4);
|
||||
}
|
||||
|
||||
gl_RenderState.SetTextureMode(TM_NORMAL);
|
||||
gl_RenderState.AlphaFunc(Alpha_GEqual, gl_mask_sprite_threshold);
|
||||
gl_RenderState.SetObjectColor(0xffffffff);
|
||||
gl_RenderState.SetDynLight(0, 0, 0);
|
||||
|
|
Loading…
Reference in a new issue