mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-21 10:49:23 +00:00
Refactor so PWE compiles with the newly externalized LibCommon
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "CDynamicVertexBuffer.h"
|
||||
#include "CVertexArrayManager.h"
|
||||
|
||||
static const u32 gskAttribSize[] = {
|
||||
static const uint32 gskAttribSize[] = {
|
||||
0xC, 0xC, 0x4, 0x4, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ CDynamicVertexBuffer::~CDynamicVertexBuffer()
|
||||
ClearBuffers();
|
||||
}
|
||||
|
||||
void CDynamicVertexBuffer::SetVertexCount(u32 NumVerts)
|
||||
void CDynamicVertexBuffer::SetVertexCount(uint32 NumVerts)
|
||||
{
|
||||
ClearBuffers();
|
||||
mNumVertices = NumVerts;
|
||||
@@ -44,7 +44,7 @@ void CDynamicVertexBuffer::SetActiveAttribs(FVertexDescription AttribFlags)
|
||||
|
||||
void CDynamicVertexBuffer::BufferAttrib(EVertexAttribute Attrib, const void *pkData)
|
||||
{
|
||||
u32 Index;
|
||||
uint32 Index;
|
||||
|
||||
switch (Attrib)
|
||||
{
|
||||
@@ -69,7 +69,7 @@ void CDynamicVertexBuffer::BufferAttrib(EVertexAttribute Attrib, const void *pkD
|
||||
|
||||
void CDynamicVertexBuffer::ClearBuffers()
|
||||
{
|
||||
for (u32 iAttrib = 0; iAttrib < 12; iAttrib++)
|
||||
for (uint32 iAttrib = 0; iAttrib < 12; iAttrib++)
|
||||
{
|
||||
int Bit = 1 << iAttrib;
|
||||
|
||||
@@ -86,7 +86,7 @@ GLuint CDynamicVertexBuffer::CreateVAO()
|
||||
glGenVertexArrays(1, &VertexArray);
|
||||
glBindVertexArray(VertexArray);
|
||||
|
||||
for (u32 iAttrib = 0; iAttrib < 12; iAttrib++)
|
||||
for (uint32 iAttrib = 0; iAttrib < 12; iAttrib++)
|
||||
{
|
||||
bool HasAttrib = ((3 << (iAttrib * 2)) != 0);
|
||||
|
||||
@@ -121,7 +121,7 @@ void CDynamicVertexBuffer::InitBuffers()
|
||||
{
|
||||
if (mBufferedFlags) ClearBuffers();
|
||||
|
||||
for (u32 iAttrib = 0; iAttrib < 12; iAttrib++)
|
||||
for (uint32 iAttrib = 0; iAttrib < 12; iAttrib++)
|
||||
{
|
||||
bool HasAttrib = ((3 << (iAttrib * 2)) != 0);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define CDYNAMICVERTEXBUFFER_H
|
||||
|
||||
#include "Core/Resource/Model/EVertexAttribute.h"
|
||||
#include <Common/types.h>
|
||||
#include <Common/BasicTypes.h>
|
||||
|
||||
#include <vector>
|
||||
#include <GL/glew.h>
|
||||
@@ -11,13 +11,13 @@ class CDynamicVertexBuffer
|
||||
{
|
||||
FVertexDescription mAttribFlags;
|
||||
FVertexDescription mBufferedFlags;
|
||||
u32 mNumVertices;
|
||||
uint32 mNumVertices;
|
||||
GLuint mAttribBuffers[12];
|
||||
|
||||
public:
|
||||
CDynamicVertexBuffer();
|
||||
~CDynamicVertexBuffer();
|
||||
void SetVertexCount(u32 NumVerts);
|
||||
void SetVertexCount(uint32 NumVerts);
|
||||
void Bind();
|
||||
void Unbind();
|
||||
void SetActiveAttribs(FVertexDescription AttribFlags);
|
||||
|
||||
@@ -11,7 +11,7 @@ CFramebuffer::CFramebuffer()
|
||||
{
|
||||
}
|
||||
|
||||
CFramebuffer::CFramebuffer(u32 Width, u32 Height)
|
||||
CFramebuffer::CFramebuffer(uint32 Width, uint32 Height)
|
||||
: mpRenderbuffer(nullptr)
|
||||
, mpTexture(nullptr)
|
||||
, mWidth(0)
|
||||
@@ -60,7 +60,7 @@ void CFramebuffer::Bind(GLenum Target /*= GL_FRAMEBUFFER*/)
|
||||
glBindFramebuffer(Target, mFramebuffer);
|
||||
}
|
||||
|
||||
void CFramebuffer::Resize(u32 Width, u32 Height)
|
||||
void CFramebuffer::Resize(uint32 Width, uint32 Height)
|
||||
{
|
||||
if ((mWidth != Width) || (mHeight != Height))
|
||||
{
|
||||
@@ -109,7 +109,7 @@ void CFramebuffer::InitBuffers()
|
||||
mStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
|
||||
if (mStatus != GL_FRAMEBUFFER_COMPLETE)
|
||||
Log::Error("Framebuffer not complete; error " + TString::HexString((u32) mStatus, 0));
|
||||
errorf("Framebuffer not complete; error 0x%X", mStatus);
|
||||
}
|
||||
|
||||
// ************ STATIC ************
|
||||
|
||||
@@ -10,7 +10,7 @@ class CFramebuffer
|
||||
GLuint mFramebuffer;
|
||||
CRenderbuffer *mpRenderbuffer;
|
||||
CTexture *mpTexture;
|
||||
u32 mWidth, mHeight;
|
||||
uint32 mWidth, mHeight;
|
||||
bool mEnableMultisampling;
|
||||
bool mInitialized;
|
||||
GLenum mStatus;
|
||||
@@ -20,11 +20,11 @@ class CFramebuffer
|
||||
|
||||
public:
|
||||
CFramebuffer();
|
||||
CFramebuffer(u32 Width, u32 Height);
|
||||
CFramebuffer(uint32 Width, uint32 Height);
|
||||
~CFramebuffer();
|
||||
void Init();
|
||||
void Bind(GLenum Target = GL_FRAMEBUFFER);
|
||||
void Resize(u32 Width, u32 Height);
|
||||
void Resize(uint32 Width, uint32 Height);
|
||||
void SetMultisamplingEnabled(bool Enable);
|
||||
|
||||
// Accessors
|
||||
|
||||
@@ -17,19 +17,19 @@ CIndexBuffer::~CIndexBuffer()
|
||||
glDeleteBuffers(1, &mIndexBuffer);
|
||||
}
|
||||
|
||||
void CIndexBuffer::AddIndex(u16 Index)
|
||||
void CIndexBuffer::AddIndex(uint16 Index)
|
||||
{
|
||||
mIndices.push_back(Index);
|
||||
}
|
||||
|
||||
void CIndexBuffer::AddIndices(u16 *pIndices, u32 Count)
|
||||
void CIndexBuffer::AddIndices(uint16 *pIndices, uint Count)
|
||||
{
|
||||
Reserve(Count);
|
||||
for (u32 iIdx = 0; iIdx < Count; iIdx++)
|
||||
for (uint iIdx = 0; iIdx < Count; iIdx++)
|
||||
mIndices.push_back(*pIndices++);
|
||||
}
|
||||
|
||||
void CIndexBuffer::Reserve(u32 Size)
|
||||
void CIndexBuffer::Reserve(uint Size)
|
||||
{
|
||||
mIndices.reserve(mIndices.size() + Size);
|
||||
}
|
||||
@@ -50,7 +50,7 @@ void CIndexBuffer::Buffer()
|
||||
|
||||
glGenBuffers(1, &mIndexBuffer);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBuffer);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, mIndices.size() * sizeof(u16), mIndices.data(), GL_STATIC_DRAW);
|
||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, mIndices.size() * sizeof(uint16), mIndices.data(), GL_STATIC_DRAW);
|
||||
|
||||
mBuffered = true;
|
||||
}
|
||||
@@ -72,7 +72,7 @@ void CIndexBuffer::DrawElements()
|
||||
Unbind();
|
||||
}
|
||||
|
||||
void CIndexBuffer::DrawElements(u32 Offset, u32 Size)
|
||||
void CIndexBuffer::DrawElements(uint Offset, uint Size)
|
||||
{
|
||||
Bind();
|
||||
glDrawElements(mPrimitiveType, Size, GL_UNSIGNED_SHORT, (char*)0 + (Offset * 2));
|
||||
@@ -84,7 +84,7 @@ bool CIndexBuffer::IsBuffered()
|
||||
return mBuffered;
|
||||
}
|
||||
|
||||
u32 CIndexBuffer::GetSize()
|
||||
uint CIndexBuffer::GetSize()
|
||||
{
|
||||
return mIndices.size();
|
||||
}
|
||||
@@ -99,11 +99,11 @@ void CIndexBuffer::SetPrimitiveType(GLenum Type)
|
||||
mPrimitiveType = Type;
|
||||
}
|
||||
|
||||
void CIndexBuffer::TrianglesToStrips(u16 *pIndices, u32 Count)
|
||||
void CIndexBuffer::TrianglesToStrips(uint16 *pIndices, uint Count)
|
||||
{
|
||||
Reserve(Count + (Count / 3));
|
||||
|
||||
for (u32 iIdx = 0; iIdx < Count; iIdx += 3)
|
||||
for (uint iIdx = 0; iIdx < Count; iIdx += 3)
|
||||
{
|
||||
mIndices.push_back(*pIndices++);
|
||||
mIndices.push_back(*pIndices++);
|
||||
@@ -112,12 +112,12 @@ void CIndexBuffer::TrianglesToStrips(u16 *pIndices, u32 Count)
|
||||
}
|
||||
}
|
||||
|
||||
void CIndexBuffer::FansToStrips(u16 *pIndices, u32 Count)
|
||||
void CIndexBuffer::FansToStrips(uint16 *pIndices, uint Count)
|
||||
{
|
||||
Reserve(Count);
|
||||
u16 FirstIndex = *pIndices;
|
||||
uint16 FirstIndex = *pIndices;
|
||||
|
||||
for (u32 iIdx = 2; iIdx < Count; iIdx += 3)
|
||||
for (uint iIdx = 2; iIdx < Count; iIdx += 3)
|
||||
{
|
||||
mIndices.push_back(pIndices[iIdx - 1]);
|
||||
mIndices.push_back(pIndices[iIdx]);
|
||||
@@ -130,11 +130,11 @@ void CIndexBuffer::FansToStrips(u16 *pIndices, u32 Count)
|
||||
}
|
||||
}
|
||||
|
||||
void CIndexBuffer::QuadsToStrips(u16 *pIndices, u32 Count)
|
||||
void CIndexBuffer::QuadsToStrips(uint16 *pIndices, uint Count)
|
||||
{
|
||||
Reserve((u32) (Count * 1.25));
|
||||
Reserve((uint) (Count * 1.25));
|
||||
|
||||
u32 iIdx = 3;
|
||||
uint iIdx = 3;
|
||||
for (; iIdx < Count; iIdx += 4)
|
||||
{
|
||||
mIndices.push_back(pIndices[iIdx - 2]);
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#ifndef CINDEXBUFFER_H
|
||||
#define CINDEXBUFFER_H
|
||||
|
||||
#include <Common/types.h>
|
||||
#include <Math/CVector3f.h>
|
||||
#include <Common/BasicTypes.h>
|
||||
#include <Common/Math/CVector3f.h>
|
||||
#include <GL/glew.h>
|
||||
|
||||
class CIndexBuffer
|
||||
{
|
||||
GLuint mIndexBuffer;
|
||||
std::vector<u16> mIndices;
|
||||
std::vector<uint16> mIndices;
|
||||
GLenum mPrimitiveType;
|
||||
bool mBuffered;
|
||||
|
||||
@@ -16,24 +16,24 @@ public:
|
||||
CIndexBuffer();
|
||||
CIndexBuffer(GLenum Type);
|
||||
~CIndexBuffer();
|
||||
void AddIndex(u16 Index);
|
||||
void AddIndices(u16 *pIndices, u32 Count);
|
||||
void Reserve(u32 Size);
|
||||
void AddIndex(uint16 Index);
|
||||
void AddIndices(uint16 *pIndices, uint Count);
|
||||
void Reserve(uint Size);
|
||||
void Clear();
|
||||
void Buffer();
|
||||
void Bind();
|
||||
void Unbind();
|
||||
void DrawElements();
|
||||
void DrawElements(u32 Offset, u32 Size);
|
||||
void DrawElements(uint Offset, uint Size);
|
||||
bool IsBuffered();
|
||||
|
||||
u32 GetSize();
|
||||
uint GetSize();
|
||||
GLenum GetPrimitiveType();
|
||||
void SetPrimitiveType(GLenum Type);
|
||||
|
||||
void TrianglesToStrips(u16 *pIndices, u32 Count);
|
||||
void FansToStrips(u16 *pIndices, u32 Count);
|
||||
void QuadsToStrips(u16 *pIndices, u32 Count);
|
||||
void TrianglesToStrips(uint16 *pIndices, uint Count);
|
||||
void FansToStrips(uint16 *pIndices, uint Count);
|
||||
void QuadsToStrips(uint16 *pIndices, uint Count);
|
||||
};
|
||||
|
||||
#endif // CINDEXBUFFER_H
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#ifndef CRENDERBUFFER_H
|
||||
#define CRENDERBUFFER_H
|
||||
|
||||
#include <Common/types.h>
|
||||
#include <Common/BasicTypes.h>
|
||||
#include <GL/glew.h>
|
||||
|
||||
class CRenderbuffer
|
||||
{
|
||||
GLuint mRenderbuffer;
|
||||
u32 mWidth, mHeight;
|
||||
uint mWidth, mHeight;
|
||||
bool mEnableMultisampling;
|
||||
bool mInitialized;
|
||||
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
CRenderbuffer::CRenderbuffer(u32 Width, u32 Height)
|
||||
CRenderbuffer::CRenderbuffer(uint Width, uint Height)
|
||||
: mWidth(Width)
|
||||
, mHeight(Height)
|
||||
, mEnableMultisampling(false)
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
InitStorage();
|
||||
}
|
||||
|
||||
inline void CRenderbuffer::Resize(u32 Width, u32 Height)
|
||||
inline void CRenderbuffer::Resize(uint Width, uint Height)
|
||||
{
|
||||
mWidth = Width;
|
||||
mHeight = Height;
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
#include "CShader.h"
|
||||
#include "Core/Render/CGraphics.h"
|
||||
#include <Common/BasicTypes.h>
|
||||
#include <Common/Log.h>
|
||||
#include <Common/TString.h>
|
||||
#include <Common/types.h>
|
||||
#include <Common/FileIO/CTextInStream.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
bool gDebugDumpShaders = false;
|
||||
u64 gFailedCompileCount = 0;
|
||||
u64 gSuccessfulCompileCount = 0;
|
||||
uint64 gFailedCompileCount = 0;
|
||||
uint64 gSuccessfulCompileCount = 0;
|
||||
|
||||
CShader* CShader::spCurrentShader = nullptr;
|
||||
int CShader::smNumShaders = 0;
|
||||
@@ -58,8 +57,8 @@ bool CShader::CompileVertexSource(const char* pkSource)
|
||||
if (CompileStatus == GL_FALSE)
|
||||
{
|
||||
TString Out = "dump/BadVS_" + std::to_string(gFailedCompileCount) + ".txt";
|
||||
Log::Error("Unable to compile vertex shader; dumped to " + Out);
|
||||
DumpShaderSource(mVertexShader, Out);
|
||||
errorf("Unable to compile vertex shader; dumped to %s", *Out);
|
||||
|
||||
gFailedCompileCount++;
|
||||
glDeleteShader(mVertexShader);
|
||||
@@ -70,8 +69,8 @@ bool CShader::CompileVertexSource(const char* pkSource)
|
||||
else if (gDebugDumpShaders == true)
|
||||
{
|
||||
TString Out = "dump/VS_" + TString::FromInt64(gSuccessfulCompileCount, 8, 10) + ".txt";
|
||||
Log::Write("Debug shader dumping enabled; dumped to " + Out);
|
||||
DumpShaderSource(mVertexShader, Out);
|
||||
debugf("Debug shader dumping enabled; dumped to %s", *Out);
|
||||
|
||||
gSuccessfulCompileCount++;
|
||||
}
|
||||
@@ -93,7 +92,7 @@ bool CShader::CompilePixelSource(const char* pkSource)
|
||||
if (CompileStatus == GL_FALSE)
|
||||
{
|
||||
TString Out = "dump/BadPS_" + TString::FromInt64(gFailedCompileCount, 8, 10) + ".txt";
|
||||
Log::Error("Unable to compile pixel shader; dumped to " + Out);
|
||||
errorf("Unable to compile pixel shader; dumped to %s", *Out);
|
||||
DumpShaderSource(mPixelShader, Out);
|
||||
|
||||
gFailedCompileCount++;
|
||||
@@ -105,7 +104,7 @@ bool CShader::CompilePixelSource(const char* pkSource)
|
||||
else if (gDebugDumpShaders == true)
|
||||
{
|
||||
TString Out = "dump/PS_" + TString::FromInt64(gSuccessfulCompileCount, 8, 10) + ".txt";
|
||||
Log::Write("Debug shader dumping enabled; dumped to " + Out);
|
||||
debugf("Debug shader dumping enabled; dumped to %s", *Out);
|
||||
DumpShaderSource(mPixelShader, Out);
|
||||
|
||||
gSuccessfulCompileCount++;
|
||||
@@ -136,7 +135,7 @@ bool CShader::LinkShaders()
|
||||
if (LinkStatus == GL_FALSE)
|
||||
{
|
||||
TString Out = "dump/BadLink_" + TString::FromInt64(gFailedCompileCount, 8, 10) + ".txt";
|
||||
Log::Error("Unable to link shaders. Dumped error log to " + Out);
|
||||
errorf("Unable to link shaders. Dumped error log to %s", *Out);
|
||||
|
||||
GLint LogLen;
|
||||
glGetProgramiv(mProgram, GL_INFO_LOG_LENGTH, &LogLen);
|
||||
@@ -188,13 +187,13 @@ GLuint CShader::GetUniformBlockIndex(const char* pkUniformBlock)
|
||||
return glGetUniformBlockIndex(mProgram, pkUniformBlock);
|
||||
}
|
||||
|
||||
void CShader::SetTextureUniforms(u32 NumTextures)
|
||||
void CShader::SetTextureUniforms(uint32 NumTextures)
|
||||
{
|
||||
for (u32 iTex = 0; iTex < NumTextures; iTex++)
|
||||
for (uint32 iTex = 0; iTex < NumTextures; iTex++)
|
||||
glUniform1i(mTextureUniforms[iTex], iTex);
|
||||
}
|
||||
|
||||
void CShader::SetNumLights(u32 NumLights)
|
||||
void CShader::SetNumLights(uint32 NumLights)
|
||||
{
|
||||
glUniform1i(mNumLightsUniform, NumLights);
|
||||
}
|
||||
@@ -219,26 +218,18 @@ CShader* CShader::FromResourceFile(const TString& rkShaderName)
|
||||
{
|
||||
TString VertexShaderFilename = "../resources/shaders/" + rkShaderName + ".vs";
|
||||
TString PixelShaderFilename = "../resources/shaders/" + rkShaderName + ".ps";
|
||||
CTextInStream VertexShaderFile(VertexShaderFilename);
|
||||
CTextInStream PixelShaderFile(PixelShaderFilename);
|
||||
TString VertexShaderText, PixelShaderText;
|
||||
|
||||
if (!VertexShaderFile.IsValid())
|
||||
Log::Error("Couldn't load vertex shader file for " + rkShaderName);
|
||||
if (!PixelShaderFile.IsValid())
|
||||
Log::Error("Error: Couldn't load pixel shader file for " + rkShaderName);
|
||||
if ((!VertexShaderFile.IsValid()) || (!PixelShaderFile.IsValid())) return nullptr;
|
||||
|
||||
std::stringstream VertexShader;
|
||||
while (!VertexShaderFile.EoF())
|
||||
VertexShader << VertexShaderFile.GetString();
|
||||
|
||||
std::stringstream PixelShader;
|
||||
while (!PixelShaderFile.EoF())
|
||||
PixelShader << PixelShaderFile.GetString();
|
||||
if (!FileUtil::LoadFileToString(VertexShaderFilename, VertexShaderText))
|
||||
errorf("Couldn't load vertex shader file for %s", *rkShaderName);
|
||||
if (!FileUtil::LoadFileToString(PixelShaderFilename, PixelShaderText))
|
||||
errorf("Couldn't load pixel shader file for %s", *rkShaderName);
|
||||
if (VertexShaderText.IsEmpty() || PixelShaderText.IsEmpty())
|
||||
return nullptr;
|
||||
|
||||
CShader *pShader = new CShader();
|
||||
pShader->CompileVertexSource(VertexShader.str().c_str());
|
||||
pShader->CompilePixelSource(PixelShader.str().c_str());
|
||||
pShader->CompileVertexSource(*VertexShaderText);
|
||||
pShader->CompilePixelSource(*PixelShaderText);
|
||||
pShader->LinkShaders();
|
||||
return pShader;
|
||||
}
|
||||
@@ -256,7 +247,7 @@ void CShader::KillCachedShader()
|
||||
// ************ PRIVATE ************
|
||||
void CShader::CacheCommonUniforms()
|
||||
{
|
||||
for (u32 iTex = 0; iTex < 8; iTex++)
|
||||
for (uint32 iTex = 0; iTex < 8; iTex++)
|
||||
{
|
||||
TString TexUniform = "Texture" + TString::FromInt32(iTex);
|
||||
mTextureUniforms[iTex] = glGetUniformLocation(mProgram, *TexUniform);
|
||||
|
||||
@@ -37,8 +37,8 @@ public:
|
||||
GLuint GetProgramID();
|
||||
GLuint GetUniformLocation(const char* pkUniform);
|
||||
GLuint GetUniformBlockIndex(const char* pkUniformBlock);
|
||||
void SetTextureUniforms(u32 NumTextures);
|
||||
void SetNumLights(u32 NumLights);
|
||||
void SetTextureUniforms(uint32 NumTextures);
|
||||
void SetNumLights(uint32 NumLights);
|
||||
void SetCurrent();
|
||||
|
||||
// Static
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "CShaderGenerator.h"
|
||||
#include <Common/AssertMacro.h>
|
||||
#include <Common/Macros.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
@@ -179,7 +179,7 @@ bool CShaderGenerator::CreateVertexShader(const CMaterial& rkMat)
|
||||
if (VtxDesc & eColor0) ShaderCode << "out vec4 Color0;\n";
|
||||
if (VtxDesc & eColor1) ShaderCode << "out vec4 Color1;\n";
|
||||
|
||||
for (u32 iPass = 0; iPass < rkMat.PassCount(); iPass++)
|
||||
for (uint32 iPass = 0; iPass < rkMat.PassCount(); iPass++)
|
||||
if (rkMat.Pass(iPass)->TexCoordSource() != 0xFF)
|
||||
ShaderCode << "out vec3 Tex" << iPass << ";\n";
|
||||
|
||||
@@ -332,9 +332,9 @@ bool CShaderGenerator::CreateVertexShader(const CMaterial& rkMat)
|
||||
ShaderCode << " \n"
|
||||
<< " // TexGen\n";
|
||||
|
||||
u32 PassCount = rkMat.PassCount();
|
||||
uint32 PassCount = rkMat.PassCount();
|
||||
|
||||
for (u32 iPass = 0; iPass < PassCount; iPass++)
|
||||
for (uint32 iPass = 0; iPass < PassCount; iPass++)
|
||||
{
|
||||
CMaterialPass *pPass = rkMat.Pass(iPass);
|
||||
if (pPass->TexCoordSource() == 0xFF) continue;
|
||||
@@ -378,9 +378,9 @@ bool CShaderGenerator::CreatePixelShader(const CMaterial& rkMat)
|
||||
if (VtxDesc & eColor0) ShaderCode << "in vec4 Color0;\n";
|
||||
if (VtxDesc & eColor1) ShaderCode << "in vec4 Color1;\n";
|
||||
|
||||
u32 PassCount = rkMat.PassCount();
|
||||
uint32 PassCount = rkMat.PassCount();
|
||||
|
||||
for (u32 iPass = 0; iPass < PassCount; iPass++)
|
||||
for (uint32 iPass = 0; iPass < PassCount; iPass++)
|
||||
if (rkMat.Pass(iPass)->TexCoordSource() != 0xFF)
|
||||
ShaderCode << "in vec3 Tex" << iPass << ";\n";
|
||||
|
||||
@@ -396,7 +396,7 @@ bool CShaderGenerator::CreatePixelShader(const CMaterial& rkMat)
|
||||
<< " float LightmapMultiplier;\n"
|
||||
<< "};\n\n";
|
||||
|
||||
for (u32 iPass = 0; iPass < PassCount; iPass++)
|
||||
for (uint32 iPass = 0; iPass < PassCount; iPass++)
|
||||
if (rkMat.Pass(iPass)->Texture() != nullptr)
|
||||
ShaderCode << "uniform sampler2D Texture" << iPass << ";\n";
|
||||
|
||||
@@ -413,7 +413,7 @@ bool CShaderGenerator::CreatePixelShader(const CMaterial& rkMat)
|
||||
<< " \n";
|
||||
|
||||
bool Lightmap = false;
|
||||
for (u32 iPass = 0; iPass < PassCount; iPass++)
|
||||
for (uint32 iPass = 0; iPass < PassCount; iPass++)
|
||||
{
|
||||
const CMaterialPass *pPass = rkMat.Pass(iPass);
|
||||
CFourCC PassType = pPass->Type();
|
||||
@@ -451,7 +451,7 @@ bool CShaderGenerator::CreatePixelShader(const CMaterial& rkMat)
|
||||
if (pPass->RasSel() != eRasColorNull)
|
||||
ShaderCode << " Ras = " << gkRasSel[pPass->RasSel()] << ";\n";
|
||||
|
||||
for (u8 iInput = 0; iInput < 4; iInput++)
|
||||
for (uint8 iInput = 0; iInput < 4; iInput++)
|
||||
{
|
||||
char TevChar = iInput + 0x41; // the current stage number represented as an ASCII letter; eg 0 is 'A'
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#ifndef CUNIFORMBUFFER_H
|
||||
#define CUNIFORMBUFFER_H
|
||||
|
||||
#include <Common/types.h>
|
||||
#include <Common/BasicTypes.h>
|
||||
#include <GL/glew.h>
|
||||
|
||||
class CUniformBuffer
|
||||
{
|
||||
GLuint mUniformBuffer;
|
||||
u32 mBufferSize;
|
||||
uint mBufferSize;
|
||||
|
||||
public:
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
SetBufferSize(0);
|
||||
}
|
||||
|
||||
CUniformBuffer(u32 Size)
|
||||
CUniformBuffer(uint Size)
|
||||
{
|
||||
glGenBuffers(1, &mUniformBuffer);
|
||||
SetBufferSize(Size);
|
||||
@@ -52,20 +52,20 @@ public:
|
||||
Unbind();
|
||||
}
|
||||
|
||||
void BufferRange(const void *pkData, u32 Offset, u32 Size)
|
||||
void BufferRange(const void *pkData, uint Offset, uint Size)
|
||||
{
|
||||
Bind();
|
||||
glBufferSubData(GL_UNIFORM_BUFFER, Offset, Size, pkData);
|
||||
Unbind();
|
||||
}
|
||||
|
||||
void SetBufferSize(u32 Size)
|
||||
void SetBufferSize(uint Size)
|
||||
{
|
||||
mBufferSize = Size;
|
||||
InitializeBuffer();
|
||||
}
|
||||
|
||||
u32 GetBufferSize()
|
||||
uint GetBufferSize()
|
||||
{
|
||||
return mBufferSize;
|
||||
}
|
||||
|
||||
@@ -94,12 +94,12 @@ CVertexArrayManager* CVertexArrayManager::Current()
|
||||
|
||||
void CVertexArrayManager::DeleteAllArraysForVBO(CVertexBuffer *pVBO)
|
||||
{
|
||||
for (u32 iVAM = 0; iVAM < sVAManagers.size(); iVAM++)
|
||||
for (uint32 iVAM = 0; iVAM < sVAManagers.size(); iVAM++)
|
||||
sVAManagers[iVAM]->DeleteVAO(pVBO);
|
||||
}
|
||||
|
||||
void CVertexArrayManager::DeleteAllArraysForVBO(CDynamicVertexBuffer *pVBO)
|
||||
{
|
||||
for (u32 iVAM = 0; iVAM < sVAManagers.size(); iVAM++)
|
||||
for (uint32 iVAM = 0; iVAM < sVAManagers.size(); iVAM++)
|
||||
sVAManagers[iVAM]->DeleteVAO(pVBO);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class CVertexArrayManager
|
||||
{
|
||||
std::unordered_map<CVertexBuffer*, GLuint> mVBOMap;
|
||||
std::unordered_map<CDynamicVertexBuffer*, GLuint> mDynamicVBOMap;
|
||||
u32 mVectorIndex;
|
||||
uint32 mVectorIndex;
|
||||
|
||||
static std::vector<CVertexArrayManager*> sVAManagers;
|
||||
static CVertexArrayManager *spCurrentManager;
|
||||
|
||||
@@ -21,7 +21,7 @@ CVertexBuffer::~CVertexBuffer()
|
||||
glDeleteBuffers(14, mAttribBuffers);
|
||||
}
|
||||
|
||||
u16 CVertexBuffer::AddVertex(const CVertex& rkVtx)
|
||||
uint16 CVertexBuffer::AddVertex(const CVertex& rkVtx)
|
||||
{
|
||||
if (mPositions.size() == 0xFFFF) throw std::overflow_error("VBO contains too many vertices");
|
||||
|
||||
@@ -30,10 +30,10 @@ u16 CVertexBuffer::AddVertex(const CVertex& rkVtx)
|
||||
if (mVtxDesc & eColor0) mColors[0].push_back(rkVtx.Color[0]);
|
||||
if (mVtxDesc & eColor1) mColors[1].push_back(rkVtx.Color[1]);
|
||||
|
||||
for (u32 iTex = 0; iTex < 8; iTex++)
|
||||
for (uint32 iTex = 0; iTex < 8; iTex++)
|
||||
if (mVtxDesc & (eTex0 << iTex)) mTexCoords[iTex].push_back(rkVtx.Tex[iTex]);
|
||||
|
||||
for (u32 iMtx = 0; iMtx < 8; iMtx++)
|
||||
for (uint32 iMtx = 0; iMtx < 8; iMtx++)
|
||||
if (mVtxDesc & (ePosMtx << iMtx)) mTexCoords[iMtx].push_back(rkVtx.MatrixIndices[iMtx]);
|
||||
|
||||
if (mVtxDesc.HasAnyFlags(eBoneIndices | eBoneWeights) && mpSkin)
|
||||
@@ -46,11 +46,11 @@ u16 CVertexBuffer::AddVertex(const CVertex& rkVtx)
|
||||
return (mPositions.size() - 1);
|
||||
}
|
||||
|
||||
u16 CVertexBuffer::AddIfUnique(const CVertex& rkVtx, u16 Start)
|
||||
uint16 CVertexBuffer::AddIfUnique(const CVertex& rkVtx, uint16 Start)
|
||||
{
|
||||
if (Start < mPositions.size())
|
||||
{
|
||||
for (u16 iVert = Start; iVert < mPositions.size(); iVert++)
|
||||
for (uint16 iVert = Start; iVert < mPositions.size(); iVert++)
|
||||
{
|
||||
// I use a bool because "continue" doesn't work properly within the iTex loop
|
||||
bool Unique = false;
|
||||
@@ -68,7 +68,7 @@ u16 CVertexBuffer::AddIfUnique(const CVertex& rkVtx, u16 Start)
|
||||
if (rkVtx.Color[1] != mColors[1][iVert]) Unique = true;
|
||||
|
||||
if (!Unique)
|
||||
for (u32 iTex = 0; iTex < 8; iTex++)
|
||||
for (uint32 iTex = 0; iTex < 8; iTex++)
|
||||
if ((mVtxDesc & (eTex0 << iTex)))
|
||||
if (rkVtx.Tex[iTex] != mTexCoords[iTex][iVert])
|
||||
{
|
||||
@@ -80,7 +80,7 @@ u16 CVertexBuffer::AddIfUnique(const CVertex& rkVtx, u16 Start)
|
||||
{
|
||||
const SVertexWeights& rkWeights = mpSkin->WeightsForVertex(rkVtx.ArrayPosition);
|
||||
|
||||
for (u32 iWgt = 0; iWgt < 4; iWgt++)
|
||||
for (uint32 iWgt = 0; iWgt < 4; iWgt++)
|
||||
{
|
||||
if ( ((mVtxDesc & eBoneIndices) && (rkWeights.Indices[iWgt] != mBoneIndices[iVert][iWgt])) ||
|
||||
((mVtxDesc & eBoneWeights) && (rkWeights.Weights[iWgt] != mBoneWeights[iVert][iWgt])) )
|
||||
@@ -98,9 +98,9 @@ u16 CVertexBuffer::AddIfUnique(const CVertex& rkVtx, u16 Start)
|
||||
return AddVertex(rkVtx);
|
||||
}
|
||||
|
||||
void CVertexBuffer::Reserve(u16 Size)
|
||||
void CVertexBuffer::Reserve(uint16 Size)
|
||||
{
|
||||
u32 ReserveSize = mPositions.size() + Size;
|
||||
uint32 ReserveSize = mPositions.size() + Size;
|
||||
|
||||
if (mVtxDesc & ePosition)
|
||||
mPositions.reserve(ReserveSize);
|
||||
@@ -114,7 +114,7 @@ void CVertexBuffer::Reserve(u16 Size)
|
||||
if (mVtxDesc & eColor1)
|
||||
mColors[1].reserve(ReserveSize);
|
||||
|
||||
for (u32 iTex = 0; iTex < 8; iTex++)
|
||||
for (uint32 iTex = 0; iTex < 8; iTex++)
|
||||
if (mVtxDesc & (eTex0 << iTex))
|
||||
mTexCoords[iTex].reserve(ReserveSize);
|
||||
|
||||
@@ -136,7 +136,7 @@ void CVertexBuffer::Clear()
|
||||
mColors[0].clear();
|
||||
mColors[1].clear();
|
||||
|
||||
for (u32 iTex = 0; iTex < 8; iTex++)
|
||||
for (uint32 iTex = 0; iTex < 8; iTex++)
|
||||
mTexCoords[iTex].clear();
|
||||
|
||||
mBoneIndices.clear();
|
||||
@@ -155,7 +155,7 @@ void CVertexBuffer::Buffer()
|
||||
// Generate buffers
|
||||
glGenBuffers(14, mAttribBuffers);
|
||||
|
||||
for (u32 iAttrib = 0; iAttrib < 14; iAttrib++)
|
||||
for (uint32 iAttrib = 0; iAttrib < 14; iAttrib++)
|
||||
{
|
||||
int Attrib = (ePosition << iAttrib);
|
||||
bool HasAttrib = ((mVtxDesc & Attrib) != 0);
|
||||
@@ -171,7 +171,7 @@ void CVertexBuffer::Buffer()
|
||||
|
||||
else if (iAttrib < 4)
|
||||
{
|
||||
u8 Index = (u8) (iAttrib - 2);
|
||||
uint8 Index = (uint8) (iAttrib - 2);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, mAttribBuffers[iAttrib]);
|
||||
glBufferData(GL_ARRAY_BUFFER, mColors[Index].size() * sizeof(CColor), mColors[Index].data(), GL_STATIC_DRAW);
|
||||
@@ -179,7 +179,7 @@ void CVertexBuffer::Buffer()
|
||||
|
||||
else if (iAttrib < 12)
|
||||
{
|
||||
u8 Index = (u8) (iAttrib - 4);
|
||||
uint8 Index = (uint8) (iAttrib - 4);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, mAttribBuffers[iAttrib]);
|
||||
glBufferData(GL_ARRAY_BUFFER, mTexCoords[Index].size() * sizeof(CVector2f), mTexCoords[Index].data(), GL_STATIC_DRAW);
|
||||
@@ -234,7 +234,7 @@ void CVertexBuffer::SetSkin(CSkin *pSkin)
|
||||
mpSkin = pSkin;
|
||||
}
|
||||
|
||||
u32 CVertexBuffer::Size()
|
||||
uint32 CVertexBuffer::Size()
|
||||
{
|
||||
return mPositions.size();
|
||||
}
|
||||
@@ -245,7 +245,7 @@ GLuint CVertexBuffer::CreateVAO()
|
||||
glGenVertexArrays(1, &VertexArray);
|
||||
glBindVertexArray(VertexArray);
|
||||
|
||||
for (u32 iAttrib = 0; iAttrib < 14; iAttrib++)
|
||||
for (uint32 iAttrib = 0; iAttrib < 14; iAttrib++)
|
||||
{
|
||||
int Attrib = (ePosition << iAttrib);
|
||||
bool HasAttrib = ((mVtxDesc & Attrib) != 0);
|
||||
|
||||
@@ -25,9 +25,9 @@ public:
|
||||
CVertexBuffer();
|
||||
CVertexBuffer(FVertexDescription Desc);
|
||||
~CVertexBuffer();
|
||||
u16 AddVertex(const CVertex& rkVtx);
|
||||
u16 AddIfUnique(const CVertex& rkVtx, u16 Start);
|
||||
void Reserve(u16 Size);
|
||||
uint16 AddVertex(const CVertex& rkVtx);
|
||||
uint16 AddIfUnique(const CVertex& rkVtx, uint16 Start);
|
||||
void Reserve(uint16 Size);
|
||||
void Clear();
|
||||
void Buffer();
|
||||
void Bind();
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
FVertexDescription VertexDesc();
|
||||
void SetVertexDesc(FVertexDescription Desc);
|
||||
void SetSkin(CSkin *pSkin);
|
||||
u32 Size();
|
||||
uint32 Size();
|
||||
GLuint CreateVAO();
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef GLCOMMON_H
|
||||
#define GLCOMMON_H
|
||||
|
||||
#include <Common/types.h>
|
||||
#include <Common/BasicTypes.h>
|
||||
#include <GL/glew.h>
|
||||
|
||||
enum EBlendFactor
|
||||
|
||||
Reference in New Issue
Block a user