Skip to content
Chuck Walbourn edited this page Nov 12, 2018 · 3 revisions

File Format Details

The VBO object is essentially a binary dump of a VB and an IB. It does not describe the input layout, the vertex size, attributes or material information, or support 32-bit index buffers.

DWORD numVertices
DWORD numIndices
<vertex data>
<16-bit index data>

The ResourceLoading sample used a vertex layout of { XMFLOAT3 position, XMFLOAT3 normal, XMFLOAT2 textureCoordinates } which is assumed to be fixed for the format. Variants could use alternative vertex formats, but this information is not encoded in the VBO file itself.

Example Code

std::ifstream vboFile(szFileName, std::ifstream::in | std::ifstream::binary);
if ( !vboFile.is_open() )
    return HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND );

uint32_t numVertices = 0;
uint32_t numIndices = 0;

vboFile.read( reinterpret_cast<char*>( &numVertices ), sizeof(uint32_t ) );
if ( !numVertices )
    return E_FAIL;

vboFile.read( reinterpret_cast<char*>( &numIndices ), sizeof(uint32_t ) );
if ( !numIndices )
    return E_FAIL;

struct Vertex
{
    XMFLOAT3 position;
    XMFLOAT3 normal;
    XMFLOAT2 textureCoordinates;
};

std::vector<Vertex> vertices;
vertices.resize( numVertices );
vboFile.read( reinterpret_cast<char*>( vertices.data() ), sizeof(Vertex) * numVertices );

std::vector<uint16_t> indices;
indices.resize( numIndices );
vboFile.read( reinterpret_cast<char*>( indices.data() ), sizeof(uint16_t) * numIndices );

For Use

  • Universal Windows Platform apps
  • Windows desktop apps
  • Windows 11
  • Windows 10
  • Windows 8.1
  • Windows 7 Service Pack 1
  • Xbox One
  • Xbox Series X|S
  • Windows Subsystem for Linux

Architecture

  • x86
  • x64
  • ARM64

For Development

  • Visual Studio 2022
  • Visual Studio 2019 (16.11)
  • clang/LLVM v12 - v18
  • GCC 10.5, 11.4, 12.3
  • MinGW 12.2, 13.2
  • CMake 3.20

Related Projects

DirectX Tool Kit for DirectX 11

DirectX Tool Kit for DirectX 12

DirectXTex

DirectXMath

Tools

Test Suite

Content Exporter

DxCapsViewer

See also

DirectX Landing Page

Clone this wiki locally