mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-12-16 15:21:02 +00:00
87 lines
No EOL
1.6 KiB
C++
87 lines
No EOL
1.6 KiB
C++
#ifndef __VERTEXBUFFER_H
|
|
#define __VERTEXBUFFER_H
|
|
|
|
#include "tarray.h"
|
|
|
|
struct vertex_t;
|
|
struct secplane_t;
|
|
struct subsector_t;
|
|
struct sector_t;
|
|
|
|
|
|
class FVertexBuffer
|
|
{
|
|
protected:
|
|
unsigned int vbo_id;
|
|
|
|
public:
|
|
FVertexBuffer();
|
|
virtual ~FVertexBuffer();
|
|
virtual void BindVBO() = 0;
|
|
};
|
|
|
|
struct FFlatVertex
|
|
{
|
|
float x,z,y; // world position
|
|
float u,v; // texture coordinates
|
|
|
|
void SetFlatVertex(vertex_t *vt, const secplane_t &plane);
|
|
void Set(float xx, float zz, float yy, float uu, float vv)
|
|
{
|
|
x = xx;
|
|
z = zz;
|
|
y = yy;
|
|
u = uu;
|
|
v = vv;
|
|
}
|
|
};
|
|
|
|
#define VTO ((FFlatVertex*)NULL)
|
|
|
|
|
|
class FFlatVertexBuffer : public FVertexBuffer
|
|
{
|
|
FFlatVertex *map;
|
|
unsigned int mIndex;
|
|
unsigned int mCurIndex;
|
|
|
|
void CheckPlanes(sector_t *sector);
|
|
|
|
public:
|
|
int vbo_arg;
|
|
TArray<FFlatVertex> vbo_shadowdata; // this is kept around for updating the actual (non-readable) buffer
|
|
|
|
FFlatVertexBuffer();
|
|
~FFlatVertexBuffer();
|
|
|
|
void CreateVBO();
|
|
void BindVBO();
|
|
void CheckUpdate(sector_t *sector);
|
|
|
|
FFlatVertex *GetBuffer()
|
|
{
|
|
return &map[mCurIndex];
|
|
}
|
|
unsigned int GetCount(FFlatVertex *newptr, unsigned int *poffset)
|
|
{
|
|
unsigned int newofs = (unsigned int)(newptr - map);
|
|
unsigned int diff = newofs - mCurIndex;
|
|
*poffset = mCurIndex;
|
|
mCurIndex = newofs;
|
|
return diff;
|
|
}
|
|
void Reset()
|
|
{
|
|
mCurIndex = mIndex;
|
|
}
|
|
|
|
private:
|
|
int CreateSubsectorVertices(subsector_t *sub, const secplane_t &plane, int floor);
|
|
int CreateSectorVertices(sector_t *sec, const secplane_t &plane, int floor);
|
|
int CreateVertices(int h, sector_t *sec, const secplane_t &plane, int floor);
|
|
void CreateFlatVBO();
|
|
void UpdatePlaneVertices(sector_t *sec, int plane);
|
|
|
|
};
|
|
|
|
#endif |