mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-24 21:21:04 +00:00
Merge branch 'init_global_state' of https://github.com/dpjudas/zdoom
This commit is contained in:
commit
10550c4ef0
12 changed files with 77 additions and 8 deletions
|
@ -80,19 +80,44 @@ void FRenderState::Reset()
|
||||||
mDstBlend = GL_ONE_MINUS_SRC_ALPHA;
|
mDstBlend = GL_ONE_MINUS_SRC_ALPHA;
|
||||||
mAlphaThreshold = 0.5f;
|
mAlphaThreshold = 0.5f;
|
||||||
mBlendEquation = GL_FUNC_ADD;
|
mBlendEquation = GL_FUNC_ADD;
|
||||||
|
mModelMatrixEnabled = false;
|
||||||
|
mTextureMatrixEnabled = false;
|
||||||
mObjectColor = 0xffffffff;
|
mObjectColor = 0xffffffff;
|
||||||
mVertexBuffer = mCurrentVertexBuffer = NULL;
|
mVertexBuffer = mCurrentVertexBuffer = NULL;
|
||||||
mColormapState = CM_DEFAULT;
|
mColormapState = CM_DEFAULT;
|
||||||
|
mSoftLight = 0;
|
||||||
|
mLightParms[0] = mLightParms[1] = mLightParms[2] = 0.0f;
|
||||||
mLightParms[3] = -1.f;
|
mLightParms[3] = -1.f;
|
||||||
mSpecialEffect = EFF_NONE;
|
mSpecialEffect = EFF_NONE;
|
||||||
mClipHeight = 0.f;
|
mClipHeight = 0.f;
|
||||||
mClipHeightDirection = 0.f;
|
mClipHeightDirection = 0.f;
|
||||||
|
mShaderTimer = 0.0f;
|
||||||
ClearClipSplit();
|
ClearClipSplit();
|
||||||
|
|
||||||
stSrcBlend = stDstBlend = -1;
|
stSrcBlend = stDstBlend = -1;
|
||||||
stBlendEquation = -1;
|
stBlendEquation = -1;
|
||||||
stAlphaThreshold = -1.f;
|
stAlphaThreshold = -1.f;
|
||||||
|
stAlphaTest = 0;
|
||||||
mLastDepthClamp = true;
|
mLastDepthClamp = true;
|
||||||
|
mInterpolationFactor = 0.0f;
|
||||||
|
|
||||||
|
mColor.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
mCameraPos.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
mGlowTop.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
mGlowBottom.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
mGlowTopPlane.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
mGlowBottomPlane.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
mSplitTopPlane.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
mSplitBottomPlane.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
mClipLine.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
mDynColor.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
mClipSplit[0] = mClipSplit[1] = 0.0f;
|
||||||
|
mEffectState = 0;
|
||||||
|
activeShader = nullptr;
|
||||||
|
mProjectionMatrix.loadIdentity();
|
||||||
|
mViewMatrix.loadIdentity();
|
||||||
|
mModelMatrix.loadIdentity();
|
||||||
|
mTextureMatrix.loadIdentity();
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -8,7 +8,7 @@ class FBloomExtractShader
|
||||||
public:
|
public:
|
||||||
void Bind();
|
void Bind();
|
||||||
|
|
||||||
FBufferedUniform1i SceneTexture;
|
FBufferedUniformSampler SceneTexture;
|
||||||
FBufferedUniform1f Exposure;
|
FBufferedUniform1f Exposure;
|
||||||
FBufferedUniform2f Scale;
|
FBufferedUniform2f Scale;
|
||||||
FBufferedUniform2f Offset;
|
FBufferedUniform2f Offset;
|
||||||
|
@ -22,7 +22,7 @@ class FBloomCombineShader
|
||||||
public:
|
public:
|
||||||
void Bind();
|
void Bind();
|
||||||
|
|
||||||
FBufferedUniform1i BloomTexture;
|
FBufferedUniformSampler BloomTexture;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FShaderProgram mShader;
|
FShaderProgram mShader;
|
||||||
|
|
|
@ -8,7 +8,7 @@ class FLensShader
|
||||||
public:
|
public:
|
||||||
void Bind();
|
void Bind();
|
||||||
|
|
||||||
FBufferedUniform1i InputTexture;
|
FBufferedUniformSampler InputTexture;
|
||||||
FBufferedUniform1f AspectRatio;
|
FBufferedUniform1f AspectRatio;
|
||||||
FBufferedUniform1f Scale;
|
FBufferedUniform1f Scale;
|
||||||
FBufferedUniform4f LensDistortionCoefficient;
|
FBufferedUniform4f LensDistortionCoefficient;
|
||||||
|
|
|
@ -8,7 +8,7 @@ class FPresentShader
|
||||||
public:
|
public:
|
||||||
void Bind();
|
void Bind();
|
||||||
|
|
||||||
FBufferedUniform1i InputTexture;
|
FBufferedUniformSampler InputTexture;
|
||||||
FBufferedUniform1f InvGamma;
|
FBufferedUniform1f InvGamma;
|
||||||
FBufferedUniform1f Contrast;
|
FBufferedUniform1f Contrast;
|
||||||
FBufferedUniform1f Brightness;
|
FBufferedUniform1f Brightness;
|
||||||
|
|
|
@ -201,6 +201,28 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class FBufferedUniformSampler
|
||||||
|
{
|
||||||
|
int mBuffer;
|
||||||
|
int mIndex;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void Init(GLuint hShader, const GLchar *name)
|
||||||
|
{
|
||||||
|
mIndex = glGetUniformLocation(hShader, name);
|
||||||
|
mBuffer = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Set(int newvalue)
|
||||||
|
{
|
||||||
|
if (newvalue != mBuffer)
|
||||||
|
{
|
||||||
|
mBuffer = newvalue;
|
||||||
|
glUniform1i(mIndex, newvalue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class FShader
|
class FShader
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,6 +52,12 @@
|
||||||
#include "i_system.h"
|
#include "i_system.h"
|
||||||
#include "doomerrors.h"
|
#include "doomerrors.h"
|
||||||
|
|
||||||
|
FShaderProgram::FShaderProgram()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < NumShaderTypes; i++)
|
||||||
|
mShaders[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// Free shader program resources
|
// Free shader program resources
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
class FShaderProgram
|
class FShaderProgram
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
FShaderProgram();
|
||||||
~FShaderProgram();
|
~FShaderProgram();
|
||||||
|
|
||||||
enum ShaderType
|
enum ShaderType
|
||||||
|
@ -30,6 +31,9 @@ public:
|
||||||
static void PatchFragShader(FString &code);
|
static void PatchFragShader(FString &code);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
FShaderProgram(const FShaderProgram &) = delete;
|
||||||
|
FShaderProgram &operator=(const FShaderProgram &) = delete;
|
||||||
|
|
||||||
static FString PatchShader(ShaderType type, const FString &code, const char *defines, int maxGlslVersion);
|
static FString PatchShader(ShaderType type, const FString &code, const char *defines, int maxGlslVersion);
|
||||||
static void PatchCommon(FString &code);
|
static void PatchCommon(FString &code);
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,9 @@ class FTonemapShader
|
||||||
public:
|
public:
|
||||||
void Bind();
|
void Bind();
|
||||||
|
|
||||||
FBufferedUniform1i SceneTexture;
|
FBufferedUniformSampler SceneTexture;
|
||||||
FBufferedUniform1f Exposure;
|
FBufferedUniform1f Exposure;
|
||||||
FBufferedUniform1i PaletteLUT;
|
FBufferedUniformSampler PaletteLUT;
|
||||||
|
|
||||||
static bool IsPaletteMode();
|
static bool IsPaletteMode();
|
||||||
|
|
||||||
|
|
|
@ -99,6 +99,11 @@ OpenGLFrameBuffer::OpenGLFrameBuffer(void *hMonitor, int width, int height, int
|
||||||
// If wglSwapIntervalEXT is called after glBindFramebuffer in a frame the setting is not changed!
|
// If wglSwapIntervalEXT is called after glBindFramebuffer in a frame the setting is not changed!
|
||||||
SetVSync(vid_vsync);
|
SetVSync(vid_vsync);
|
||||||
|
|
||||||
|
// Make sure all global variables tracking OpenGL context state are reset..
|
||||||
|
FHardwareTexture::InitGlobalState();
|
||||||
|
FMaterial::InitGlobalState();
|
||||||
|
gl_RenderState.Reset();
|
||||||
|
|
||||||
GLRenderer = new FGLRenderer(this);
|
GLRenderer = new FGLRenderer(this);
|
||||||
memcpy (SourcePalette, GPalette.BaseColors, sizeof(PalEntry)*256);
|
memcpy (SourcePalette, GPalette.BaseColors, sizeof(PalEntry)*256);
|
||||||
UpdatePalette ();
|
UpdatePalette ();
|
||||||
|
|
|
@ -48,11 +48,11 @@ private:
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static unsigned int lastbound[MAX_TEXTURES];
|
static unsigned int lastbound[MAX_TEXTURES];
|
||||||
static int lastactivetexture;
|
|
||||||
static int max_texturesize;
|
|
||||||
|
|
||||||
static int GetTexDimension(int value);
|
static int GetTexDimension(int value);
|
||||||
|
|
||||||
|
static void InitGlobalState() { for (int i = 0; i < MAX_TEXTURES; i++) lastbound[i] = 0; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
short texwidth, texheight;
|
short texwidth, texheight;
|
||||||
|
|
|
@ -669,6 +669,12 @@ static FMaterial *last;
|
||||||
static int lastclamp;
|
static int lastclamp;
|
||||||
static int lasttrans;
|
static int lasttrans;
|
||||||
|
|
||||||
|
void FMaterial::InitGlobalState()
|
||||||
|
{
|
||||||
|
last = nullptr;
|
||||||
|
lastclamp = 0;
|
||||||
|
lasttrans = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void FMaterial::Bind(int clampmode, int translation)
|
void FMaterial::Bind(int clampmode, int translation)
|
||||||
{
|
{
|
||||||
|
|
|
@ -263,6 +263,7 @@ public:
|
||||||
static FMaterial *ValidateTexture(FTextureID no, bool expand, bool trans);
|
static FMaterial *ValidateTexture(FTextureID no, bool expand, bool trans);
|
||||||
static void ClearLastTexture();
|
static void ClearLastTexture();
|
||||||
|
|
||||||
|
static void InitGlobalState();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue