Vertex and Index buffer API

Typedefs

using Ibuffer = Sbuffer
using Vbuffer = Sbuffer
namespace d3d

Functions

Sbuffer *create_vb(int size_bytes, int flags, const char *name = "")

Creates a vertex buffer.

This function creates a vertex buffer with the specified size and flags.

Todo:

Make the name parameter mandatory.

Parameters:
  • size_bytes – The size of the vertex buffer in bytes.

  • flags – The creation flags.

  • name – The name of the vertex buffer (temporarily optional).

Returns:

A pointer to the created vertex buffer.

Sbuffer *create_ib(int size_bytes, int flags, const char *stat_name = "ib")

Creates an index buffer.

This function creates an index buffer with the specified size and flags.

Todo:

Make the name parameter mandatory.

Parameters:
  • size_bytes – The size of the index buffer in bytes.

  • flags – The creation flags.

  • stat_name – The name of the index buffer (temporarily optional).

Returns:

A pointer to the created index buffer.

bool setvsrc_ex(int stream, Sbuffer *vb, int offset, int stride_bytes)

Sets the vertex buffer as a stream source.

This function sets the vertex buffer as a stream source for the specified stream.

Parameters:
  • stream – The stream index.

  • vb – A pointer to the vertex buffer.

  • offset – The offset in bytes from the start of the vertex buffer.

  • stride_bytes – The stride in bytes between vertices.

Returns:

True if the vertex stream source was set successfully, false otherwise.

inline bool setvsrc(int stream, Sbuffer *vb, int stride_bytes)

Sets the vertex buffer as a stream source.

This function sets the vertex buffer as a stream source for the specified stream.

Parameters:
  • stream – The stream index.

  • vb – A pointer to the vertex buffer.

  • stride_bytes – The stride in bytes between vertices.

Returns:

True if the vertex stream source was set successfully, false otherwise.

bool setind(Sbuffer *ib)

Sets the index buffer.

This function sets the index buffer for rendering.

Parameters:

ib – A pointer to the index buffer.

Returns:

True if the indices were set successfully, false otherwise.

VDECL create_vdecl(VSDTYPE *vsd)

Creates a DX8-style vertex declaration.

This function creates a DX8-style vertex declaration based on the specified vertex shader declaration.

Todo:

Do we really need to support DX8-style vertex declarations? Maybe it’s time to look for a more modern solution.

Parameters:

vsd – The vertex shader declaration.

Returns:

The created vertex declaration, or BAD_VDECL on error.

void delete_vdecl(VDECL vdecl)

Deletes a vertex declaration.

This function deletes a vertex declaration.

Parameters:

vdecl – The vertex declaration to delete.

bool setvdecl(VDECL vdecl)

Sets the current vertex declaration.

This function sets the current vertex declaration for rendering.

Parameters:

vdecl – The vertex declaration to set.

Returns:

True if the vertex declaration was set successfully, false otherwise.