update all uses of VertexBuffer, IndexBuffer and VERTEX_ATTRIBS to compile and run under the new changes
This commit is contained in:
parent
9f42c16c93
commit
4db24ae39a
|
@ -53,14 +53,17 @@ KeyframeMesh::KeyframeMesh(const KeyframeMeshFile *file)
|
|||
|
||||
m_numVerticesPerFrame = file->GetNumVerticesPerFrame();
|
||||
|
||||
m_vertices = new VertexBuffer(BUFFEROBJECT_USAGE_STREAM);
|
||||
VERTEX_ATTRIBS attribs[] = {
|
||||
VERTEX_V3, // position for frame 1
|
||||
VERTEX_V3, // position for frame 2
|
||||
VERTEX_V3, // normal for frame 1
|
||||
VERTEX_V3, // normal for frame 2
|
||||
VERTEX_TEXCOORD
|
||||
};
|
||||
|
||||
m_vertices = new VertexBuffer();
|
||||
ASSERT(m_vertices != NULL);
|
||||
m_vertices->AddAttribute(ATTRIB_SIZE_VEC3); // position for frame 1
|
||||
m_vertices->AddAttribute(ATTRIB_SIZE_VEC3); // position for frame 2
|
||||
m_vertices->AddAttribute(ATTRIB_SIZE_VEC3); // normal for frame 1
|
||||
m_vertices->AddAttribute(ATTRIB_SIZE_VEC3); // normal for frame 2
|
||||
m_vertices->AddAttribute(VERTEX_TEXCOORD);
|
||||
m_vertices->Create(m_numVerticesPerFrame);
|
||||
m_vertices->Initialize(attribs, 5, m_numVerticesPerFrame, BUFFEROBJECT_USAGE_STREAM);
|
||||
}
|
||||
|
||||
KeyframeMesh::~KeyframeMesh()
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "../../math/vector3.h"
|
||||
#include "../../support/animationsequence.h"
|
||||
#include <stl/string.h>
|
||||
#include <stl/vector.h>
|
||||
|
||||
SkeletalMeshFile::SkeletalMeshFile(File *file)
|
||||
: MeshFile(file)
|
||||
|
@ -56,14 +57,18 @@ SkeletalMesh* SkeletalMeshFile::CreateMesh()
|
|||
file->Seek(verticesDesc->start, FILESEEK_BEGINNING);
|
||||
mesh->m_numVertices = file->ReadUnsignedInt();
|
||||
|
||||
mesh->m_vertexBuffer = new VertexBuffer(BUFFEROBJECT_USAGE_STATIC);
|
||||
mesh->m_vertexBuffer->AddAttribute(ATTRIB_SIZE_1F);
|
||||
mesh->m_vertexBuffer->AddAttribute(VERTEX_POS_3D);
|
||||
// lol, lazy way out
|
||||
stl::vector<VERTEX_ATTRIBS> attribs;
|
||||
attribs.reserve(4);
|
||||
attribs.push_back(VERTEX_F1);
|
||||
attribs.push_back(VERTEX_POS_3D);
|
||||
if (hasNormals)
|
||||
mesh->m_vertexBuffer->AddAttribute(VERTEX_NORMAL);
|
||||
attribs.push_back(VERTEX_NORMAL);
|
||||
if (hasTexCoords)
|
||||
mesh->m_vertexBuffer->AddAttribute(VERTEX_TEXCOORD);
|
||||
mesh->m_vertexBuffer->Create(mesh->m_numVertices);
|
||||
attribs.push_back(VERTEX_TEXCOORD);
|
||||
|
||||
mesh->m_vertexBuffer = new VertexBuffer();
|
||||
mesh->m_vertexBuffer->Initialize(&attribs[0], attribs.size(), mesh->m_numVertices, BUFFEROBJECT_USAGE_STATIC);
|
||||
|
||||
// read vertices
|
||||
mesh->m_vertices = new Vector3[mesh->m_numVertices];
|
||||
|
|
|
@ -24,6 +24,7 @@ void SkeletalMeshSubset::Create(const stl::string &name, uint32_t numTriangles,
|
|||
ASSERT(m_indices == NULL);
|
||||
ASSERT(numTriangles > 0);
|
||||
m_name = name;
|
||||
m_indices = new IndexBuffer(numTriangles * 3, TRUE);
|
||||
m_indices = new IndexBuffer();
|
||||
m_indices->Initialize(numTriangles * 3, BUFFEROBJECT_USAGE_STATIC);
|
||||
m_alpha = alpha;
|
||||
}
|
||||
|
|
|
@ -8,12 +8,15 @@
|
|||
StaticMeshSubset::StaticMeshSubset(uint32_t numTriangles, Texture *texture)
|
||||
{
|
||||
STACK_TRACE;
|
||||
m_vertices = new VertexBuffer(BUFFEROBJECT_USAGE_STATIC);
|
||||
VERTEX_ATTRIBS attribs[] = {
|
||||
VERTEX_POS_3D,
|
||||
VERTEX_NORMAL,
|
||||
VERTEX_TEXCOORD
|
||||
};
|
||||
|
||||
m_vertices = new VertexBuffer();
|
||||
ASSERT(m_vertices != NULL);
|
||||
m_vertices->AddAttribute(VERTEX_POS_3D);
|
||||
m_vertices->AddAttribute(VERTEX_NORMAL);
|
||||
m_vertices->AddAttribute(VERTEX_TEXCOORD);
|
||||
m_vertices->Create(numTriangles * 3);
|
||||
m_vertices->Initialize(attribs, 3, numTriangles * 3, BUFFEROBJECT_USAGE_STATIC);
|
||||
m_texture = texture;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,14 +35,17 @@ BillboardSpriteBatch::BillboardSpriteBatch(GraphicsDevice *graphicsDevice)
|
|||
// TODO: default size of 1 is best?
|
||||
m_currentSpriteCapacity = 1;
|
||||
m_currentSpritePointer = 0;
|
||||
|
||||
VERTEX_ATTRIBS attribs[] = {
|
||||
VERTEX_POS_3D,
|
||||
VERTEX_COLOR,
|
||||
VERTEX_TEXCOORD
|
||||
};
|
||||
|
||||
// size vertices and texture storage to match m_currentSpriteCapacity
|
||||
m_vertices = new VertexBuffer(BUFFEROBJECT_USAGE_STREAM);
|
||||
m_vertices = new VertexBuffer();
|
||||
ASSERT(m_vertices != NULL);
|
||||
m_vertices->AddAttribute(VERTEX_POS_3D);
|
||||
m_vertices->AddAttribute(VERTEX_COLOR);
|
||||
m_vertices->AddAttribute(VERTEX_TEXCOORD);
|
||||
m_vertices->Create(m_currentSpriteCapacity * VERTICES_PER_SPRITE);
|
||||
m_vertices->Initialize(attribs, 3, m_currentSpriteCapacity * VERTICES_PER_SPRITE, BUFFEROBJECT_USAGE_STREAM);
|
||||
|
||||
m_textures.resize(m_currentSpriteCapacity);
|
||||
|
||||
|
|
|
@ -37,8 +37,8 @@ DebugShader::DebugShader()
|
|||
BOOL result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_POS_3D);
|
||||
MapAttributeToStandardAttribType("a_color", VERTEX_COLOR);
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_3D);
|
||||
MapAttributeToStandardAttribType("a_color", VERTEX_STD_COLOR);
|
||||
}
|
||||
|
||||
DebugShader::~DebugShader()
|
||||
|
|
|
@ -27,12 +27,15 @@ GeometryDebugRenderer::GeometryDebugRenderer(GraphicsDevice *graphicsDevice, BOO
|
|||
ASSERT(m_renderState != NULL);
|
||||
m_renderState->SetDepthTesting(depthTesting);
|
||||
m_renderState->SetLineWidth(2.0f);
|
||||
|
||||
VERTEX_ATTRIBS attribs[] = {
|
||||
VERTEX_POS_3D,
|
||||
VERTEX_COLOR
|
||||
};
|
||||
|
||||
m_vertices = new VertexBuffer(BUFFEROBJECT_USAGE_STREAM);
|
||||
m_vertices = new VertexBuffer();
|
||||
ASSERT(m_vertices != NULL);
|
||||
m_vertices->AddAttribute(VERTEX_POS_3D);
|
||||
m_vertices->AddAttribute(VERTEX_COLOR);
|
||||
m_vertices->Create(16384);
|
||||
m_vertices->Initialize(attribs, 2, 16384, BUFFEROBJECT_USAGE_STREAM);
|
||||
m_currentVertex = 0;
|
||||
|
||||
m_begunRendering = FALSE;
|
||||
|
|
|
@ -492,7 +492,7 @@ void GraphicsDevice::SetShaderVertexAttributes()
|
|||
int32_t bufferAttribIndex = 0;
|
||||
if (m_boundShader->IsAttributeMappedToStandardType(i))
|
||||
{
|
||||
VERTEX_ATTRIBS standardType = m_boundShader->GetAttributeMappedStandardType(i);
|
||||
VERTEX_STANDARD_ATTRIBS standardType = m_boundShader->GetAttributeMappedStandardType(i);
|
||||
bufferAttribIndex = m_boundVertexBuffer->GetIndexOfStandardAttrib(standardType);
|
||||
ASSERT(bufferAttribIndex != -1);
|
||||
if (bufferAttribIndex == -1)
|
||||
|
|
|
@ -1053,7 +1053,7 @@ void Shader::MapAttributeToVboAttribIndex(const stl::string &name, uint32_t vboA
|
|||
attribute->isTypeBound = TRUE;
|
||||
}
|
||||
|
||||
void Shader::MapAttributeToStandardAttribType(const stl::string &name, VERTEX_ATTRIBS standardAttribType)
|
||||
void Shader::MapAttributeToStandardAttribType(const stl::string &name, VERTEX_STANDARD_ATTRIBS standardAttribType)
|
||||
{
|
||||
STACK_TRACE;
|
||||
ShaderAttribute *attribute = GetAttribute(name);
|
||||
|
|
|
@ -237,7 +237,7 @@ public:
|
|||
* @return the standard attribute type mapping associated with this
|
||||
* shader attribute
|
||||
*/
|
||||
VERTEX_ATTRIBS GetAttributeMappedStandardType(uint32_t attribIndex) const;
|
||||
VERTEX_STANDARD_ATTRIBS GetAttributeMappedStandardType(uint32_t attribIndex) const;
|
||||
|
||||
/**
|
||||
* Maps the given shader attribute to an index that will be used to refer
|
||||
|
@ -260,7 +260,7 @@ public:
|
|||
* @param standardAttribType the standard type to map this shader attribute
|
||||
* to in bound vertex buffer objects
|
||||
*/
|
||||
void MapAttributeToStandardAttribType(const stl::string &name, VERTEX_ATTRIBS standardAttribType);
|
||||
void MapAttributeToStandardAttribType(const stl::string &name, VERTEX_STANDARD_ATTRIBS standardAttribType);
|
||||
|
||||
/**
|
||||
* New OpenGL graphics context creation callback.
|
||||
|
@ -388,7 +388,7 @@ inline uint32_t Shader::GetAttributeMappedBufferIndex(uint32_t attribIndex) cons
|
|||
return m_attributeMapping[attribIndex].attribIndex;
|
||||
}
|
||||
|
||||
inline VERTEX_ATTRIBS Shader::GetAttributeMappedStandardType(uint32_t attribIndex) const
|
||||
inline VERTEX_STANDARD_ATTRIBS Shader::GetAttributeMappedStandardType(uint32_t attribIndex) const
|
||||
{
|
||||
return m_attributeMapping[attribIndex].standardType;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ struct ShaderAttribute
|
|||
struct ShaderAttributeMapInfo
|
||||
{
|
||||
BOOL usesStandardType;
|
||||
VERTEX_ATTRIBS standardType;
|
||||
VERTEX_STANDARD_ATTRIBS standardType;
|
||||
uint32_t attribIndex;
|
||||
};
|
||||
|
||||
|
|
|
@ -36,8 +36,8 @@ SimpleColorShader::SimpleColorShader()
|
|||
BOOL result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_POS_3D);
|
||||
MapAttributeToStandardAttribType("a_color", VERTEX_COLOR);
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_3D);
|
||||
MapAttributeToStandardAttribType("a_color", VERTEX_STD_COLOR);
|
||||
}
|
||||
|
||||
SimpleColorShader::~SimpleColorShader()
|
||||
|
|
|
@ -41,9 +41,9 @@ SimpleColorTextureShader::SimpleColorTextureShader()
|
|||
BOOL result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_POS_3D);
|
||||
MapAttributeToStandardAttribType("a_color", VERTEX_COLOR);
|
||||
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_TEXCOORD);
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_3D);
|
||||
MapAttributeToStandardAttribType("a_color", VERTEX_STD_COLOR);
|
||||
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_STD_TEXCOORD);
|
||||
}
|
||||
|
||||
SimpleColorTextureShader::~SimpleColorTextureShader()
|
||||
|
|
|
@ -35,8 +35,8 @@ SimpleTextureShader::SimpleTextureShader()
|
|||
BOOL result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_POS_3D);
|
||||
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_TEXCOORD);
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_3D);
|
||||
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_STD_TEXCOORD);
|
||||
}
|
||||
|
||||
SimpleTextureShader::~SimpleTextureShader()
|
||||
|
|
|
@ -39,7 +39,7 @@ SimpleTextureVertexLerpShader::SimpleTextureVertexLerpShader()
|
|||
|
||||
MapAttributeToVboAttribIndex("a_position1", 0);
|
||||
MapAttributeToVboAttribIndex("a_position2", 1);
|
||||
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_TEXCOORD);
|
||||
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_STD_TEXCOORD);
|
||||
}
|
||||
|
||||
SimpleTextureVertexLerpShader::~SimpleTextureVertexLerpShader()
|
||||
|
|
|
@ -56,8 +56,8 @@ SimpleTextureVertexSkinningShader::SimpleTextureVertexSkinningShader()
|
|||
ASSERT(result == TRUE);
|
||||
|
||||
MapAttributeToVboAttribIndex("a_jointIndex", 0);
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_POS_3D);
|
||||
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_TEXCOORD);
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_3D);
|
||||
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_STD_TEXCOORD);
|
||||
}
|
||||
|
||||
SimpleTextureVertexSkinningShader::~SimpleTextureVertexSkinningShader()
|
||||
|
|
|
@ -47,9 +47,9 @@ Sprite2DShader::Sprite2DShader()
|
|||
BOOL result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_POS_2D);
|
||||
MapAttributeToStandardAttribType("a_color", VERTEX_COLOR);
|
||||
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_TEXCOORD);
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_2D);
|
||||
MapAttributeToStandardAttribType("a_color", VERTEX_STD_COLOR);
|
||||
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_STD_TEXCOORD);
|
||||
}
|
||||
|
||||
Sprite2DShader::~Sprite2DShader()
|
||||
|
|
|
@ -53,9 +53,9 @@ Sprite3DShader::Sprite3DShader()
|
|||
BOOL result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_POS_3D);
|
||||
MapAttributeToStandardAttribType("a_color", VERTEX_COLOR);
|
||||
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_TEXCOORD);
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_3D);
|
||||
MapAttributeToStandardAttribType("a_color", VERTEX_STD_COLOR);
|
||||
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_STD_TEXCOORD);
|
||||
}
|
||||
|
||||
Sprite3DShader::~Sprite3DShader()
|
||||
|
|
|
@ -34,16 +34,19 @@ SpriteBatch::SpriteBatch(GraphicsDevice *graphicsDevice)
|
|||
|
||||
// TODO: default size of 1 is best?
|
||||
m_currentSpritePointer = 0;
|
||||
|
||||
VERTEX_ATTRIBS attribs[] = {
|
||||
VERTEX_POS_2D,
|
||||
VERTEX_COLOR,
|
||||
VERTEX_TEXCOORD
|
||||
};
|
||||
|
||||
// size vertices and texture storage to match m_currentSpriteCapacity
|
||||
// HACK: we initialize the buffer to have a size of "1" simply because we
|
||||
// can't use a size of 0 with the current VertexBuffer implementation
|
||||
m_vertices = new VertexBuffer(BUFFEROBJECT_USAGE_STREAM);
|
||||
m_vertices = new VertexBuffer();
|
||||
ASSERT(m_vertices != NULL);
|
||||
m_vertices->AddAttribute(VERTEX_POS_2D);
|
||||
m_vertices->AddAttribute(VERTEX_COLOR);
|
||||
m_vertices->AddAttribute(VERTEX_TEXCOORD);
|
||||
m_vertices->Create(1);
|
||||
m_vertices->Initialize(attribs, 3, 1, BUFFEROBJECT_USAGE_STREAM);
|
||||
|
||||
m_entities.reserve(1);
|
||||
|
||||
|
|
|
@ -13,22 +13,19 @@ Grid::Grid(GraphicsDevice *graphicsDevice, uint16_t width, uint16_t height)
|
|||
|
||||
m_renderState = new RENDERSTATE_DEFAULT;
|
||||
ASSERT(m_renderState != NULL);
|
||||
|
||||
VERTEX_ATTRIBS attribs[] = {
|
||||
VERTEX_POS_3D,
|
||||
VERTEX_COLOR,
|
||||
};
|
||||
|
||||
m_horizontalPoints = new VertexBuffer(BUFFEROBJECT_USAGE_STATIC);
|
||||
m_horizontalPoints = new VertexBuffer();
|
||||
ASSERT(m_horizontalPoints != NULL);
|
||||
m_horizontalPoints->AddAttribute(VERTEX_POS_3D);
|
||||
m_horizontalPoints->AddAttribute(VERTEX_COLOR);
|
||||
m_horizontalPoints->AddAttribute(ATTRIB_SIZE_1F);
|
||||
m_horizontalPoints->AddAttribute(ATTRIB_SIZE_1F);
|
||||
m_horizontalPoints->Create(width * 2 + 2);
|
||||
m_horizontalPoints->Initialize(attribs, 2, width * 2 + 2, BUFFEROBJECT_USAGE_STATIC);
|
||||
|
||||
m_verticalPoints = new VertexBuffer(BUFFEROBJECT_USAGE_STATIC);
|
||||
m_verticalPoints = new VertexBuffer();
|
||||
ASSERT(m_verticalPoints != NULL);
|
||||
m_verticalPoints->AddAttribute(VERTEX_POS_3D);
|
||||
m_verticalPoints->AddAttribute(VERTEX_COLOR);
|
||||
m_verticalPoints->AddAttribute(ATTRIB_SIZE_1F);
|
||||
m_verticalPoints->AddAttribute(ATTRIB_SIZE_1F);
|
||||
m_verticalPoints->Create(height * 2 + 2);
|
||||
m_verticalPoints->Initialize(attribs, 2, height * 2 + 2, BUFFEROBJECT_USAGE_STATIC);
|
||||
|
||||
for (uint16_t i = 0; i < height + 1; ++i)
|
||||
{
|
||||
|
@ -36,19 +33,6 @@ Grid::Grid(GraphicsDevice *graphicsDevice, uint16_t width, uint16_t height)
|
|||
m_horizontalPoints->SetColor((i * 2), 1.0f, 1.0f, 1.0f);
|
||||
m_horizontalPoints->SetPosition3((i * 2) + 1, width / 2.0f, 0.0f, i - (height / 2.0f));
|
||||
m_horizontalPoints->SetColor((i * 2) + 1, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
if (i == 8)
|
||||
{
|
||||
m_horizontalPoints->Set1f(3, (i * 2), 1.0f);
|
||||
m_horizontalPoints->Set1f(3, (i * 2) + 1, 1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_horizontalPoints->Set1f(3, (i * 2), 0.0f);
|
||||
m_horizontalPoints->Set1f(3, (i * 2) + 1, 0.0f);
|
||||
}
|
||||
m_horizontalPoints->Set1f(2, (i * 2), 2.0f);
|
||||
m_horizontalPoints->Set1f(2, (i * 2) + 1, 3.0f);
|
||||
}
|
||||
|
||||
for (uint16_t i = 0; i < width + 1; ++i)
|
||||
|
@ -57,19 +41,6 @@ Grid::Grid(GraphicsDevice *graphicsDevice, uint16_t width, uint16_t height)
|
|||
m_verticalPoints->SetColor((i * 2), 1.0f, 1.0f, 1.0f);
|
||||
m_verticalPoints->SetPosition3((i * 2) + 1, i - (width / 2.0f), 0.0f, height / 2.0f);
|
||||
m_verticalPoints->SetColor((i * 2) + 1, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
if (i == 1)
|
||||
{
|
||||
m_verticalPoints->Set1f(3, (i * 2), 1.0f);
|
||||
m_verticalPoints->Set1f(3, (i * 2) + 1, 1.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_verticalPoints->Set1f(3, (i * 2), 0.0f);
|
||||
m_verticalPoints->Set1f(3, (i * 2) + 1, 0.0f);
|
||||
}
|
||||
m_verticalPoints->Set1f(2, (i * 2), 0.0f);
|
||||
m_verticalPoints->Set1f(2, (i * 2) + 1, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,14 +59,17 @@ CubeTileMesh::CubeTileMesh(CUBE_FACES faces, const RectF *textureAtlasTileBounda
|
|||
m_rightFaceVertexOffset = numVertices;
|
||||
numVertices += CUBE_VERTICES_PER_FACE;
|
||||
}
|
||||
|
||||
VERTEX_ATTRIBS attribs[] = {
|
||||
VERTEX_POS_3D,
|
||||
VERTEX_NORMAL,
|
||||
VERTEX_COLOR,
|
||||
VERTEX_TEXCOORD
|
||||
};
|
||||
|
||||
m_vertices = new VertexBuffer(BUFFEROBJECT_USAGE_STATIC);
|
||||
m_vertices = new VertexBuffer();
|
||||
ASSERT(m_vertices != NULL);
|
||||
m_vertices->AddAttribute(VERTEX_POS_3D);
|
||||
m_vertices->AddAttribute(VERTEX_NORMAL);
|
||||
m_vertices->AddAttribute(VERTEX_COLOR);
|
||||
m_vertices->AddAttribute(VERTEX_TEXCOORD);
|
||||
m_vertices->Create(numVertices);
|
||||
m_vertices->Initialize(attribs, 4, numVertices, BUFFEROBJECT_USAGE_STATIC);
|
||||
|
||||
SetupFaceVertices(textureAtlasTileBoundaries);
|
||||
SetupCollisionVertices();
|
||||
|
|
|
@ -14,9 +14,9 @@ StaticTileMesh::StaticTileMesh(const StaticMesh *mesh, const RectF *textureAtlas
|
|||
StaticMeshSubset *subset = mesh->GetSubset(0);
|
||||
|
||||
// copy the source buffer
|
||||
m_vertices = new VertexBuffer(BUFFEROBJECT_USAGE_STATIC);
|
||||
m_vertices = new VertexBuffer();
|
||||
ASSERT(m_vertices != NULL);
|
||||
m_vertices->CreateCopyOf(subset->GetVertices());
|
||||
m_vertices->Initialize(subset->GetVertices());
|
||||
|
||||
SetOpaque(opaqueSides);
|
||||
SetAlpha(alpha);
|
||||
|
@ -48,12 +48,17 @@ StaticTileMesh::StaticTileMesh(const StaticMesh *mesh, const RectF *textureAtlas
|
|||
for (uint32_t i = 0; i < numTiles; ++i)
|
||||
numVertices += mesh->GetSubset(i)->GetVertices()->GetNumElements();
|
||||
|
||||
// create a copy of the mesh's vertex attributes as an array
|
||||
const VertexBuffer *meshVertices = mesh->GetSubset(0)->GetVertices();
|
||||
VERTEX_ATTRIBS *attribs = new VERTEX_ATTRIBS[meshVertices->GetNumAttributes()];
|
||||
for (uint32_t i = 0; i < meshVertices->GetNumAttributes(); ++i)
|
||||
attribs[i] = meshVertices->GetAttributeInfo(i)->standardType;
|
||||
|
||||
// create the vertex buffer using the same attribs as the source mesh
|
||||
// (assuming all subsets have the same attribs in the mesh)
|
||||
m_vertices = new VertexBuffer(BUFFEROBJECT_USAGE_STATIC);
|
||||
m_vertices = new VertexBuffer();
|
||||
ASSERT(m_vertices != NULL);
|
||||
m_vertices->CopyAttributesFrom(mesh->GetSubset(0)->GetVertices());
|
||||
m_vertices->Create(numVertices);
|
||||
m_vertices->Initialize(attribs, meshVertices->GetNumAttributes(), numVertices, BUFFEROBJECT_USAGE_STATIC);
|
||||
|
||||
SetOpaque(opaqueSides);
|
||||
SetAlpha(alpha);
|
||||
|
|
|
@ -38,15 +38,18 @@ TileChunk::TileChunk(uint32_t x, uint32_t y, uint32_t z, uint32_t width, uint32_
|
|||
|
||||
m_data = new Tile[width * height * depth];
|
||||
ASSERT(m_data != NULL);
|
||||
|
||||
VERTEX_ATTRIBS attribs[] = {
|
||||
VERTEX_POS_3D,
|
||||
VERTEX_NORMAL,
|
||||
VERTEX_TEXCOORD,
|
||||
VERTEX_COLOR
|
||||
};
|
||||
|
||||
// TODO: is 16 a good starting default size?
|
||||
m_vertices = new VertexBuffer(BUFFEROBJECT_USAGE_STATIC);
|
||||
m_vertices = new VertexBuffer();
|
||||
ASSERT(m_vertices != NULL);
|
||||
m_vertices->AddAttribute(VERTEX_POS_3D);
|
||||
m_vertices->AddAttribute(VERTEX_NORMAL);
|
||||
m_vertices->AddAttribute(VERTEX_TEXCOORD);
|
||||
m_vertices->AddAttribute(VERTEX_COLOR);
|
||||
m_vertices->Create(16);
|
||||
m_vertices->Initialize(attribs, 4, 16, BUFFEROBJECT_USAGE_STATIC);
|
||||
m_numVertices = 0;
|
||||
|
||||
// start off assuming we don't have any alpha vertices
|
||||
|
@ -377,17 +380,20 @@ void TileChunk::EnableAlphaVertices(BOOL enable)
|
|||
{
|
||||
if (m_alphaVertices != NULL)
|
||||
return;
|
||||
|
||||
VERTEX_ATTRIBS attribs[] = {
|
||||
VERTEX_POS_3D,
|
||||
VERTEX_NORMAL,
|
||||
VERTEX_TEXCOORD,
|
||||
VERTEX_COLOR
|
||||
};
|
||||
|
||||
// need to create the vertex buffer
|
||||
// TODO: is '16' a good default size? it probably isn't likely that
|
||||
// chunks will have a lot of these. has to be non-zero anyway...
|
||||
m_alphaVertices = new VertexBuffer(BUFFEROBJECT_USAGE_STATIC);
|
||||
m_alphaVertices = new VertexBuffer();
|
||||
ASSERT(m_alphaVertices != NULL);
|
||||
m_alphaVertices->AddAttribute(VERTEX_POS_3D);
|
||||
m_alphaVertices->AddAttribute(VERTEX_NORMAL);
|
||||
m_alphaVertices->AddAttribute(VERTEX_TEXCOORD);
|
||||
m_alphaVertices->AddAttribute(VERTEX_COLOR);
|
||||
m_alphaVertices->Create(16);
|
||||
m_alphaVertices->Initialize(attribs, 4, 16, BUFFEROBJECT_USAGE_STATIC);
|
||||
m_numAlphaVertices = 0;
|
||||
}
|
||||
else
|
||||
|
|
Reference in a new issue