mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-20 10:25:40 +00:00
Implemented TFlags for easy, type-safe bitflags
This commit is contained in:
@@ -35,14 +35,14 @@ void CDynamicVertexBuffer::Unbind()
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
void CDynamicVertexBuffer::SetActiveAttribs(u32 AttribFlags)
|
||||
void CDynamicVertexBuffer::SetActiveAttribs(FVertexDescription AttribFlags)
|
||||
{
|
||||
ClearBuffers();
|
||||
mAttribFlags = (EVertexDescription) AttribFlags;
|
||||
mAttribFlags = AttribFlags;
|
||||
InitBuffers();
|
||||
}
|
||||
|
||||
void CDynamicVertexBuffer::BufferAttrib(EVertexDescription Attrib, const void *pData)
|
||||
void CDynamicVertexBuffer::BufferAttrib(EVertexAttribute Attrib, const void *pData)
|
||||
{
|
||||
u32 Index;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef CDYNAMICVERTEXBUFFER_H
|
||||
#define CDYNAMICVERTEXBUFFER_H
|
||||
|
||||
#include "Core/Resource/Model/EVertexDescription.h"
|
||||
#include "Core/Resource/Model/EVertexAttribute.h"
|
||||
#include <Common/types.h>
|
||||
#include <Math/CVector2f.h>
|
||||
#include <Math/CVector3f.h>
|
||||
@@ -11,8 +11,8 @@
|
||||
|
||||
class CDynamicVertexBuffer
|
||||
{
|
||||
EVertexDescription mAttribFlags;
|
||||
EVertexDescription mBufferedFlags;
|
||||
FVertexDescription mAttribFlags;
|
||||
FVertexDescription mBufferedFlags;
|
||||
u32 mNumVertices;
|
||||
GLuint mAttribBuffers[12];
|
||||
|
||||
@@ -22,8 +22,8 @@ public:
|
||||
void SetVertexCount(u32 NumVerts);
|
||||
void Bind();
|
||||
void Unbind();
|
||||
void SetActiveAttribs(u32 AttribFlags);
|
||||
void BufferAttrib(EVertexDescription Attrib, const void *pData);
|
||||
void SetActiveAttribs(FVertexDescription AttribFlags);
|
||||
void BufferAttrib(EVertexAttribute Attrib, const void *pData);
|
||||
void ClearBuffers();
|
||||
GLuint CreateVAO();
|
||||
private:
|
||||
|
||||
@@ -153,7 +153,7 @@ bool CShaderGenerator::CreateVertexShader(const CMaterial& Mat)
|
||||
|
||||
// Input
|
||||
ShaderCode << "// Input\n";
|
||||
EVertexDescription VtxDesc = Mat.VtxDesc();
|
||||
FVertexDescription VtxDesc = Mat.VtxDesc();
|
||||
if (VtxDesc & ePosition) ShaderCode << "layout(location = 0) in vec3 RawPosition;\n";
|
||||
if (VtxDesc & eNormal) ShaderCode << "layout(location = 1) in vec3 RawNormal;\n";
|
||||
if (VtxDesc & eColor0) ShaderCode << "layout(location = 2) in vec4 RawColor0;\n";
|
||||
@@ -308,7 +308,7 @@ bool CShaderGenerator::CreatePixelShader(const CMaterial& Mat)
|
||||
ShaderCode << "#version 330 core\n"
|
||||
<< "\n";
|
||||
|
||||
EVertexDescription VtxDesc = Mat.VtxDesc();
|
||||
FVertexDescription VtxDesc = Mat.VtxDesc();
|
||||
if (VtxDesc & ePosition) ShaderCode << "in vec3 Position;\n";
|
||||
if (VtxDesc & eNormal) ShaderCode << "in vec3 Normal;\n";
|
||||
if (VtxDesc & eColor0) ShaderCode << "in vec4 Color0;\n";
|
||||
|
||||
@@ -7,7 +7,7 @@ CVertexBuffer::CVertexBuffer()
|
||||
SetVertexDesc(ePosition | eNormal | eTex0 | eTex1 | eTex2 | eTex3 | eTex4 | eTex5 | eTex6 | eTex7);
|
||||
}
|
||||
|
||||
CVertexBuffer::CVertexBuffer(EVertexDescription Desc)
|
||||
CVertexBuffer::CVertexBuffer(FVertexDescription Desc)
|
||||
{
|
||||
mBuffered = false;
|
||||
SetVertexDesc(Desc);
|
||||
@@ -174,12 +174,12 @@ bool CVertexBuffer::IsBuffered()
|
||||
return mBuffered;
|
||||
}
|
||||
|
||||
EVertexDescription CVertexBuffer::VertexDesc()
|
||||
FVertexDescription CVertexBuffer::VertexDesc()
|
||||
{
|
||||
return mVtxDesc;
|
||||
}
|
||||
|
||||
void CVertexBuffer::SetVertexDesc(EVertexDescription Desc)
|
||||
void CVertexBuffer::SetVertexDesc(FVertexDescription Desc)
|
||||
{
|
||||
Clear();
|
||||
mVtxDesc = Desc;
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
#define CVERTEXBUFFER_H
|
||||
|
||||
#include "Core/Resource/Model/CVertex.h"
|
||||
#include "Core/Resource/Model/EVertexDescription.h"
|
||||
#include "Core/Resource/Model/EVertexAttribute.h"
|
||||
#include <vector>
|
||||
#include <GL/glew.h>
|
||||
|
||||
class CVertexBuffer
|
||||
{
|
||||
EVertexDescription mVtxDesc; // Flags that indicate what vertex attributes are enabled on this vertex buffer
|
||||
FVertexDescription mVtxDesc; // Flags that indicate what vertex attributes are enabled on this vertex buffer
|
||||
GLuint mAttribBuffers[12]; // Separate GL buffer for each attribute to allow not tracking unused attribs. No support for matrix indices currently.
|
||||
std::vector<CVector3f> mPositions; // Vector of vertex positions
|
||||
std::vector<CVector3f> mNormals; // Vector of vertex normals
|
||||
@@ -18,7 +18,7 @@ class CVertexBuffer
|
||||
|
||||
public:
|
||||
CVertexBuffer();
|
||||
CVertexBuffer(EVertexDescription Desc);
|
||||
CVertexBuffer(FVertexDescription Desc);
|
||||
~CVertexBuffer();
|
||||
u16 AddVertex(const CVertex& vtx);
|
||||
u16 AddIfUnique(const CVertex& vtx, u16 start);
|
||||
@@ -28,8 +28,8 @@ public:
|
||||
void Bind();
|
||||
void Unbind();
|
||||
bool IsBuffered();
|
||||
EVertexDescription VertexDesc();
|
||||
void SetVertexDesc(EVertexDescription Desc);
|
||||
FVertexDescription VertexDesc();
|
||||
void SetVertexDesc(FVertexDescription Desc);
|
||||
u32 Size();
|
||||
GLuint CreateVAO();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user