mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 23:32:02 +00:00
- removed the voxel vertex buffer because it needs to be gone before implementing a model vertex buffer.
This commit is contained in:
parent
03916d75de
commit
412d6499d9
4 changed files with 7 additions and 152 deletions
|
@ -899,16 +899,3 @@ bool gl_IsHUDModelForPlayerAvailable (player_t * player)
|
||||||
return ( smf != NULL );
|
return ( smf != NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
// gl_CleanModelData
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
void gl_CleanModelData()
|
|
||||||
{
|
|
||||||
for (unsigned i=0;i<Models.Size(); i++)
|
|
||||||
{
|
|
||||||
Models[i]->CleanGLData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -30,8 +30,6 @@ public:
|
||||||
virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length) = 0;
|
virtual bool Load(const char * fn, int lumpnum, const char * buffer, int length) = 0;
|
||||||
virtual int FindFrame(const char * name) = 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 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
|
bool mOwningVoxel; // if created through MODELDEF deleting this object must also delete the voxel object
|
||||||
TArray<FVoxelVertex> mVertices;
|
TArray<FVoxelVertex> mVertices;
|
||||||
TArray<unsigned int> mIndices;
|
TArray<unsigned int> mIndices;
|
||||||
FVoxelVertexBuffer *mVBO;
|
|
||||||
FTexture *mPalette;
|
FTexture *mPalette;
|
||||||
|
|
||||||
void MakeSlabPolys(int x, int y, kvxslab_t *voxptr, FVoxelMap &check);
|
void MakeSlabPolys(int x, int y, kvxslab_t *voxptr, FVoxelMap &check);
|
||||||
|
@ -286,8 +283,6 @@ public:
|
||||||
~FVoxelModel();
|
~FVoxelModel();
|
||||||
bool Load(const char * fn, int lumpnum, const char * buffer, int length);
|
bool Load(const char * fn, int lumpnum, const char * buffer, int length);
|
||||||
void Initialize();
|
void Initialize();
|
||||||
void MakeGLData();
|
|
||||||
void CleanGLData();
|
|
||||||
virtual int FindFrame(const char * name);
|
virtual int FindFrame(const char * name);
|
||||||
virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0);
|
virtual void RenderFrame(FTexture * skin, int frame, int frame2, double inter, int translation=0);
|
||||||
FTexture *GetPaletteTexture() const { return mPalette; }
|
FTexture *GetPaletteTexture() const { return mPalette; }
|
||||||
|
@ -345,6 +340,5 @@ void gl_RenderModel(GLSprite * spr);
|
||||||
// [BB] HUD weapon model rendering functions.
|
// [BB] HUD weapon model rendering functions.
|
||||||
void gl_RenderHUDModel(pspdef_t *psp, fixed_t ofsx, fixed_t ofsy);
|
void gl_RenderHUDModel(pspdef_t *psp, fixed_t ofsx, fixed_t ofsy);
|
||||||
bool gl_IsHUDModelForPlayerAvailable (player_t * player);
|
bool gl_IsHUDModelForPlayerAvailable (player_t * player);
|
||||||
void gl_CleanModelData();
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -203,92 +203,6 @@ int FVoxelTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, F
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
|
|
||||||
class FVoxelVertexBuffer : public FVertexBuffer
|
|
||||||
{
|
|
||||||
unsigned int ibo_id;
|
|
||||||
bool isint;
|
|
||||||
|
|
||||||
public:
|
|
||||||
FVoxelVertexBuffer(TArray<FVoxelVertex> &verts, TArray<unsigned int> &indices);
|
|
||||||
~FVoxelVertexBuffer();
|
|
||||||
void BindVBO();
|
|
||||||
bool IsInt() const { return isint; }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
FVoxelVertexBuffer::FVoxelVertexBuffer(TArray<FVoxelVertex> &verts, TArray<unsigned int> &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;i<indices.Size();i++)
|
|
||||||
{
|
|
||||||
sbuffer[i] = (unsigned short)indices[i];
|
|
||||||
}
|
|
||||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.Size() * sizeof(unsigned short), sbuffer, GL_STATIC_DRAW);
|
|
||||||
delete [] sbuffer;
|
|
||||||
isint = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
FVoxelVertexBuffer::~FVoxelVertexBuffer()
|
|
||||||
{
|
|
||||||
if (ibo_id != 0)
|
|
||||||
{
|
|
||||||
glDeleteBuffers(1, &ibo_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
#define VVO ((FVoxelVertex*)NULL)
|
|
||||||
|
|
||||||
void FVoxelVertexBuffer::BindVBO()
|
|
||||||
{
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id);
|
|
||||||
glVertexPointer(3,GL_FLOAT, sizeof(FVoxelVertex), &VVO->x);
|
|
||||||
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;
|
mVoxel = voxel;
|
||||||
mOwningVoxel = owned;
|
mOwningVoxel = owned;
|
||||||
mVBO = NULL;
|
|
||||||
mPalette = new FVoxelTexture(voxel);
|
mPalette = new FVoxelTexture(voxel);
|
||||||
Initialize();
|
Initialize();
|
||||||
}
|
}
|
||||||
|
@ -312,7 +225,6 @@ FVoxelModel::FVoxelModel(FVoxel *voxel, bool owned)
|
||||||
|
|
||||||
FVoxelModel::~FVoxelModel()
|
FVoxelModel::~FVoxelModel()
|
||||||
{
|
{
|
||||||
CleanGLData();
|
|
||||||
delete mPalette;
|
delete mPalette;
|
||||||
if (mOwningVoxel) delete mVoxel;
|
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
|
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
|
// Voxels don't have frames so always return 0
|
||||||
|
@ -507,16 +393,6 @@ void FVoxelModel::RenderFrame(FTexture * skin, int frame, int frame2, double int
|
||||||
FMaterial * tex = FMaterial::ValidateTexture(skin);
|
FMaterial * tex = FMaterial::ValidateTexture(skin);
|
||||||
tex->Bind(0, translation);
|
tex->Bind(0, translation);
|
||||||
|
|
||||||
if (mVBO == NULL) MakeGLData();
|
|
||||||
if (mVBO != NULL)
|
|
||||||
{
|
|
||||||
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();
|
gl_RenderState.Apply();
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
for (unsigned i = 0; i < mIndices.Size(); i++)
|
for (unsigned i = 0; i < mIndices.Size(); i++)
|
||||||
|
@ -527,5 +403,4 @@ void FVoxelModel::RenderFrame(FTexture * skin, int frame, int frame2, double int
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,6 @@ void FGLRenderer::Initialize()
|
||||||
|
|
||||||
FGLRenderer::~FGLRenderer()
|
FGLRenderer::~FGLRenderer()
|
||||||
{
|
{
|
||||||
gl_CleanModelData();
|
|
||||||
gl_DeleteAllAttachedLights();
|
gl_DeleteAllAttachedLights();
|
||||||
FMaterial::FlushAll();
|
FMaterial::FlushAll();
|
||||||
//if (mThreadManager != NULL) delete mThreadManager;
|
//if (mThreadManager != NULL) delete mThreadManager;
|
||||||
|
|
Loading…
Reference in a new issue