mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-13 16:07:45 +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)
|
: FVertexBuffer(gl.buffermethod == BM_PERSISTENT)
|
||||||
{
|
{
|
||||||
if (gl.buffermethod == BM_PERSISTENT)
|
if (gl.buffermethod == BM_PERSISTENT)
|
||||||
|
@ -125,7 +125,22 @@ FFlatVertexBuffer::FFlatVertexBuffer()
|
||||||
vbo_shadowdata.Reserve(BUFFER_SIZE);
|
vbo_shadowdata.Reserve(BUFFER_SIZE);
|
||||||
map = new FFlatVertex[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()
|
FFlatVertexBuffer::~FFlatVertexBuffer()
|
||||||
|
@ -350,7 +365,6 @@ void FFlatVertexBuffer::UpdatePlaneVertices(sector_t *sec, int plane)
|
||||||
|
|
||||||
void FFlatVertexBuffer::CreateVBO()
|
void FFlatVertexBuffer::CreateVBO()
|
||||||
{
|
{
|
||||||
vbo_shadowdata.Resize(mNumReserved);
|
|
||||||
CreateFlatVBO();
|
CreateFlatVBO();
|
||||||
mCurIndex = mIndex = vbo_shadowdata.Size();
|
mCurIndex = mIndex = vbo_shadowdata.Size();
|
||||||
memcpy(map, &vbo_shadowdata[0], vbo_shadowdata.Size() * sizeof(FFlatVertex));
|
memcpy(map, &vbo_shadowdata[0], vbo_shadowdata.Size() * sizeof(FFlatVertex));
|
||||||
|
|
|
@ -84,7 +84,7 @@ class FFlatVertexBuffer : public FVertexBuffer
|
||||||
public:
|
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
|
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();
|
~FFlatVertexBuffer();
|
||||||
|
|
||||||
void BindVBO();
|
void BindVBO();
|
||||||
|
|
|
@ -113,7 +113,7 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb)
|
||||||
void gl_LoadModels();
|
void gl_LoadModels();
|
||||||
void gl_FlushModels();
|
void gl_FlushModels();
|
||||||
|
|
||||||
void FGLRenderer::Initialize()
|
void FGLRenderer::Initialize(int width, int height)
|
||||||
{
|
{
|
||||||
mBuffers = new FGLRenderBuffers();
|
mBuffers = new FGLRenderBuffers();
|
||||||
mBloomExtractShader = new FBloomExtractShader();
|
mBloomExtractShader = new FBloomExtractShader();
|
||||||
|
@ -137,7 +137,7 @@ void FGLRenderer::Initialize()
|
||||||
glpart = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart.png"), FTexture::TEX_MiscPatch);
|
glpart = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/glpart.png"), FTexture::TEX_MiscPatch);
|
||||||
mirrortexture = FTexture::CreateTexture(Wads.GetNumForFullName("glstuff/mirror.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;
|
mSkyVBO = new FSkyVertexBuffer;
|
||||||
if (gl.lightmethod != LM_SOFTWARE) mLights = new FLightBuffer();
|
if (gl.lightmethod != LM_SOFTWARE) mLights = new FLightBuffer();
|
||||||
else mLights = NULL;
|
else mLights = NULL;
|
||||||
|
|
|
@ -129,7 +129,7 @@ public:
|
||||||
void SetViewAngle(DAngle viewangle);
|
void SetViewAngle(DAngle viewangle);
|
||||||
void SetupView(float viewx, float viewy, float viewz, DAngle viewangle, bool mirror, bool planemirror);
|
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 CreateScene();
|
||||||
void RenderMultipassStuff();
|
void RenderMultipassStuff();
|
||||||
|
|
|
@ -525,16 +525,8 @@ void gl_FillScreen()
|
||||||
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
||||||
gl_RenderState.EnableTexture(false);
|
gl_RenderState.EnableTexture(false);
|
||||||
gl_RenderState.Apply();
|
gl_RenderState.Apply();
|
||||||
FFlatVertex *ptr = GLRenderer->mVBO->GetBuffer();
|
// The fullscreen quad is stored at index 4 in the main vertex buffer.
|
||||||
ptr->Set(0, 0, 0, 0, 0);
|
glDrawArrays(GL_TRIANGLE_STRIP, 4, 4);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -164,7 +164,7 @@ void OpenGLFrameBuffer::InitializeState()
|
||||||
//int h = GetHeight();
|
//int h = GetHeight();
|
||||||
//glViewport(0, (trueH - h)/2, GetWidth(), GetHeight());
|
//glViewport(0, (trueH - h)/2, GetWidth(), GetHeight());
|
||||||
|
|
||||||
GLRenderer->Initialize();
|
GLRenderer->Initialize(GetWidth(), GetHeight());
|
||||||
GLRenderer->SetOutputViewport(nullptr);
|
GLRenderer->SetOutputViewport(nullptr);
|
||||||
Begin2D(false);
|
Begin2D(false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue