From 412d6499d967c9ab660c76756df39c1ee7cec0ed Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 19 Jun 2014 14:46:55 +0200 Subject: [PATCH] - removed the voxel vertex buffer because it needs to be gone before implementing a model vertex buffer. --- src/gl/models/gl_models.cpp | 13 --- src/gl/models/gl_models.h | 6 -- src/gl/models/gl_voxels.cpp | 139 ++------------------------------ src/gl/renderer/gl_renderer.cpp | 1 - 4 files changed, 7 insertions(+), 152 deletions(-) diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 76e8006aa..fc248b2cc 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -899,16 +899,3 @@ bool gl_IsHUDModelForPlayerAvailable (player_t * player) return ( smf != NULL ); } -//=========================================================================== -// -// gl_CleanModelData -// -//=========================================================================== - -void gl_CleanModelData() -{ - for (unsigned i=0;iCleanGLData(); - } -} diff --git a/src/gl/models/gl_models.h b/src/gl/models/gl_models.h index 181784b9b..e20010931 100644 --- a/src/gl/models/gl_models.h +++ b/src/gl/models/gl_models.h @@ -30,8 +30,6 @@ public: virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length) = 0; virtual int FindFrame(const char * name) = 0; virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0) = 0; - virtual void MakeGLData() {} - virtual void CleanGLData() {} @@ -274,7 +272,6 @@ protected: bool mOwningVoxel; // if created through MODELDEF deleting this object must also delete the voxel object TArray mVertices; TArray mIndices; - FVoxelVertexBuffer *mVBO; FTexture *mPalette; void MakeSlabPolys(int x, int y, kvxslab_t *voxptr, FVoxelMap &check); @@ -286,8 +283,6 @@ public: ~FVoxelModel(); bool Load(const char * fn, int lumpnum, const char * buffer, int length); void Initialize(); - void MakeGLData(); - void CleanGLData(); virtual int FindFrame(const char * name); virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0); FTexture *GetPaletteTexture() const { return mPalette; } @@ -345,6 +340,5 @@ void gl_RenderModel(GLSprite * spr); // [BB] HUD weapon model rendering functions. void gl_RenderHUDModel(pspdef_t *psp, fixed_t ofsx, fixed_t ofsy); bool gl_IsHUDModelForPlayerAvailable (player_t * player); -void gl_CleanModelData(); #endif diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp index 873390f9c..e1fb094af 100644 --- a/src/gl/models/gl_voxels.cpp +++ b/src/gl/models/gl_voxels.cpp @@ -203,92 +203,6 @@ int FVoxelTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, F return 0; } -//=========================================================================== -// -// -// -//=========================================================================== - - -class FVoxelVertexBuffer : public FVertexBuffer -{ - unsigned int ibo_id; - bool isint; - -public: - FVoxelVertexBuffer(TArray &verts, TArray &indices); - ~FVoxelVertexBuffer(); - void BindVBO(); - bool IsInt() const { return isint; } -}; - - -//=========================================================================== -// -// -// -//=========================================================================== - -FVoxelVertexBuffer::FVoxelVertexBuffer(TArray &verts, TArray &indices) -{ - ibo_id = 0; - glGenBuffers(1, &ibo_id); - - glBindBuffer(GL_ARRAY_BUFFER, vbo_id); - glBufferData(GL_ARRAY_BUFFER, verts.Size() * sizeof(FVoxelVertex), &verts[0], GL_STATIC_DRAW); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); - if (verts.Size() > 65535) - { - glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.Size() * sizeof(unsigned int), &indices[0], GL_STATIC_DRAW); - isint = true; - } - else - { - unsigned short *sbuffer = new unsigned short[indices.Size()]; - for(unsigned i=0;ix); - glTexCoordPointer(2,GL_FLOAT, sizeof(FVoxelVertex), &VVO->u); - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glDisableClientState(GL_COLOR_ARRAY); -} - - - //=========================================================================== // // @@ -299,7 +213,6 @@ FVoxelModel::FVoxelModel(FVoxel *voxel, bool owned) { mVoxel = voxel; mOwningVoxel = owned; - mVBO = NULL; mPalette = new FVoxelTexture(voxel); Initialize(); } @@ -312,7 +225,6 @@ FVoxelModel::FVoxelModel(FVoxel *voxel, bool owned) FVoxelModel::~FVoxelModel() { - CleanGLData(); delete mPalette; if (mOwningVoxel) delete mVoxel; } @@ -459,32 +371,6 @@ bool FVoxelModel::Load(const char * fn, int lumpnum, const char * buffer, int le return false; // not needed } -//=========================================================================== -// -// -// -//=========================================================================== - -void FVoxelModel::MakeGLData() -{ - mVBO = new FVoxelVertexBuffer(mVertices, mIndices); -} - -//=========================================================================== -// -// -// -//=========================================================================== - -void FVoxelModel::CleanGLData() -{ - if (mVBO != NULL) - { - delete mVBO; - mVBO = NULL; - } -} - //=========================================================================== // // Voxels don't have frames so always return 0 @@ -507,25 +393,14 @@ void FVoxelModel::RenderFrame(FTexture * skin, int frame, int frame2, double int FMaterial * tex = FMaterial::ValidateTexture(skin); tex->Bind(0, translation); - if (mVBO == NULL) MakeGLData(); - if (mVBO != NULL) + gl_RenderState.Apply(); + glBegin(GL_QUADS); + for (unsigned i = 0; i < mIndices.Size(); i++) { - gl_RenderState.SetVertexBuffer(mVBO); - gl_RenderState.Apply(); - glDrawElements(GL_QUADS, mIndices.Size(), mVBO->IsInt() ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT, 0); - gl_RenderState.SetVertexBuffer(GLRenderer->mVBO); - } - else - { - gl_RenderState.Apply(); - glBegin(GL_QUADS); - for (unsigned i = 0; i < mIndices.Size(); i++) - { - FVoxelVertex *vert = &mVertices[mIndices[i]]; - glTexCoord2fv(&vert->u); - glVertex3fv(&vert->x); - } - glEnd(); + FVoxelVertex *vert = &mVertices[mIndices[i]]; + glTexCoord2fv(&vert->u); + glVertex3fv(&vert->x); } + glEnd(); } diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 78ec2e34e..a51e1fc37 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -118,7 +118,6 @@ void FGLRenderer::Initialize() FGLRenderer::~FGLRenderer() { - gl_CleanModelData(); gl_DeleteAllAttachedLights(); FMaterial::FlushAll(); //if (mThreadManager != NULL) delete mThreadManager;