mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-12-12 13:21:51 +00:00
- fix null drawers
- slightly better renderstyle drawer selection
This commit is contained in:
parent
d724b623d1
commit
0cb3605c70
5 changed files with 32 additions and 10 deletions
|
@ -17,6 +17,7 @@ class PolyFrameBuffer : public SystemBaseFrameBuffer
|
|||
public:
|
||||
RenderMemory *GetFrameMemory() { return &mFrameMemory; }
|
||||
PolyRenderState *GetRenderState() { return mRenderState.get(); }
|
||||
DCanvas *GetCanvas() { return mCanvas.get(); }
|
||||
const DrawerCommandQueuePtr &GetDrawCommands();
|
||||
void FlushDrawCommands();
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "hwrenderer/data/flatvertices.h"
|
||||
#include "hwrenderer/data/hw_viewpointbuffer.h"
|
||||
#include "hwrenderer/data/shaderuniforms.h"
|
||||
#include "swrenderer/r_swcolormaps.h"
|
||||
|
||||
static PolyDrawMode dtToDrawMode[] =
|
||||
{
|
||||
|
@ -79,6 +80,7 @@ void PolyRenderState::SetDepthRange(float min, float max)
|
|||
|
||||
void PolyRenderState::SetColorMask(bool r, bool g, bool b, bool a)
|
||||
{
|
||||
args.SetWriteColor(r || g || b || a);
|
||||
}
|
||||
|
||||
void PolyRenderState::SetStencil(int offs, int op, int flags)
|
||||
|
@ -113,6 +115,8 @@ void PolyRenderState::SetScissor(int x, int y, int w, int h)
|
|||
|
||||
void PolyRenderState::SetViewport(int x, int y, int w, int h)
|
||||
{
|
||||
auto fb = GetPolyFrameBuffer();
|
||||
PolyTriangleDrawer::SetViewport(fb->GetDrawCommands(), x, y, w, h, fb->GetCanvas());
|
||||
}
|
||||
|
||||
void PolyRenderState::EnableDepthTest(bool on)
|
||||
|
@ -138,7 +142,10 @@ void PolyRenderState::Apply()
|
|||
|
||||
args.SetStencilTest(false);
|
||||
args.SetWriteStencil(false);
|
||||
args.SetNoColormap();
|
||||
|
||||
FColormap cm;
|
||||
cm.Clear();
|
||||
args.SetLight(GetColorTable(cm), (int)(mLightParms[3] * 255.0f), mViewpointUniforms->mGlobVis, true);
|
||||
|
||||
args.SetColor(MAKEARGB(
|
||||
static_cast<uint32_t>(mStreamData.uVertexColor.W * 255.0f + 0.5f),
|
||||
|
@ -153,6 +160,14 @@ void PolyRenderState::Apply()
|
|||
{
|
||||
DCanvas *texcanvas = base->GetImage(mMaterial);
|
||||
args.SetTexture(texcanvas->GetPixels(), texcanvas->GetHeight(), texcanvas->GetWidth());
|
||||
|
||||
if (mRenderStyle == LegacyRenderStyles[STYLE_Normal])
|
||||
args.SetStyle(TriBlendMode::Normal);
|
||||
else if (mRenderStyle == LegacyRenderStyles[STYLE_Add])
|
||||
args.SetStyle(TriBlendMode::Add);
|
||||
else if (mRenderStyle == LegacyRenderStyles[STYLE_Translucent])
|
||||
args.SetStyle(TriBlendMode::Translucent);
|
||||
else
|
||||
args.SetStyle(TriBlendMode::Opaque);
|
||||
}
|
||||
else
|
||||
|
@ -173,10 +188,10 @@ void PolyRenderState::Bind(PolyDataBuffer *buffer, uint32_t offset, uint32_t len
|
|||
{
|
||||
if (buffer->bindingpoint == VIEWPOINT_BINDINGPOINT)
|
||||
{
|
||||
HWViewpointUniforms *uniforms = reinterpret_cast<HWViewpointUniforms*>(static_cast<uint8_t*>(buffer->Memory()) + offset);
|
||||
mViewpointUniforms = reinterpret_cast<HWViewpointUniforms*>(static_cast<uint8_t*>(buffer->Memory()) + offset);
|
||||
|
||||
Mat4f viewToProj = Mat4f::FromValues(uniforms->mProjectionMatrix.get());
|
||||
Mat4f worldToView = Mat4f::FromValues(uniforms->mViewMatrix.get());
|
||||
Mat4f viewToProj = Mat4f::FromValues(mViewpointUniforms->mProjectionMatrix.get());
|
||||
Mat4f worldToView = Mat4f::FromValues(mViewpointUniforms->mViewMatrix.get());
|
||||
|
||||
auto fb = GetPolyFrameBuffer();
|
||||
PolyTriangleDrawer::SetTransform(fb->GetDrawCommands(), fb->GetFrameMemory()->NewObject<Mat4f>(viewToProj * worldToView), nullptr);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "hwrenderer/scene/hw_renderstate.h"
|
||||
#include "hwrenderer/textures/hw_material.h"
|
||||
|
||||
class PolyRenderPassSetup;
|
||||
struct HWViewpointUniforms;
|
||||
|
||||
class PolyRenderState : public FRenderState
|
||||
{
|
||||
|
@ -45,6 +45,8 @@ public:
|
|||
private:
|
||||
void Apply();
|
||||
|
||||
HWViewpointUniforms *mViewpointUniforms = nullptr;
|
||||
|
||||
bool mDepthClamp = true;
|
||||
PolyDrawArgs args;
|
||||
};
|
||||
|
|
|
@ -2250,10 +2250,10 @@ void(*ScreenTriangle::RectDrawers32[])(const void *, int, int, int, const RectDr
|
|||
|
||||
void(*ScreenTriangle::TriangleDrawers[])(const TriDrawTriangleArgs *args, PolyTriangleThreadData *thread, int16_t *edges, int topY, int bottomY) =
|
||||
{
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
&DrawTriangle<TriScreenDrawerModes::TriangleOpt0>,
|
||||
&DrawTriangle<TriScreenDrawerModes::TriangleOpt1>,
|
||||
&DrawTriangle<TriScreenDrawerModes::TriangleOpt2>,
|
||||
&DrawTriangle<TriScreenDrawerModes::TriangleOpt3>,
|
||||
&DrawTriangle<TriScreenDrawerModes::TriangleOpt4>,
|
||||
&DrawTriangle<TriScreenDrawerModes::TriangleOpt5>,
|
||||
&DrawTriangle<TriScreenDrawerModes::TriangleOpt6>,
|
||||
|
|
|
@ -223,6 +223,10 @@ namespace TriScreenDrawerModes
|
|||
SWTRI_WriteStencil = 16
|
||||
};
|
||||
|
||||
struct TriangleOpt0 { static const int Flags = 0; };
|
||||
struct TriangleOpt1 { static const int Flags = 1; };
|
||||
struct TriangleOpt2 { static const int Flags = 2; };
|
||||
struct TriangleOpt3 { static const int Flags = 3; };
|
||||
struct TriangleOpt4 { static const int Flags = 4; };
|
||||
struct TriangleOpt5 { static const int Flags = 5; };
|
||||
struct TriangleOpt6 { static const int Flags = 6; };
|
||||
|
|
Loading…
Reference in a new issue