- - removed the remains of the old FVertexBuffer class.

This commit is contained in:
Christoph Oelckers 2018-10-27 22:04:13 +02:00
parent 067716cefb
commit 83e706afe7
16 changed files with 50 additions and 268 deletions

View file

@ -1037,7 +1037,6 @@ set (PCH_SOURCES
g_statusbar/sbarinfo.cpp g_statusbar/sbarinfo.cpp
g_statusbar/sbar_mugshot.cpp g_statusbar/sbar_mugshot.cpp
g_statusbar/shared_sbar.cpp g_statusbar/shared_sbar.cpp
gl/data/gl_vertexbuffer.cpp
gl/data/gl_uniformbuffer.cpp gl/data/gl_uniformbuffer.cpp
gl/data/gl_viewpointbuffer.cpp gl/data/gl_viewpointbuffer.cpp
gl/dynlights/gl_lightbuffer.cpp gl/dynlights/gl_lightbuffer.cpp

View file

@ -1,93 +0,0 @@
//
//---------------------------------------------------------------------------
//
// Copyright(C) 2005-2016 Christoph Oelckers
// All rights reserved.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see http://www.gnu.org/licenses/
//
//--------------------------------------------------------------------------
//
/*
** gl_vertexbuffer.cpp
** Vertex buffer handling.
**
**/
#include "gl_load/gl_system.h"
#include "doomtype.h"
#include "p_local.h"
#include "r_state.h"
#include "cmdlib.h"
#include "gl_load/gl_interface.h"
#include "gl/renderer/gl_renderer.h"
#include "gl/shaders/gl_shader.h"
#include "gl/data/gl_vertexbuffer.h"
//==========================================================================
//
// Create / destroy the VBO
//
//==========================================================================
FVertexBuffer::FVertexBuffer(bool wantbuffer)
{
vbo_id = 0;
if (wantbuffer) glGenBuffers(1, &vbo_id);
}
FVertexBuffer::~FVertexBuffer()
{
if (vbo_id != 0)
{
glDeleteBuffers(1, &vbo_id);
}
}
void FSimpleVertexBuffer::BindVBO()
{
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
glVertexAttribPointer(VATTR_VERTEX, 3, GL_FLOAT, false, sizeof(FSimpleVertex), &VSiO->x);
glVertexAttribPointer(VATTR_TEXCOORD, 2, GL_FLOAT, false, sizeof(FSimpleVertex), &VSiO->u);
glVertexAttribPointer(VATTR_COLOR, 4, GL_UNSIGNED_BYTE, true, sizeof(FSimpleVertex), &VSiO->color);
glEnableVertexAttribArray(VATTR_VERTEX);
glEnableVertexAttribArray(VATTR_TEXCOORD);
glEnableVertexAttribArray(VATTR_COLOR);
glDisableVertexAttribArray(VATTR_VERTEX2);
glDisableVertexAttribArray(VATTR_NORMAL);
}
void FSimpleVertexBuffer::EnableColorArray(bool on)
{
if (on)
{
glEnableVertexAttribArray(VATTR_COLOR);
}
else
{
glDisableVertexAttribArray(VATTR_COLOR);
}
}
void FSimpleVertexBuffer::set(FSimpleVertex *verts, int count)
{
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
gl_RenderState.ResetVertexBuffer();
gl_RenderState.SetVertexBuffer(this);
glBufferData(GL_ARRAY_BUFFER, count * sizeof(*verts), verts, GL_STREAM_DRAW);
}

View file

@ -1,89 +0,0 @@
//
//---------------------------------------------------------------------------
//
// Copyright(C) 2005-2016 Christoph Oelckers
// All rights reserved.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see http://www.gnu.org/licenses/
//
//--------------------------------------------------------------------------
//
#ifndef __VERTEXBUFFER_H
#define __VERTEXBUFFER_H
#include <atomic>
#include <thread>
#include <mutex>
#include "tarray.h"
#include "hwrenderer/utility/hw_clock.h"
#include "gl_load/gl_interface.h"
#include "r_data/models/models.h"
#include "hwrenderer/data/flatvertices.h"
#include "hwrenderer/scene/hw_skydome.h"
#include "hwrenderer/data/vertexbuffer.h"
struct vertex_t;
struct secplane_t;
struct subsector_t;
struct sector_t;
class FMaterial;
class FRenderState;
class FVertexBuffer
{
protected:
unsigned int vbo_id;
public:
FVertexBuffer(bool wantbuffer = true);
virtual ~FVertexBuffer();
virtual void BindVBO() = 0;
};
struct FSimpleVertex
{
float x, z, y; // world position
float u, v; // texture coordinates
PalEntry color;
void Set(float xx, float zz, float yy, float uu = 0, float vv = 0, PalEntry col = 0xffffffff)
{
x = xx;
z = zz;
y = yy;
u = uu;
v = vv;
color = col;
}
};
#define VTO ((FFlatVertex*)NULL)
#define VSiO ((FSimpleVertex*)NULL)
class FSimpleVertexBuffer : public FVertexBuffer
{
TArray<FSimpleVertex> mBuffer;
public:
FSimpleVertexBuffer()
{
}
void BindVBO();
void set(FSimpleVertex *verts, int count);
void EnableColorArray(bool on);
};
#endif

View file

@ -37,6 +37,8 @@
#include "i_time.h" #include "i_time.h"
#include "cmdlib.h" #include "cmdlib.h"
#include "hwrenderer/textures/hw_material.h" #include "hwrenderer/textures/hw_material.h"
#include "hwrenderer/data/vertexbuffer.h"
#include "hwrenderer/data/flatvertices.h"
#include "gl_load/gl_interface.h" #include "gl_load/gl_interface.h"
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"

View file

@ -23,7 +23,6 @@
#pragma once #pragma once
#include "tarray.h" #include "tarray.h"
#include "gl/data/gl_vertexbuffer.h"
#include "p_pspr.h" #include "p_pspr.h"
#include "r_data/voxels.h" #include "r_data/voxels.h"
#include "r_data/models/models.h" #include "r_data/models/models.h"

View file

@ -37,11 +37,11 @@
#include "gl/renderer/gl_renderbuffers.h" #include "gl/renderer/gl_renderbuffers.h"
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
#include "gl/renderer/gl_postprocessstate.h" #include "gl/renderer/gl_postprocessstate.h"
#include "gl/data/gl_vertexbuffer.h"
#include "hwrenderer/postprocessing/hw_presentshader.h" #include "hwrenderer/postprocessing/hw_presentshader.h"
#include "hwrenderer/postprocessing/hw_postprocess.h" #include "hwrenderer/postprocessing/hw_postprocess.h"
#include "hwrenderer/postprocessing/hw_postprocess_cvars.h" #include "hwrenderer/postprocessing/hw_postprocess_cvars.h"
#include "hwrenderer/utility/hw_vrmodes.h" #include "hwrenderer/utility/hw_vrmodes.h"
#include "hwrenderer/data/flatvertices.h"
#include "gl/shaders/gl_postprocessshaderinstance.h" #include "gl/shaders/gl_postprocessshaderinstance.h"
#include "gl/textures/gl_hwtexture.h" #include "gl/textures/gl_hwtexture.h"
#include "r_videoscale.h" #include "r_videoscale.h"

View file

@ -28,7 +28,6 @@
#include "templates.h" #include "templates.h"
#include "gl_load/gl_system.h" #include "gl_load/gl_system.h"
#include "gl_load/gl_interface.h" #include "gl_load/gl_interface.h"
#include "gl/data/gl_vertexbuffer.h"
#include "gl/renderer/gl_postprocessstate.h" #include "gl/renderer/gl_postprocessstate.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View file

@ -35,6 +35,7 @@
#include "p_effect.h" #include "p_effect.h"
#include "d_player.h" #include "d_player.h"
#include "a_dynlight.h" #include "a_dynlight.h"
#include "cmdlib.h"
#include "g_game.h" #include "g_game.h"
#include "swrenderer/r_swscene.h" #include "swrenderer/r_swscene.h"
#include "hwrenderer/utility/hw_clock.h" #include "hwrenderer/utility/hw_clock.h"
@ -46,17 +47,19 @@
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
#include "gl/renderer/gl_renderstate.h" #include "gl/renderer/gl_renderstate.h"
#include "gl/renderer/gl_renderbuffers.h" #include "gl/renderer/gl_renderbuffers.h"
#include "gl/data/gl_vertexbuffer.h"
#include "gl/scene/gl_drawinfo.h" #include "gl/scene/gl_drawinfo.h"
#include "hwrenderer/utility/hw_vrmodes.h" #include "hwrenderer/utility/hw_vrmodes.h"
#include "hwrenderer/postprocessing/hw_presentshader.h" #include "hwrenderer/postprocessing/hw_presentshader.h"
#include "hwrenderer/postprocessing/hw_present3dRowshader.h" #include "hwrenderer/postprocessing/hw_present3dRowshader.h"
#include "hwrenderer/postprocessing/hw_shadowmapshader.h" #include "hwrenderer/postprocessing/hw_shadowmapshader.h"
#include "hwrenderer/data/flatvertices.h"
#include "hwrenderer/scene/hw_skydome.h"
#include "gl/shaders/gl_postprocessshaderinstance.h" #include "gl/shaders/gl_postprocessshaderinstance.h"
#include "gl/textures/gl_samplers.h" #include "gl/textures/gl_samplers.h"
#include "gl/dynlights/gl_lightbuffer.h" #include "gl/dynlights/gl_lightbuffer.h"
#include "gl/data/gl_viewpointbuffer.h" #include "gl/data/gl_viewpointbuffer.h"
#include "r_videoscale.h" #include "r_videoscale.h"
#include "r_data/models/models.h"
EXTERN_CVAR(Int, screenblocks) EXTERN_CVAR(Int, screenblocks)
EXTERN_CVAR(Bool, cl_capfps) EXTERN_CVAR(Bool, cl_capfps)
@ -362,41 +365,42 @@ void FGLRenderer::BeginFrame()
// //
//=========================================================================== //===========================================================================
class F2DVertexBuffer : public FSimpleVertexBuffer class F2DVertexBuffer
{ {
uint32_t ibo_id; IVertexBuffer *mVertexBuffer;
IIndexBuffer *mIndexBuffer;
// Make sure we can build upon FSimpleVertexBuffer.
static_assert(offsetof(FSimpleVertex, x) == offsetof(F2DDrawer::TwoDVertex, x), "x not aligned");
static_assert(offsetof(FSimpleVertex, u) == offsetof(F2DDrawer::TwoDVertex, u), "u not aligned");
static_assert(offsetof(FSimpleVertex, color) == offsetof(F2DDrawer::TwoDVertex, color0), "color not aligned");
public: public:
F2DVertexBuffer() F2DVertexBuffer()
{ {
glGenBuffers(1, &ibo_id); mVertexBuffer = screen->CreateVertexBuffer();
mIndexBuffer = screen->CreateIndexBuffer();
static const FVertexBufferAttribute format[] = {
{ 0, VATTR_VERTEX, VFmt_Float3, myoffsetof(F2DDrawer::TwoDVertex, x) },
{ 0, VATTR_TEXCOORD, VFmt_Float2, myoffsetof(F2DDrawer::TwoDVertex, u) },
{ 0, VATTR_COLOR, VFmt_Byte4, myoffsetof(F2DDrawer::TwoDVertex, color0) }
};
mVertexBuffer->SetFormat(1, 3, sizeof(FSkyVertex), format);
} }
~F2DVertexBuffer() ~F2DVertexBuffer()
{ {
if (ibo_id != 0) delete mIndexBuffer;
{ delete mVertexBuffer;
glDeleteBuffers(1, &ibo_id);
}
} }
void UploadData(F2DDrawer::TwoDVertex *vertices, int vertcount, int *indices, int indexcount) void UploadData(F2DDrawer::TwoDVertex *vertices, int vertcount, int *indices, int indexcount)
{ {
glBindBuffer(GL_ARRAY_BUFFER, vbo_id); mVertexBuffer->SetData(vertcount * sizeof(*vertices), vertices, false);
glBufferData(GL_ARRAY_BUFFER, vertcount * sizeof(vertices[0]), vertices, GL_STREAM_DRAW); mIndexBuffer->SetData(indexcount * sizeof(unsigned int), indices, false);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexcount * sizeof(indices[0]), indices, GL_STREAM_DRAW);
} }
void BindVBO() override void Bind(FRenderState &state)
{ {
FSimpleVertexBuffer::BindVBO(); state.SetVertexBuffer(mVertexBuffer, 0, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); state.SetIndexBuffer(mIndexBuffer);
} }
}; };
@ -446,9 +450,9 @@ void FGLRenderer::Draw2D(F2DDrawer *drawer)
// Change from BGRA to RGBA // Change from BGRA to RGBA
std::swap(v.color0.r, v.color0.b); std::swap(v.color0.r, v.color0.b);
} }
auto vb = new F2DVertexBuffer; F2DVertexBuffer vb;
vb->UploadData(&vertices[0], vertices.Size(), &indices[0], indices.Size()); vb.UploadData(&vertices[0], vertices.Size(), &indices[0], indices.Size());
gl_RenderState.SetVertexBuffer(vb); vb.Bind(gl_RenderState);
gl_RenderState.EnableFog(false); gl_RenderState.EnableFog(false);
for(auto &cmd : commands) for(auto &cmd : commands)
@ -544,7 +548,6 @@ void FGLRenderer::Draw2D(F2DDrawer *drawer)
gl_RenderState.EnableFog(false); gl_RenderState.EnableFog(false);
gl_RenderState.ResetColor(); gl_RenderState.ResetColor();
gl_RenderState.Apply(); gl_RenderState.Apply();
delete vb;
FGLDebug::PopGroup(); FGLDebug::PopGroup();
twoD.Unclock(); twoD.Unclock();
} }

View file

@ -30,8 +30,9 @@
#include "r_data/colormaps.h" #include "r_data/colormaps.h"
#include "gl_load/gl_system.h" #include "gl_load/gl_system.h"
#include "gl_load/gl_interface.h" #include "gl_load/gl_interface.h"
#include "gl/data/gl_vertexbuffer.h"
#include "hwrenderer/utility/hw_cvars.h" #include "hwrenderer/utility/hw_cvars.h"
#include "hwrenderer/data/flatvertices.h"
#include "hwrenderer/scene/hw_skydome.h"
#include "gl/shaders/gl_shader.h" #include "gl/shaders/gl_shader.h"
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
#include "gl/dynlights//gl_lightbuffer.h" #include "gl/dynlights//gl_lightbuffer.h"
@ -262,8 +263,6 @@ void FGLRenderState::ApplyState()
} }
void FGLRenderState::ApplyBuffers() void FGLRenderState::ApplyBuffers()
{
if (mVertexBuffer != nullptr)
{ {
if (mVertexBuffer != mCurrentVertexBuffer || mVertexOffsets[0] != mCurrentVertexOffsets[0] || mVertexOffsets[1] != mCurrentVertexOffsets[1]) if (mVertexBuffer != mCurrentVertexBuffer || mVertexOffsets[0] != mCurrentVertexOffsets[0] || mVertexOffsets[1] != mCurrentVertexOffsets[1])
{ {
@ -272,7 +271,6 @@ void FGLRenderState::ApplyBuffers()
mCurrentVertexBuffer = mVertexBuffer; mCurrentVertexBuffer = mVertexBuffer;
mCurrentVertexOffsets[0] = mVertexOffsets[0]; mCurrentVertexOffsets[0] = mVertexOffsets[0];
mCurrentVertexOffsets[1] = mVertexOffsets[1]; mCurrentVertexOffsets[1] = mVertexOffsets[1];
mCurrentFVertexBuffer = nullptr;
} }
if (mIndexBuffer != mCurrentIndexBuffer) if (mIndexBuffer != mCurrentIndexBuffer)
{ {
@ -280,15 +278,6 @@ void FGLRenderState::ApplyBuffers()
mCurrentIndexBuffer = mIndexBuffer; mCurrentIndexBuffer = mIndexBuffer;
} }
} }
else if (mFVertexBuffer != mCurrentFVertexBuffer)
{
if (mFVertexBuffer == NULL) glBindBuffer(GL_ARRAY_BUFFER, 0);
else mFVertexBuffer->BindVBO();
mCurrentFVertexBuffer = mFVertexBuffer;
mCurrentVertexBuffer = nullptr;
mCurrentIndexBuffer = nullptr;
}
}
void FGLRenderState::Apply() void FGLRenderState::Apply()
{ {
@ -391,10 +380,3 @@ void FGLRenderState::ApplyBlendMode()
} }
} }
// Needs to be redone
void FGLRenderState::SetVertexBuffer(int which)
{
if (which == VB_Sky) GLRenderer->mSkyVBO->Bind(*this);
else GLRenderer->mVBO->Bind(*this);
}

View file

@ -34,7 +34,6 @@
#include "r_data/r_translate.h" #include "r_data/r_translate.h"
#include "g_levellocals.h" #include "g_levellocals.h"
class FVertexBuffer;
class FShader; class FShader;
struct GLSectorPlane; struct GLSectorPlane;
extern TArray<VSMatrix> gl_MatrixStack; extern TArray<VSMatrix> gl_MatrixStack;
@ -56,8 +55,6 @@ class FGLRenderState : public FRenderState
float mInterpolationFactor; float mInterpolationFactor;
FVertexBuffer *mFVertexBuffer, *mCurrentFVertexBuffer;
int mEffectState; int mEffectState;
int mTempTM = TM_NORMAL; int mTempTM = TM_NORMAL;
@ -107,17 +104,9 @@ public:
void ApplyLightIndex(int index); void ApplyLightIndex(int index);
void ApplyBlendMode(); void ApplyBlendMode();
void SetVertexBuffer(FVertexBuffer *vb)
{
mFVertexBuffer = vb;
mVertexBuffer = nullptr;
mIndexBuffer = nullptr;
}
void ResetVertexBuffer() void ResetVertexBuffer()
{ {
// forces rebinding with the next 'apply' call. // forces rebinding with the next 'apply' call.
mCurrentFVertexBuffer = nullptr;
mVertexBuffer = nullptr; mVertexBuffer = nullptr;
mIndexBuffer = nullptr; mIndexBuffer = nullptr;
} }
@ -174,8 +163,6 @@ public:
return mPassType == GBUFFER_PASS ? 3 : 1; return mPassType == GBUFFER_PASS ? 3 : 1;
} }
void SetVertexBuffer(int which) override;
}; };
extern FGLRenderState gl_RenderState; extern FGLRenderState gl_RenderState;

View file

@ -34,8 +34,9 @@
#include "g_levellocals.h" #include "g_levellocals.h"
#include "tarray.h" #include "tarray.h"
#include "hwrenderer/scene/hw_drawstructs.h" #include "hwrenderer/scene/hw_drawstructs.h"
#include "hwrenderer/data/flatvertices.h"
#include "hwrenderer/utility/hw_clock.h"
#include "gl/data/gl_vertexbuffer.h"
#include "gl/scene/gl_drawinfo.h" #include "gl/scene/gl_drawinfo.h"
#include "hwrenderer/scene/hw_clipper.h" #include "hwrenderer/scene/hw_clipper.h"
#include "gl/renderer/gl_renderstate.h" #include "gl/renderer/gl_renderstate.h"
@ -259,6 +260,7 @@ void FDrawInfo::RenderPortal(HWPortal *p, bool usestencil)
gl_RenderState.SetLightIndex(-1); gl_RenderState.SetLightIndex(-1);
gp->DrawContents(new_di, gl_RenderState); gp->DrawContents(new_di, gl_RenderState);
new_di->EndDrawInfo(); new_di->EndDrawInfo();
GLRenderer->mVBO->Bind(gl_RenderState);
GLRenderer->mViewpoints->Bind(vpIndex); GLRenderer->mViewpoints->Bind(vpIndex);
gp->RemoveStencil(this, gl_RenderState, usestencil); gp->RemoveStencil(this, gl_RenderState, usestencil);

View file

@ -39,7 +39,10 @@
#include "p_local.h" #include "p_local.h"
#include "serializer.h" #include "serializer.h"
#include "g_levellocals.h" #include "g_levellocals.h"
#include "r_data/models/models.h"
#include "hwrenderer/dynlights/hw_dynlightdata.h" #include "hwrenderer/dynlights/hw_dynlightdata.h"
#include "hwrenderer/utility/hw_clock.h"
#include "hwrenderer/data/flatvertices.h"
#include "gl/dynlights/gl_lightbuffer.h" #include "gl/dynlights/gl_lightbuffer.h"
#include "gl_load/gl_interface.h" #include "gl_load/gl_interface.h"
@ -48,7 +51,6 @@
#include "hwrenderer/utility/hw_cvars.h" #include "hwrenderer/utility/hw_cvars.h"
#include "gl/renderer/gl_renderstate.h" #include "gl/renderer/gl_renderstate.h"
#include "gl/renderer/gl_renderbuffers.h" #include "gl/renderer/gl_renderbuffers.h"
#include "gl/data/gl_vertexbuffer.h"
#include "gl/data/gl_viewpointbuffer.h" #include "gl/data/gl_viewpointbuffer.h"
#include "hwrenderer/scene/hw_clipper.h" #include "hwrenderer/scene/hw_clipper.h"
#include "hwrenderer/scene/hw_portal.h" #include "hwrenderer/scene/hw_portal.h"

View file

@ -31,7 +31,6 @@
#include "gl_load/gl_interface.h" #include "gl_load/gl_interface.h"
#include "hwrenderer/utility/hw_cvars.h" #include "hwrenderer/utility/hw_cvars.h"
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
#include "gl/data/gl_vertexbuffer.h"
#include "gl/dynlights/gl_lightbuffer.h" #include "gl/dynlights/gl_lightbuffer.h"
#include "gl/scene/gl_drawinfo.h" #include "gl/scene/gl_drawinfo.h"

View file

@ -38,7 +38,6 @@
#include "gl/textures/gl_samplers.h" #include "gl/textures/gl_samplers.h"
#include "hwrenderer/utility/hw_clock.h" #include "hwrenderer/utility/hw_clock.h"
#include "hwrenderer/utility/hw_vrmodes.h" #include "hwrenderer/utility/hw_vrmodes.h"
#include "gl/data/gl_vertexbuffer.h"
#include "gl/data/gl_uniformbuffer.h" #include "gl/data/gl_uniformbuffer.h"
#include "gl/models/gl_models.h" #include "gl/models/gl_models.h"
#include "gl/shaders/gl_shaderprogram.h" #include "gl/shaders/gl_shaderprogram.h"
@ -46,6 +45,8 @@
#include "r_videoscale.h" #include "r_videoscale.h"
#include "glsys_vertexbuffer.h" #include "glsys_vertexbuffer.h"
#include "hwrenderer/data/flatvertices.h"
EXTERN_CVAR (Bool, vid_vsync) EXTERN_CVAR (Bool, vid_vsync)
FGLRenderer *GLRenderer; FGLRenderer *GLRenderer;

View file

@ -407,17 +407,7 @@ public:
mIndexBuffer = ib; mIndexBuffer = ib;
} }
void SetColor(int sectorlightlevel, int rellight, bool fullbright, const FColormap &cm, float alpha, bool weapon = false); 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); void SetFog(int lightlevel, int rellight, bool fullbright, const FColormap *cmap, bool isadditive);
// Temporary helper to get around the lack of hardware independent vertex buffer interface.
// This needs to be done better so that abstract interfaces can be passed around between hwrenderer and the backends.
enum
{
VB_Default,
VB_Sky
};
virtual void SetVertexBuffer(int which) = 0;
}; };

View file

@ -180,7 +180,7 @@ void HWSkyPortal::DrawContents(HWDrawInfo *di, FRenderState &state)
di->SetupView(0, 0, 0, !!(mState->MirrorFlag & 1), !!(mState->PlaneMirrorFlag & 1)); di->SetupView(0, 0, 0, !!(mState->MirrorFlag & 1), !!(mState->PlaneMirrorFlag & 1));
state.SetVertexBuffer(FRenderState::VB_Sky); vertexBuffer->Bind(state);
if (origin->texture[0] && origin->texture[0]->tex->bSkybox) if (origin->texture[0] && origin->texture[0]->tex->bSkybox)
{ {
RenderBox(di, state, origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->sky2); RenderBox(di, state, origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->sky2);
@ -215,7 +215,6 @@ void HWSkyPortal::DrawContents(HWDrawInfo *di, FRenderState &state)
state.SetObjectColor(0xffffffff); state.SetObjectColor(0xffffffff);
} }
} }
state.SetVertexBuffer(FRenderState::VB_Default);
::level.lightmode = oldlightmode; ::level.lightmode = oldlightmode;
di->SetDepthClamp(oldClamp); di->SetDepthClamp(oldClamp);
} }