mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-27 22:22:08 +00:00
- predefine the vertex data for the blend overlay which will never change throughout the lifetime of the GLRenderer object.
This commit is contained in:
parent
d7c0dda722
commit
8daaf61160
6 changed files with 24 additions and 18 deletions
|
@ -109,7 +109,7 @@ void FSimpleVertexBuffer::set(FSimpleVertex *verts, int count)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FFlatVertexBuffer::FFlatVertexBuffer()
|
||||
FFlatVertexBuffer::FFlatVertexBuffer(int width, int height)
|
||||
: FVertexBuffer(gl.buffermethod == BM_PERSISTENT)
|
||||
{
|
||||
if (gl.buffermethod == BM_PERSISTENT)
|
||||
|
@ -125,7 +125,22 @@ FFlatVertexBuffer::FFlatVertexBuffer()
|
|||
vbo_shadowdata.Reserve(BUFFER_SIZE);
|
||||
map = new FFlatVertex[BUFFER_SIZE];
|
||||
}
|
||||
mNumReserved = mIndex = mCurIndex = 0;
|
||||
mIndex = mCurIndex = 0;
|
||||
mNumReserved = 8;
|
||||
vbo_shadowdata.Resize(mNumReserved);
|
||||
|
||||
// the first quad is reserved for handling coordinates through uniforms.
|
||||
vbo_shadowdata[0].Set(1, 0, 0, 0, 0);
|
||||
vbo_shadowdata[1].Set(2, 0, 0, 0, 0);
|
||||
vbo_shadowdata[2].Set(3, 0, 0, 0, 0);
|
||||
vbo_shadowdata[3].Set(4, 0, 0, 0, 0);
|
||||
|
||||
// and the second one for the fullscreen quad used for blend overlays.
|
||||
vbo_shadowdata[4].Set(0, 0, 0, 0, 0);
|
||||
vbo_shadowdata[5].Set(0, (float)height, 0, 0, 0);
|
||||
vbo_shadowdata[6].Set((float)width, 0, 0, 0, 0);
|
||||
vbo_shadowdata[7].Set((float)width, (float)height, 0, 0, 0);
|
||||
|
||||
}
|
||||
|
||||
FFlatVertexBuffer::~FFlatVertexBuffer()
|
||||
|
@ -350,7 +365,6 @@ void FFlatVertexBuffer::UpdatePlaneVertices(sector_t *sec, int plane)
|
|||
|
||||
void FFlatVertexBuffer::CreateVBO()
|
||||
{
|
||||
vbo_shadowdata.Resize(mNumReserved);
|
||||
CreateFlatVBO();
|
||||
mCurIndex = mIndex = vbo_shadowdata.Size();
|
||||
memcpy(map, &vbo_shadowdata[0], vbo_shadowdata.Size() * sizeof(FFlatVertex));
|
||||
|
|
|
@ -84,7 +84,7 @@ class FFlatVertexBuffer : public FVertexBuffer
|
|||
public:
|
||||
TArray<FFlatVertex> vbo_shadowdata; // this is kept around for updating the actual (non-readable) buffer and as stand-in for pre GL 4.x
|
||||
|
||||
FFlatVertexBuffer();
|
||||
FFlatVertexBuffer(int width, int height);
|
||||
~FFlatVertexBuffer();
|
||||
|
||||
void BindVBO();
|
||||
|
|
|
@ -113,7 +113,7 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb)
|
|||
void gl_LoadModels();
|
||||
void gl_FlushModels();
|
||||
|
||||
void FGLRenderer::Initialize()
|
||||
void FGLRenderer::Initialize(int width, int height)
|
||||
{
|
||||
mBuffers = new FGLRenderBuffers();
|
||||
mBloomExtractShader = new FBloomExtractShader();
|
||||
|
@ -137,7 +137,7 @@ void FGLRenderer::Initialize()
|
|||
glpart = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart.png"), FTexture::TEX_MiscPatch);
|
||||
mirrortexture = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/mirror.png"), FTexture::TEX_MiscPatch);
|
||||
|
||||
mVBO = new FFlatVertexBuffer;
|
||||
mVBO = new FFlatVertexBuffer(width, height);
|
||||
mSkyVBO = new FSkyVertexBuffer;
|
||||
if (gl.lightmethod != LM_SOFTWARE) mLights = new FLightBuffer();
|
||||
else mLights = NULL;
|
||||
|
|
|
@ -129,7 +129,7 @@ public:
|
|||
void SetViewAngle(DAngle viewangle);
|
||||
void SetupView(float viewx, float viewy, float viewz, DAngle viewangle, bool mirror, bool planemirror);
|
||||
|
||||
void Initialize();
|
||||
void Initialize(int width, int height);
|
||||
|
||||
void CreateScene();
|
||||
void RenderMultipassStuff();
|
||||
|
|
|
@ -525,16 +525,8 @@ void gl_FillScreen()
|
|||
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
||||
gl_RenderState.EnableTexture(false);
|
||||
gl_RenderState.Apply();
|
||||
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
|
||||
ptr->Set(0, 0, 0, 0, 0);
|
||||
ptr++;
|
||||
ptr->Set(0, (float)SCREENHEIGHT, 0, 0, 0);
|
||||
ptr++;
|
||||
ptr->Set((float)SCREENWIDTH, 0, 0, 0, 0);
|
||||
ptr++;
|
||||
ptr->Set((float)SCREENWIDTH, (float)SCREENHEIGHT, 0, 0, 0);
|
||||
ptr++;
|
||||
GLRenderer->mVBO->RenderCurrent(ptr, GL_TRIANGLE_STRIP);
|
||||
// The fullscreen quad is stored at index 4 in the main vertex buffer.
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 4, 4);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -164,7 +164,7 @@ void OpenGLFrameBuffer::InitializeState()
|
|||
//int h = GetHeight();
|
||||
//glViewport(0, (trueH - h)/2, GetWidth(), GetHeight());
|
||||
|
||||
GLRenderer->Initialize();
|
||||
GLRenderer->Initialize(GetWidth(), GetHeight());
|
||||
GLRenderer->SetOutputViewport(nullptr);
|
||||
Begin2D(false);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue