mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-28 23:11:58 +00:00
- removed the Bind function from FFlatVertexBuffer.
This is not flexible enough. There was already one place where this was not supposed to go through the render state. The new interface allows more general use of the contained buffer objects.
This commit is contained in:
parent
fa498611f8
commit
48bc5550d7
10 changed files with 23 additions and 22 deletions
|
@ -30,6 +30,7 @@
|
||||||
#include "m_png.h"
|
#include "m_png.h"
|
||||||
#include "r_utility.h"
|
#include "r_utility.h"
|
||||||
#include "d_player.h"
|
#include "d_player.h"
|
||||||
|
#include "gl/system/gl_buffers.h"
|
||||||
#include "gl/system/gl_framebuffer.h"
|
#include "gl/system/gl_framebuffer.h"
|
||||||
#include "hwrenderer/utility/hw_cvars.h"
|
#include "hwrenderer/utility/hw_cvars.h"
|
||||||
#include "gl/system/gl_debug.h"
|
#include "gl/system/gl_debug.h"
|
||||||
|
@ -56,8 +57,8 @@ namespace OpenGLRenderer
|
||||||
|
|
||||||
void FGLRenderer::RenderScreenQuad()
|
void FGLRenderer::RenderScreenQuad()
|
||||||
{
|
{
|
||||||
screen->mVertexData->Bind(gl_RenderState);
|
auto buffer = static_cast<GLVertexBuffer *>(screen->mVertexData->GetBufferObjects().first);
|
||||||
gl_RenderState.ApplyBuffers();
|
buffer->Bind(nullptr);
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, FFlatVertexBuffer::PRESENT_INDEX, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -220,7 +220,7 @@ void FGLRenderer::UpdateShadowMap()
|
||||||
|
|
||||||
sector_t *FGLRenderer::RenderView(player_t* player)
|
sector_t *FGLRenderer::RenderView(player_t* player)
|
||||||
{
|
{
|
||||||
screen->mVertexData->Bind(gl_RenderState);
|
gl_RenderState.SetVertexBuffer(screen->mVertexData);
|
||||||
screen->mVertexData->Reset();
|
screen->mVertexData->Reset();
|
||||||
sector_t *retsec;
|
sector_t *retsec;
|
||||||
|
|
||||||
|
@ -344,7 +344,7 @@ void FGLRenderer::WriteSavePic (player_t *player, FileWriter *file, int width, i
|
||||||
mBuffers = mSaveBuffers;
|
mBuffers = mSaveBuffers;
|
||||||
|
|
||||||
P_FindParticleSubsectors(); // make sure that all recently spawned particles have a valid subsector.
|
P_FindParticleSubsectors(); // make sure that all recently spawned particles have a valid subsector.
|
||||||
screen->mVertexData->Bind(gl_RenderState);
|
gl_RenderState.SetVertexBuffer(screen->mVertexData);
|
||||||
screen->mVertexData->Reset();
|
screen->mVertexData->Reset();
|
||||||
screen->mLights->Clear();
|
screen->mLights->Clear();
|
||||||
screen->mViewpoints->Clear();
|
screen->mViewpoints->Clear();
|
||||||
|
|
|
@ -186,7 +186,7 @@ void GLVertexBuffer::Bind(int *offsets)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
// This is what gets called from RenderState.Apply. It shouldn't be called anywhere else.
|
// This is what gets called from RenderState.Apply. It shouldn't be called anywhere else if the render state is in use
|
||||||
GLBuffer::Bind();
|
GLBuffer::Bind();
|
||||||
for(auto &attrinf : mAttributeInfo)
|
for(auto &attrinf : mAttributeInfo)
|
||||||
{
|
{
|
||||||
|
|
|
@ -411,18 +411,6 @@ void FFlatVertexBuffer::Copy(int start, int count)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void FFlatVertexBuffer::Bind(FRenderState &state)
|
|
||||||
{
|
|
||||||
state.SetVertexBuffer(mVertexBuffer, 0, 0);
|
|
||||||
state.SetIndexBuffer(mIndexBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
void FFlatVertexBuffer::CreateVBO()
|
void FFlatVertexBuffer::CreateVBO()
|
||||||
{
|
{
|
||||||
vbo_shadowdata.Resize(mNumReserved);
|
vbo_shadowdata.Resize(mNumReserved);
|
||||||
|
|
|
@ -103,7 +103,11 @@ public:
|
||||||
~FFlatVertexBuffer();
|
~FFlatVertexBuffer();
|
||||||
|
|
||||||
void OutputResized(int width, int height);
|
void OutputResized(int width, int height);
|
||||||
void Bind(FRenderState &state);
|
std::pair<IVertexBuffer *, IIndexBuffer *> GetBufferObjects() const
|
||||||
|
{
|
||||||
|
return std::make_pair(mVertexBuffer, mIndexBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
void CreateVBO();
|
void CreateVBO();
|
||||||
void Copy(int start, int count);
|
void Copy(int start, int count);
|
||||||
|
|
||||||
|
@ -147,6 +151,7 @@ protected:
|
||||||
void CheckPlanes(sector_t *sector);
|
void CheckPlanes(sector_t *sector);
|
||||||
public:
|
public:
|
||||||
void CheckUpdate(sector_t *sector);
|
void CheckUpdate(sector_t *sector);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -588,7 +588,7 @@ void HWDrawInfo::RenderPortal(HWPortal *p, FRenderState &state, bool usestencil)
|
||||||
state.SetLightIndex(-1);
|
state.SetLightIndex(-1);
|
||||||
gp->DrawContents(new_di, state);
|
gp->DrawContents(new_di, state);
|
||||||
new_di->EndDrawInfo();
|
new_di->EndDrawInfo();
|
||||||
screen->mVertexData->Bind(state);
|
state.SetVertexBuffer(screen->mVertexData);
|
||||||
screen->mViewpoints->Bind(state, vpIndex);
|
screen->mViewpoints->Bind(state, vpIndex);
|
||||||
gp->RemoveStencil(this, state, usestencil);
|
gp->RemoveStencil(this, state, usestencil);
|
||||||
|
|
||||||
|
|
|
@ -457,6 +457,13 @@ public:
|
||||||
mIndexBuffer = ib;
|
mIndexBuffer = ib;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <class T> void SetVertexBuffer(T *buffer)
|
||||||
|
{
|
||||||
|
auto ptrs = buffer->GetBufferObjects();
|
||||||
|
SetVertexBuffer(ptrs.first, 0, 0);
|
||||||
|
SetIndexBuffer(ptrs.second);
|
||||||
|
}
|
||||||
|
|
||||||
void SetInterpolationFactor(float fac)
|
void SetInterpolationFactor(float fac)
|
||||||
{
|
{
|
||||||
mInterpolationFactor = fac;
|
mInterpolationFactor = fac;
|
||||||
|
|
|
@ -271,7 +271,7 @@ void GLSprite::DrawSprite(HWDrawInfo *di, FRenderState &state, bool translucent)
|
||||||
{
|
{
|
||||||
FGLModelRenderer renderer(di, state, dynlightindex);
|
FGLModelRenderer renderer(di, state, dynlightindex);
|
||||||
renderer.RenderModel(x, y, z, modelframe, actor, di->Viewpoint.TicFrac);
|
renderer.RenderModel(x, y, z, modelframe, actor, di->Viewpoint.TicFrac);
|
||||||
screen->mVertexData->Bind(state);
|
state.SetVertexBuffer(screen->mVertexData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ void HWDrawInfo::DrawPSprite(HUDSprite *huds, FRenderState &state)
|
||||||
|
|
||||||
FGLModelRenderer renderer(this, state, huds->lightindex);
|
FGLModelRenderer renderer(this, state, huds->lightindex);
|
||||||
renderer.RenderHUDModel(huds->weapon, huds->mx, huds->my);
|
renderer.RenderHUDModel(huds->weapon, huds->mx, huds->my);
|
||||||
screen->mVertexData->Bind(state);
|
state.SetVertexBuffer(screen->mVertexData);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -212,7 +212,7 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state)
|
||||||
state.SetScissor(-1, -1, -1, -1);
|
state.SetScissor(-1, -1, -1, -1);
|
||||||
|
|
||||||
state.SetRenderStyle(STYLE_Translucent);
|
state.SetRenderStyle(STYLE_Translucent);
|
||||||
screen->mVertexData->Bind(state);
|
state.SetVertexBuffer(screen->mVertexData);
|
||||||
state.EnableTexture(true);
|
state.EnableTexture(true);
|
||||||
state.EnableBrightmap(true);
|
state.EnableBrightmap(true);
|
||||||
state.SetTextureMode(TM_NORMAL);
|
state.SetTextureMode(TM_NORMAL);
|
||||||
|
|
Loading…
Reference in a new issue