mirror of
https://github.com/NoelFB/blah.git
synced 2025-02-22 14:18:29 +08:00
52 lines
1.4 KiB
C++
52 lines
1.4 KiB
C++
#include "mesh.h"
|
|
|
|
using namespace Blah;
|
|
|
|
void Mesh::vertex_format(const VertexAttribute* attributes, int attribute_count, int stride)
|
|
{
|
|
if (stride < 0)
|
|
{
|
|
stride = 0;
|
|
|
|
for (int n = 0; n < attribute_count; n++)
|
|
{
|
|
const VertexAttribute* attrib = (attributes + n);
|
|
|
|
if (attrib->type == VertexAttributeType::Byte)
|
|
stride += attrib->components * 1;
|
|
else if (attrib->type == VertexAttributeType::Short)
|
|
stride += attrib->components * 2;
|
|
else if (attrib->type == VertexAttributeType::Int)
|
|
stride += attrib->components * 4;
|
|
else if (attrib->type == VertexAttributeType::Float)
|
|
stride += attrib->components * 4;
|
|
}
|
|
}
|
|
|
|
vertex_format_internal(attributes, attribute_count, stride);
|
|
}
|
|
|
|
void Mesh::instance_format(const VertexAttribute* attributes, int attribute_count, int stride)
|
|
{
|
|
if (stride < 0)
|
|
{
|
|
stride = 0;
|
|
|
|
for (int n = 0; n < attribute_count; n++)
|
|
{
|
|
const VertexAttribute* attrib = (attributes + n);
|
|
|
|
if (attrib->type == VertexAttributeType::Byte)
|
|
stride += attrib->components * 1;
|
|
else if (attrib->type == VertexAttributeType::Short)
|
|
stride += attrib->components * 2;
|
|
else if (attrib->type == VertexAttributeType::Int)
|
|
stride += attrib->components * 4;
|
|
else if (attrib->type == VertexAttributeType::Float)
|
|
stride += attrib->components * 4;
|
|
}
|
|
}
|
|
|
|
instance_format_internal(attributes, attribute_count, stride);
|
|
}
|