mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-23 04:22:34 +00:00
- hooked low level buffers into render state.
It still needs to support the old interface so the code isn't really clean
This commit is contained in:
parent
3db26a3a1b
commit
332ab220ad
5 changed files with 56 additions and 9 deletions
|
@ -37,6 +37,7 @@
|
|||
#include "gl/dynlights//gl_lightbuffer.h"
|
||||
#include "gl/renderer/gl_renderbuffers.h"
|
||||
#include "gl/textures/gl_hwtexture.h"
|
||||
#include "gl/system/glsys_vertexbuffer.h"
|
||||
|
||||
FGLRenderState gl_RenderState;
|
||||
|
||||
|
@ -73,6 +74,11 @@ void FGLRenderState::Reset()
|
|||
mEffectState = 0;
|
||||
activeShader = nullptr;
|
||||
mPassType = NORMAL_PASS;
|
||||
|
||||
mCurrentVertexBuffer = nullptr;
|
||||
mCurrentVertexOffsets[0] = mVertexOffsets[0] = 0;
|
||||
mCurrentIndexBuffer = nullptr;
|
||||
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -246,11 +252,22 @@ void FGLRenderState::Apply()
|
|||
mBias.mChanged = false;
|
||||
}
|
||||
|
||||
if (mVertexBuffer != mCurrentVertexBuffer)
|
||||
if (mVertexBuffer != nullptr)
|
||||
{
|
||||
if (mVertexBuffer == NULL) glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
else mVertexBuffer->BindVBO();
|
||||
mCurrentVertexBuffer = mVertexBuffer;
|
||||
if (mVertexBuffer != mCurrentVertexBuffer || mVertexOffsets[0] != mCurrentVertexOffsets[0] || mVertexOffsets[1] != mCurrentVertexOffsets[1])
|
||||
{
|
||||
assert(mVertexBuffer != nullptr);
|
||||
static_cast<GLVertexBuffer*>(mVertexBuffer)->Bind(mVertexOffsets);
|
||||
mCurrentVertexBuffer = mVertexBuffer;
|
||||
mCurrentVertexOffsets[0] = mVertexOffsets[0];
|
||||
mCurrentVertexOffsets[1] = mVertexOffsets[1];
|
||||
}
|
||||
}
|
||||
else if (mFVertexBuffer != mCurrentFVertexBuffer)
|
||||
{
|
||||
if (mFVertexBuffer == NULL) glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
else mFVertexBuffer->BindVBO();
|
||||
mCurrentFVertexBuffer = mFVertexBuffer;
|
||||
}
|
||||
ApplyShader();
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ class FGLRenderState : public FRenderState
|
|||
|
||||
float mInterpolationFactor;
|
||||
|
||||
FVertexBuffer *mVertexBuffer, *mCurrentVertexBuffer;
|
||||
FVertexBuffer *mFVertexBuffer, *mCurrentFVertexBuffer;
|
||||
|
||||
int mEffectState;
|
||||
int mTempTM = TM_NORMAL;
|
||||
|
@ -80,6 +80,10 @@ class FGLRenderState : public FRenderState
|
|||
int lastTranslation = 0;
|
||||
int maxBoundMaterial = -1;
|
||||
|
||||
IVertexBuffer *mCurrentVertexBuffer;
|
||||
int mCurrentVertexOffsets[2]; // one per binding point
|
||||
IIndexBuffer *mCurrentIndexBuffer;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
@ -103,13 +107,17 @@ public:
|
|||
|
||||
void SetVertexBuffer(FVertexBuffer *vb)
|
||||
{
|
||||
mVertexBuffer = vb;
|
||||
mFVertexBuffer = vb;
|
||||
mVertexBuffer = nullptr;
|
||||
mIndexBuffer = nullptr;
|
||||
}
|
||||
|
||||
void ResetVertexBuffer()
|
||||
{
|
||||
// forces rebinding with the next 'apply' call.
|
||||
mCurrentVertexBuffer = NULL;
|
||||
mCurrentFVertexBuffer = nullptr;
|
||||
mVertexBuffer = nullptr;
|
||||
mIndexBuffer = nullptr;
|
||||
}
|
||||
|
||||
void SetSpecular(float glossiness, float specularLevel)
|
||||
|
|
|
@ -122,7 +122,7 @@ void GLVertexBuffer::SetFormat(int numBindingPoints, int numAttributes, size_t s
|
|||
}
|
||||
}
|
||||
|
||||
void GLVertexBuffer::Bind(size_t *offsets)
|
||||
void GLVertexBuffer::Bind(int *offsets)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
~GLVertexBuffer();
|
||||
void SetData(size_t size, void *data, bool staticdata) override;
|
||||
void SetFormat(int numBindingPoints, int numAttributes, size_t stride, FVertexBufferAttribute *attrs) override;
|
||||
void Bind(size_t *offsets);
|
||||
void Bind(int *offsets);
|
||||
void Map() override;
|
||||
void Unmap() override;
|
||||
};
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
#include "hwrenderer/textures/hw_material.h"
|
||||
|
||||
struct FColormap;
|
||||
class IVertexBuffer;
|
||||
class IIndexBuffer;
|
||||
|
||||
enum EEffect
|
||||
{
|
||||
|
@ -106,6 +108,10 @@ protected:
|
|||
FMaterialState mMaterial;
|
||||
FDepthBiasState mBias;
|
||||
|
||||
IVertexBuffer *mVertexBuffer;
|
||||
int mVertexOffsets[2]; // one per binding point
|
||||
IIndexBuffer *mIndexBuffer;
|
||||
|
||||
void SetShaderLight(float level, float olight);
|
||||
|
||||
public:
|
||||
|
@ -136,6 +142,10 @@ public:
|
|||
mMaterial.Reset();
|
||||
mBias.Reset();
|
||||
|
||||
mVertexBuffer = nullptr;
|
||||
mVertexOffsets[0] = mVertexOffsets[0] = 0;
|
||||
mIndexBuffer = nullptr;
|
||||
|
||||
mColor.Set(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
mGlowTop.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
mGlowBottom.Set(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
@ -385,6 +395,18 @@ public:
|
|||
mClipSplit[1] = 1000000.f;
|
||||
}
|
||||
|
||||
void SetVertexBuffer(IVertexBuffer *vb, int offset0, int offset1)
|
||||
{
|
||||
mVertexBuffer = vb;
|
||||
mVertexOffsets[0] = offset0;
|
||||
mVertexOffsets[1] = offset1;
|
||||
}
|
||||
|
||||
void SetIndexBuffer(IIndexBuffer *ib)
|
||||
{
|
||||
mIndexBuffer = ib;
|
||||
}
|
||||
|
||||
|
||||
void SetColor(int sectorlightlevel, int rellight, bool fullbright, const FColormap &cm, float alpha, bool weapon = false);
|
||||
void SetFog(int lightlevel, int rellight, bool fullbright, const FColormap *cmap, bool isadditive);
|
||||
|
|
Loading…
Reference in a new issue