![]() |
Divide Framework 0.1
A free and open-source 3D Framework under heavy development
|
#include <VertexBuffer.h>
Classes | |
struct | Descriptor |
struct | Vertex |
Public Member Functions | |
VertexBuffer (GFXDevice &context, const Descriptor &descriptor) | |
void | reserveIndexCount (const size_t size) |
void | setVertexCount (const size_t size) |
void | resizeVertexCount (const size_t size, const Vertex &defaultValue) |
void | resizeVertexCount (const size_t size) |
size_t | getVertexCount () const noexcept |
const vector< Vertex > & | getVertices () const noexcept |
const vec3< F32 > & | getPosition (const U32 index) const |
vec2< F32 > | getTexCoord (const U32 index) const |
F32 | getNormal (const U32 index) const |
F32 | getNormal (const U32 index, vec3< F32 > &normalOut) const |
F32 | getTangent (const U32 index) const |
F32 | getTangent (const U32 index, vec3< F32 > &tangentOut) const |
vec4< U8 > | getBoneIndices (const U32 index) const |
vec4< U8 > | getBoneWeightsPacked (const U32 index) const |
vec4< F32 > | getBoneWeights (const U32 index) const |
size_t | getIndexCount () const noexcept |
U32 | getIndex (const size_t index) const |
const vector< U32 > & | getIndices () const noexcept |
void | addIndex (const U32 index) |
void | addIndices (const vector< U16 > &indices) |
void | addIndices (const vector< U32 > &indices) |
void | addRestartIndex () |
void | modifyPositionValues (const U32 indexOffset, const vector< vec3< F32 > > &newValues) |
void | modifyPositionValue (const U32 index, const vec3< F32 > &newValue) |
void | modifyPositionValue (const U32 index, const F32 x, const F32 y, const F32 z) |
void | modifyColourValue (const U32 index, const UColour4 &newValue) |
void | modifyColourValue (const U32 index, const U8 r, const U8 g, const U8 b, const U8 a) |
void | modifyNormalValue (const U32 index, const vec3< F32 > &newValue) |
void | modifyNormalValue (const U32 index, const F32 x, const F32 y, const F32 z) |
void | modifyTangentValue (const U32 index, const vec3< F32 > &newValue) |
void | modifyTangentValue (const U32 index, const F32 x, const F32 y, const F32 z) |
void | modifyTexCoordValue (const U32 index, vec2< F32 > newValue) |
void | modifyTexCoordValue (const U32 index, const F32 s, const F32 t) |
void | modifyBoneIndices (const U32 index, const vec4< U8 > indices) |
void | modifyBoneWeights (const U32 index, const FColour4 &weights) |
void | modifyBoneWeights (const U32 index, const vec4< U8 > packedWeights) |
size_t | partitionCount () const noexcept |
U16 | partitionBuffer () |
size_t | getPartitionIndexCount (const U16 partitionID) |
size_t | getPartitionOffset (const U16 partitionID) const |
size_t | lastPartitionOffset () const |
AttributeMap | generateAttributeMap () |
Activate and set all of the required vertex attributes. | |
void | reset () |
void | fromBuffer (const VertexBuffer &other) |
bool | deserialize (ByteBuffer &dataIn) |
bool | serialize (ByteBuffer &dataOut) const |
void | computeNormals () |
void | computeTangents () |
![]() | |
VertexDataInterface (GFXDevice &context, const std::string_view name) | |
virtual | ~VertexDataInterface () override |
virtual void | draw (const GenericDrawCommand &command, VDIUserData *data)=0 |
PROPERTY_R (Handle, handle) | |
PROPERTY_RW (bool, primitiveRestartRequired, false) | |
![]() | |
GUIDWrapper () noexcept | |
GUIDWrapper (const GUIDWrapper &old) noexcept | |
GUIDWrapper (GUIDWrapper &&old) noexcept | |
virtual | ~GUIDWrapper ()=default |
FORCE_INLINE I64 | getGUID () const noexcept |
GUIDWrapper & | operator= (const GUIDWrapper &old)=delete |
GUIDWrapper & | operator= (GUIDWrapper &&other)=delete |
![]() | |
virtual | ~GraphicsResource () |
GFXDevice & | context () const noexcept |
U64 | nameHash () const noexcept |
![]() | |
NonCopyable (const NonCopyable &)=delete | |
NonCopyable & | operator= (const NonCopyable &)=delete |
NonCopyable (NonCopyable &&)=default | |
NonCopyable & | operator= (NonCopyable &&)=default |
![]() | |
NonMovable (NonMovable &&)=delete | |
NonMovable & | operator= (NonMovable &&)=delete |
NonMovable (const NonMovable &)=default | |
NonMovable & | operator= (const NonMovable &)=default |
Static Public Attributes | |
static constexpr U32 | PRIMITIVE_RESTART_INDEX_L = 0xFFFFFFFF |
static constexpr U32 | PRIMITIVE_RESTART_INDEX_S = 0xFFFF |
static constexpr U16 | INVALID_PARTITION_ID = 0xFFFF |
![]() | |
static constexpr Handle | INVALID_VDI_HANDLE {U16_MAX, 0u} |
static VDIPool | s_VDIPool |
Protected Member Functions | |
bool | refresh (BufferLock &dataLockOut, BufferLock &indexLockOut) |
Returns true if data was updated. | |
bool | getMinimalData (const vector< Vertex > &dataIn, Byte *dataOut, size_t dataOutBufferLength) |
Trim down the Vertex vector to only upload the minimal amount of data to the GPU. | |
void | draw (const GenericDrawCommand &command, VDIUserData *data) override |
Calculates the appropriate attribute offsets and returns the total size of a vertex for this buffer. | |
![]() | |
GraphicsResource (GFXDevice &context, Type type, I64 GUID, U64 nameHash) | |
![]() | |
NonCopyable ()=default | |
~NonCopyable ()=default | |
![]() | |
NonMovable ()=default | |
~NonMovable ()=default | |
Static Protected Member Functions | |
static size_t | GetTotalDataSize (const AttributeFlags &usedAttributes) |
static AttributeOffsets | GetAttributeOffsets (const AttributeFlags &usedAttributes, size_t &totalDataSizeOut) |
Protected Attributes | |
Descriptor | _descriptor |
vector< std::pair< size_t, size_t > > | _partitions |
vector< Vertex > | _data |
vector< U32 > | _indices |
Used for creating an "IB". If it's empty, then an outside source should provide the indices. | |
AttributeFlags | _useAttribute {} |
GenericVertexData_ptr | _internalGVD = nullptr |
bool | _refreshQueued = false |
bool | _dataLayoutChanged = false |
bool | _indicesChanged = true |
![]() | |
const I64 | _guid |
![]() | |
GFXDevice & | _context |
Additional Inherited Members | |
![]() | |
using | Handle = PoolHandle |
using | VDIPool = ObjectPool< VertexDataInterface, 256, true > |
![]() | |
enum class | Type : U8 { RENDER_TARGET , SHADER_BUFFER , BUFFER , SHADER , SHADER_PROGRAM , TEXTURE , COUNT } |
![]() | |
static I64 | generateGUID () noexcept |
Vertex Buffer interface class to allow API-independent implementation of data This class does NOT represent an API-level VB, such as: GL_ARRAY_BUFFER / D3DVERTEXBUFFER It is only a "buffer" for "vertex info" abstract of implementation. (e.g.: OGL uses a vertex array object for this)
Definition at line 47 of file VertexBuffer.h.
Divide::VertexBuffer::VertexBuffer | ( | GFXDevice & | context, |
const Descriptor & | descriptor | ||
) |
Definition at line 128 of file VertexBuffer.cpp.
void Divide::VertexBuffer::addIndex | ( | const U32 | index | ) |
Definition at line 232 of file VertexBuffer.cpp.
Definition at line 239 of file VertexBuffer.cpp.
Definition at line 249 of file VertexBuffer.cpp.
void Divide::VertexBuffer::addRestartIndex | ( | ) |
Definition at line 255 of file VertexBuffer.cpp.
void Divide::VertexBuffer::computeNormals | ( | ) |
Definition at line 637 of file VertexBuffer.cpp.
void Divide::VertexBuffer::computeTangents | ( | ) |
Definition at line 677 of file VertexBuffer.cpp.
bool Divide::VertexBuffer::deserialize | ( | ByteBuffer & | dataIn | ) |
Definition at line 754 of file VertexBuffer.cpp.
|
overrideprotectedvirtual |
Calculates the appropriate attribute offsets and returns the total size of a vertex for this buffer.
Implements Divide::VertexDataInterface.
Definition at line 518 of file VertexBuffer.cpp.
void Divide::VertexBuffer::fromBuffer | ( | const VertexBuffer & | other | ) |
Definition at line 739 of file VertexBuffer.cpp.
AttributeMap Divide::VertexBuffer::generateAttributeMap | ( | ) |
Activate and set all of the required vertex attributes.
Definition at line 549 of file VertexBuffer.cpp.
|
staticprotected |
Definition at line 818 of file VertexBuffer.cpp.
Definition at line 197 of file VertexBuffer.cpp.
Definition at line 207 of file VertexBuffer.cpp.
Definition at line 202 of file VertexBuffer.cpp.
U32 Divide::VertexBuffer::getIndex | ( | const size_t | index | ) | const |
Definition at line 221 of file VertexBuffer.cpp.
|
noexcept |
Definition at line 216 of file VertexBuffer.cpp.
Definition at line 227 of file VertexBuffer.cpp.
|
protected |
Trim down the Vertex vector to only upload the minimal amount of data to the GPU.
Definition at line 436 of file VertexBuffer.cpp.
Definition at line 173 of file VertexBuffer.cpp.
Definition at line 178 of file VertexBuffer.cpp.
size_t Divide::VertexBuffer::getPartitionIndexCount | ( | const U16 | partitionID | ) |
Definition at line 403 of file VertexBuffer.cpp.
size_t Divide::VertexBuffer::getPartitionOffset | ( | const U16 | partitionID | ) | const |
Definition at line 414 of file VertexBuffer.cpp.
Definition at line 163 of file VertexBuffer.cpp.
Definition at line 185 of file VertexBuffer.cpp.
Definition at line 190 of file VertexBuffer.cpp.
Definition at line 168 of file VertexBuffer.cpp.
|
staticprotected |
Definition at line 805 of file VertexBuffer.cpp.
|
noexcept |
Definition at line 140 of file VertexBuffer.cpp.
|
noexcept |
Definition at line 146 of file VertexBuffer.cpp.
size_t Divide::VertexBuffer::lastPartitionOffset | ( | ) | const |
Definition at line 425 of file VertexBuffer.cpp.
Definition at line 357 of file VertexBuffer.cpp.
Definition at line 368 of file VertexBuffer.cpp.
Definition at line 378 of file VertexBuffer.cpp.
void Divide::VertexBuffer::modifyColourValue | ( | const U32 | index, |
const U8 | r, | ||
const U8 | g, | ||
const U8 | b, | ||
const U8 | a | ||
) |
Definition at line 298 of file VertexBuffer.cpp.
Definition at line 293 of file VertexBuffer.cpp.
void Divide::VertexBuffer::modifyNormalValue | ( | const U32 | index, |
const F32 | x, | ||
const F32 | y, | ||
const F32 | z | ||
) |
Definition at line 314 of file VertexBuffer.cpp.
Definition at line 309 of file VertexBuffer.cpp.
void Divide::VertexBuffer::modifyPositionValue | ( | const U32 | index, |
const F32 | x, | ||
const F32 | y, | ||
const F32 | z | ||
) |
Definition at line 282 of file VertexBuffer.cpp.
Definition at line 277 of file VertexBuffer.cpp.
void Divide::VertexBuffer::modifyPositionValues | ( | const U32 | indexOffset, |
const vector< vec3< F32 > > & | newValues | ||
) |
Definition at line 261 of file VertexBuffer.cpp.
void Divide::VertexBuffer::modifyTangentValue | ( | const U32 | index, |
const F32 | x, | ||
const F32 | y, | ||
const F32 | z | ||
) |
Definition at line 330 of file VertexBuffer.cpp.
Definition at line 325 of file VertexBuffer.cpp.
Definition at line 346 of file VertexBuffer.cpp.
Definition at line 341 of file VertexBuffer.cpp.
U16 Divide::VertexBuffer::partitionBuffer | ( | ) |
Definition at line 394 of file VertexBuffer.cpp.
|
noexcept |
Definition at line 389 of file VertexBuffer.cpp.
|
protected |
Returns true if data was updated.
Definition at line 455 of file VertexBuffer.cpp.
void Divide::VertexBuffer::reserveIndexCount | ( | const size_t | size | ) |
Definition at line 151 of file VertexBuffer.cpp.
void Divide::VertexBuffer::reset | ( | ) |
Definition at line 730 of file VertexBuffer.cpp.
|
inline |
Definition at line 80 of file VertexBuffer.h.
void Divide::VertexBuffer::resizeVertexCount | ( | const size_t | size, |
const Vertex & | defaultValue | ||
) |
Definition at line 156 of file VertexBuffer.cpp.
bool Divide::VertexBuffer::serialize | ( | ByteBuffer & | dataOut | ) | const |
Definition at line 784 of file VertexBuffer.cpp.
void Divide::VertexBuffer::setVertexCount | ( | const size_t | size | ) |
Definition at line 135 of file VertexBuffer.cpp.
Definition at line 182 of file VertexBuffer.h.
|
protected |
Definition at line 188 of file VertexBuffer.h.
|
protected |
Definition at line 179 of file VertexBuffer.h.
Used for creating an "IB". If it's empty, then an outside source should provide the indices.
Definition at line 184 of file VertexBuffer.h.
|
protected |
Definition at line 189 of file VertexBuffer.h.
|
protected |
Definition at line 186 of file VertexBuffer.h.
|
protected |
Definition at line 181 of file VertexBuffer.h.
|
protected |
Definition at line 187 of file VertexBuffer.h.
|
protected |
Definition at line 185 of file VertexBuffer.h.
|
staticconstexpr |
Definition at line 52 of file VertexBuffer.h.
|
staticconstexpr |
Definition at line 50 of file VertexBuffer.h.
|
staticconstexpr |
Definition at line 51 of file VertexBuffer.h.