mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 07:11:54 +00:00
- store the stencil caps in the reserved part of the main vertex buffer instead of constantly recreating them.
This commit is contained in:
parent
76d7b52fcd
commit
b83c2056a8
3 changed files with 24 additions and 24 deletions
|
@ -153,7 +153,7 @@ FFlatVertexBuffer::FFlatVertexBuffer(int width, int height)
|
|||
map = new FFlatVertex[BUFFER_SIZE];
|
||||
}
|
||||
mIndex = mCurIndex = 0;
|
||||
mNumReserved = 12;
|
||||
mNumReserved = NUM_RESERVED;
|
||||
vbo_shadowdata.Resize(mNumReserved);
|
||||
|
||||
// the first quad is reserved for handling coordinates through uniforms.
|
||||
|
@ -174,6 +174,17 @@ FFlatVertexBuffer::FFlatVertexBuffer(int width, int height)
|
|||
vbo_shadowdata[10].Set(1.0f, -1.0f, 0, 1.f, 0.0f);
|
||||
vbo_shadowdata[11].Set(1.0f, 1.0f, 0, 1.f, 1.f);
|
||||
|
||||
// The next two are the stencil caps.
|
||||
vbo_shadowdata[12].Set(-32767.0f, 32767.0f, -32767.0f, 0, 0);
|
||||
vbo_shadowdata[13].Set(-32767.0f, 32767.0f, 32767.0f, 0, 0);
|
||||
vbo_shadowdata[14].Set(32767.0f, 32767.0f, 32767.0f, 0, 0);
|
||||
vbo_shadowdata[15].Set(32767.0f, 32767.0f, -32767.0f, 0, 0);
|
||||
|
||||
vbo_shadowdata[16].Set(-32767.0f, -32767.0f, -32767.0f, 0, 0);
|
||||
vbo_shadowdata[17].Set(-32767.0f, -32767.0f, 32767.0f, 0, 0);
|
||||
vbo_shadowdata[18].Set(32767.0f, -32767.0f, 32767.0f, 0, 0);
|
||||
vbo_shadowdata[19].Set(32767.0f, -32767.0f, -32767.0f, 0, 0);
|
||||
|
||||
}
|
||||
|
||||
FFlatVertexBuffer::~FFlatVertexBuffer()
|
||||
|
|
|
@ -87,7 +87,11 @@ public:
|
|||
{
|
||||
QUAD_INDEX = 0,
|
||||
FULLSCREEN_INDEX = 4,
|
||||
PRESENT_INDEX = 8
|
||||
PRESENT_INDEX = 8,
|
||||
STENCILTOP_INDEX = 12,
|
||||
STENCILBOTTOM_INDEX = 16,
|
||||
|
||||
NUM_RESERVED = 20
|
||||
};
|
||||
|
||||
TArray<FFlatVertex> vbo_shadowdata; // this is kept around for updating the actual (non-readable) buffer and as stand-in for pre GL 4.x
|
||||
|
|
|
@ -147,40 +147,25 @@ void GLPortal::DrawPortalStencil()
|
|||
{
|
||||
if (mPrimIndices.Size() == 0)
|
||||
{
|
||||
bool cap = NeedCap() && lines.Size() > 1;
|
||||
mPrimIndices.Resize(2 * lines.Size() + 4 * cap);
|
||||
mPrimIndices.Resize(2 * lines.Size());
|
||||
|
||||
for (unsigned int i = 0; i<lines.Size(); i++)
|
||||
for (unsigned int i = 0; i < lines.Size(); i++)
|
||||
{
|
||||
if (gl.buffermethod != BM_DEFERRED) lines[i].MakeVertices(false);
|
||||
mPrimIndices[i * 2] = lines[i].vertindex;
|
||||
mPrimIndices[i * 2 + 1] = lines[i].vertcount;
|
||||
}
|
||||
|
||||
if (cap)
|
||||
{
|
||||
// Cap the stencil at the top and bottom
|
||||
int n = lines.Size() * 2;
|
||||
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
|
||||
ptr[0].Set(-32767.0f, 32767.0f, -32767.0f, 0, 0);
|
||||
ptr[1].Set(-32767.0f, 32767.0f, 32767.0f, 0, 0);
|
||||
ptr[2].Set(32767.0f, 32767.0f, 32767.0f, 0, 0);
|
||||
ptr[3].Set(32767.0f, 32767.0f, -32767.0f, 0, 0);
|
||||
ptr += 4;
|
||||
mPrimIndices[n + 1] = GLRenderer->mVBO->GetCount(ptr, &mPrimIndices[n]);
|
||||
ptr[0].Set(-32767.0f, -32767.0f, -32767.0f, 0, 0);
|
||||
ptr[1].Set(-32767.0f, -32767.0f, 32767.0f, 0, 0);
|
||||
ptr[2].Set(32767.0f, -32767.0f, 32767.0f, 0, 0);
|
||||
ptr[3].Set(32767.0f, -32767.0f, -32767.0f, 0, 0);
|
||||
ptr += 4;
|
||||
mPrimIndices[n + 3] = GLRenderer->mVBO->GetCount(ptr, &mPrimIndices[n + 2]);
|
||||
}
|
||||
}
|
||||
gl_RenderState.Apply();
|
||||
for (unsigned int i = 0; i < mPrimIndices.Size(); i += 2)
|
||||
{
|
||||
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, mPrimIndices[i], mPrimIndices[i + 1]);
|
||||
}
|
||||
if (NeedCap() && lines.Size() > 1)
|
||||
{
|
||||
glDrawArrays(GL_TRIANGLE_FAN, FFlatVertexBuffer::STENCILTOP_INDEX, 4);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, FFlatVertexBuffer::STENCILBOTTOM_INDEX, 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue