mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-29 07:12:36 +00:00
- added support code for indexed rendering from Raze.
This commit is contained in:
parent
2be5dc9238
commit
c65fd80fd2
6 changed files with 39 additions and 12 deletions
|
@ -58,7 +58,7 @@ public:
|
||||||
void Swap();
|
void Swap();
|
||||||
bool IsHWGammaActive() const { return HWGammaActive; }
|
bool IsHWGammaActive() const { return HWGammaActive; }
|
||||||
|
|
||||||
void SetVSync(bool vsync);
|
void SetVSync(bool vsync) override;
|
||||||
|
|
||||||
void Draw2D() override;
|
void Draw2D() override;
|
||||||
void PostProcessScene(bool swscene, int fixedcm, float flash, const std::function<void()> &afterBloomDrawEndScene2D) override;
|
void PostProcessScene(bool swscene, int fixedcm, float flash, const std::function<void()> &afterBloomDrawEndScene2D) override;
|
||||||
|
|
|
@ -329,12 +329,24 @@ void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translatio
|
||||||
|
|
||||||
if (base->BindOrCreate(tex->GetTexture(), 0, clampmode, translation, layer->scaleFlags))
|
if (base->BindOrCreate(tex->GetTexture(), 0, clampmode, translation, layer->scaleFlags))
|
||||||
{
|
{
|
||||||
for (int i = 1; i<numLayers; i++)
|
if (!(layer->scaleFlags & CTF_Indexed))
|
||||||
{
|
{
|
||||||
auto systex = static_cast<FHardwareTexture*>(mat->GetLayer(i, 0, &layer));
|
for (int i = 1; i < numLayers; i++)
|
||||||
// fixme: Upscale flags must be disabled for certain layers.
|
{
|
||||||
systex->BindOrCreate(layer->layerTexture, i, clampmode, 0, layer->scaleFlags);
|
auto systex = static_cast<FHardwareTexture*>(mat->GetLayer(i, 0, &layer));
|
||||||
maxbound = i;
|
// fixme: Upscale flags must be disabled for certain layers.
|
||||||
|
systex->BindOrCreate(layer->layerTexture, i, clampmode, 0, layer->scaleFlags);
|
||||||
|
maxbound = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 1; i < 3; i++)
|
||||||
|
{
|
||||||
|
auto systex = static_cast<FHardwareTexture*>(mat->GetLayer(i, translation, &layer));
|
||||||
|
systex->Bind(i, false);
|
||||||
|
maxbound = i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// unbind everything from the last texture that's still active
|
// unbind everything from the last texture that's still active
|
||||||
|
|
|
@ -56,7 +56,7 @@ public:
|
||||||
virtual void Resize(size_t newsize) = 0;
|
virtual void Resize(size_t newsize) = 0;
|
||||||
virtual void Map() {} // Only needed by old OpenGL but this needs to be in the interface.
|
virtual void Map() {} // Only needed by old OpenGL but this needs to be in the interface.
|
||||||
virtual void Unmap() {}
|
virtual void Unmap() {}
|
||||||
void *Memory() { assert(map); return map; }
|
void *Memory() { return map; }
|
||||||
size_t Size() { return buffersize; }
|
size_t Size() { return buffersize; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "matrix.h"
|
#include "matrix.h"
|
||||||
#include "hw_material.h"
|
#include "hw_material.h"
|
||||||
#include "texmanip.h"
|
#include "texmanip.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
struct FColormap;
|
struct FColormap;
|
||||||
class IVertexBuffer;
|
class IVertexBuffer;
|
||||||
|
@ -290,7 +291,7 @@ public:
|
||||||
mStreamData.uGradientBottomPlane = { 0.0f, 0.0f, 0.0f, 0.0f };
|
mStreamData.uGradientBottomPlane = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
mStreamData.uSplitTopPlane = { 0.0f, 0.0f, 0.0f, 0.0f };
|
mStreamData.uSplitTopPlane = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
mStreamData.uSplitBottomPlane = { 0.0f, 0.0f, 0.0f, 0.0f };
|
mStreamData.uSplitBottomPlane = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
mStreamData.uDynLightColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
mStreamData.uDynLightColor = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||||
mStreamData.uDetailParms = { 0.0f, 0.0f, 0.0f, 0.0f };
|
mStreamData.uDetailParms = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
#ifdef NPOT_EMULATION
|
#ifdef NPOT_EMULATION
|
||||||
mStreamData.uNpotEmulation = { 0,0 };
|
mStreamData.uNpotEmulation = { 0,0 };
|
||||||
|
@ -459,7 +460,15 @@ public:
|
||||||
|
|
||||||
void SetDynLight(float r, float g, float b)
|
void SetDynLight(float r, float g, float b)
|
||||||
{
|
{
|
||||||
mStreamData.uDynLightColor = { r, g, b, 0.0f };
|
mStreamData.uDynLightColor.X = r;
|
||||||
|
mStreamData.uDynLightColor.Y = g;
|
||||||
|
mStreamData.uDynLightColor.Z = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetScreenFade(float f)
|
||||||
|
{
|
||||||
|
// This component is otherwise unused.
|
||||||
|
mStreamData.uDynLightColor.W = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetObjectColor(PalEntry pe)
|
void SetObjectColor(PalEntry pe)
|
||||||
|
@ -569,7 +578,7 @@ public:
|
||||||
mMaterial.mChanged = true;
|
mMaterial.mChanged = true;
|
||||||
mTextureModeFlags = mat->GetLayerFlags();
|
mTextureModeFlags = mat->GetLayerFlags();
|
||||||
auto scale = mat->GetDetailScale();
|
auto scale = mat->GetDetailScale();
|
||||||
mStreamData.uDetailParms = { scale.X, scale.Y, 0, 0 };
|
mStreamData.uDetailParms = { scale.X, scale.Y, 2, 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetMaterial(FGameTexture* tex, EUpscaleFlags upscalemask, int scaleflags, int clampmode, int translation, int overrideshader)
|
void SetMaterial(FGameTexture* tex, EUpscaleFlags upscalemask, int scaleflags, int clampmode, int translation, int overrideshader)
|
||||||
|
|
|
@ -277,7 +277,7 @@ const FDefaultShader defaultshaders[] =
|
||||||
{"Warp 2", "shaders/glsl/func_warp2.fp", "shaders/glsl/material_normal.fp", ""},
|
{"Warp 2", "shaders/glsl/func_warp2.fp", "shaders/glsl/material_normal.fp", ""},
|
||||||
{"Specular", "shaders/glsl/func_spec.fp", "shaders/glsl/material_specular.fp", "#define SPECULAR\n#define NORMALMAP\n"},
|
{"Specular", "shaders/glsl/func_spec.fp", "shaders/glsl/material_specular.fp", "#define SPECULAR\n#define NORMALMAP\n"},
|
||||||
{"PBR","shaders/glsl/func_pbr.fp", "shaders/glsl/material_pbr.fp", "#define PBR\n#define NORMALMAP\n"},
|
{"PBR","shaders/glsl/func_pbr.fp", "shaders/glsl/material_pbr.fp", "#define PBR\n#define NORMALMAP\n"},
|
||||||
{"Paletted", "shaders/glsl/func_paletted.fp", "shaders/glsl/material_nolight.fp", ""},
|
{"Paletted", "shaders/glsl/func_paletted.fp", "shaders/glsl/material_nolight.fp", "#define PALETTE_EMULATION\n"},
|
||||||
{"No Texture", "shaders/glsl/func_notexture.fp", "shaders/glsl/material_normal.fp", "#define NO_LAYERS\n"},
|
{"No Texture", "shaders/glsl/func_notexture.fp", "shaders/glsl/material_normal.fp", "#define NO_LAYERS\n"},
|
||||||
{"Basic Fuzz", "shaders/glsl/fuzz_standard.fp", "shaders/glsl/material_normal.fp", ""},
|
{"Basic Fuzz", "shaders/glsl/fuzz_standard.fp", "shaders/glsl/material_normal.fp", ""},
|
||||||
{"Smooth Fuzz", "shaders/glsl/fuzz_smooth.fp", "shaders/glsl/material_normal.fp", ""},
|
{"Smooth Fuzz", "shaders/glsl/fuzz_smooth.fp", "shaders/glsl/material_normal.fp", ""},
|
||||||
|
|
|
@ -130,6 +130,7 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state)
|
||||||
vb.UploadData(&vertices[0], vertices.Size(), &indices[0], indices.Size());
|
vb.UploadData(&vertices[0], vertices.Size(), &indices[0], indices.Size());
|
||||||
state.SetVertexBuffer(&vb);
|
state.SetVertexBuffer(&vb);
|
||||||
state.EnableFog(false);
|
state.EnableFog(false);
|
||||||
|
state.SetScreenFade(drawer->screenFade);
|
||||||
|
|
||||||
for(auto &cmd : commands)
|
for(auto &cmd : commands)
|
||||||
{
|
{
|
||||||
|
@ -168,13 +169,17 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state)
|
||||||
}
|
}
|
||||||
state.SetFog(cmd.mColor1, 0);
|
state.SetFog(cmd.mColor1, 0);
|
||||||
state.SetColor(1, 1, 1, 1, cmd.mDesaturate);
|
state.SetColor(1, 1, 1, 1, cmd.mDesaturate);
|
||||||
|
state.SetSoftLightLevel(cmd.mLightLevel);
|
||||||
|
state.SetLightParms(0, 0);
|
||||||
|
|
||||||
state.AlphaFunc(Alpha_GEqual, 0.f);
|
state.AlphaFunc(Alpha_GEqual, 0.f);
|
||||||
|
|
||||||
if (cmd.mTexture != nullptr && cmd.mTexture->isValid())
|
if (cmd.mTexture != nullptr && cmd.mTexture->isValid())
|
||||||
{
|
{
|
||||||
auto flags = cmd.mTexture->GetUseType() >= ETextureType::Special? UF_None : cmd.mTexture->GetUseType() == ETextureType::FontChar? UF_Font : UF_Texture;
|
auto flags = cmd.mTexture->GetUseType() >= ETextureType::Special? UF_None : cmd.mTexture->GetUseType() == ETextureType::FontChar? UF_Font : UF_Texture;
|
||||||
state.SetMaterial(cmd.mTexture, flags, 0, cmd.mFlags & F2DDrawer::DTF_Wrap ? CLAMP_NONE : CLAMP_XY_NOMIP, cmd.mTranslationId, -1);
|
|
||||||
|
auto scaleflags = cmd.mFlags & F2DDrawer::DTF_Indexed ? CTF_Indexed : 0;
|
||||||
|
state.SetMaterial(cmd.mTexture, flags, scaleflags, cmd.mFlags & F2DDrawer::DTF_Wrap ? CLAMP_NONE : CLAMP_XY_NOMIP, cmd.mTranslationId, -1);
|
||||||
state.EnableTexture(true);
|
state.EnableTexture(true);
|
||||||
|
|
||||||
// Canvas textures are stored upside down
|
// Canvas textures are stored upside down
|
||||||
|
@ -226,6 +231,7 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state)
|
||||||
state.EnableBrightmap(true);
|
state.EnableBrightmap(true);
|
||||||
state.SetTextureMode(TM_NORMAL);
|
state.SetTextureMode(TM_NORMAL);
|
||||||
state.EnableFog(false);
|
state.EnableFog(false);
|
||||||
|
state.SetScreenFade(1);
|
||||||
state.ResetColor();
|
state.ResetColor();
|
||||||
drawer->mIsFirstPass = false;
|
drawer->mIsFirstPass = false;
|
||||||
twoD.Unclock();
|
twoD.Unclock();
|
||||||
|
|
Loading…
Reference in a new issue