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