citro3d
Data Structures | Functions
buffers.h File Reference

Configure vertex array buffers. More...

#include "types.h"

Go to the source code of this file.

Data Structures

struct  C3D_BufCfg
 Vertex buffer config. More...
 
struct  C3D_BufInfo
 Vertex buffer info. More...
 

Functions

void BufInfo_Init (C3D_BufInfo *info)
 Resets and initializes C3D_BufInfo structure to default values. More...
 
int BufInfo_Add (C3D_BufInfo *info, const void *data, ptrdiff_t stride, int attribCount, u64 permutation)
 Adds a buffer to the vertex buffer info struct. More...
 
C3D_BufInfoC3D_GetBufInfo (void)
 Gets pointer to the global C3D_BufInfo structure. More...
 
void C3D_SetBufInfo (C3D_BufInfo *info)
 Sets global C3D_BufInfo structure. Copies values from the specified C3D_BufInfo structure to the global C3D_BufInfo structure. More...
 

Detailed Description

Configure vertex array buffers.

Function Documentation

◆ BufInfo_Add()

int BufInfo_Add ( C3D_BufInfo info,
const void *  data,
ptrdiff_t  stride,
int  attribCount,
u64  permutation 
)

Adds a buffer to the vertex buffer info struct.

Note
The attribute indices specified in permutation should be the same as the ones returned by AttrInfo_AddLoader()
Parameters
[out]infoPointer to a C3D_BufInfo struct.
[in]dataPointer to buffer.
[in]strideDistance in bytes between vertex entries in the buffer (usually set to the size of the vertex structure).
[in]attribCountNumber of attributes to load from this buffer.
[in]permutationSpecifies the order of attributes in the buffer. Each attribute index is a nibble (4 bits), and they are ordered from least significant to most significant. Padding can be specified with 0xC, 0xD, 0xE and 0xF. (See https://3dbrew.org/wiki/GPU/Internal_Registers#GPUREG_ATTRIBBUFFERi_CONFIG1 for more info)
Remarks
Using this, one can rearrange the positions of attributes in the struct. For example, with three attributes in this buffer, setting this to 0x210 would configure the permutation to be the first attribute index, then the second, then the third. 0x120 would configure the permutation to be the first attribute index, then the third, then the second.
Returns
Buffer index if successful, negative value on failure.

◆ BufInfo_Init()

void BufInfo_Init ( C3D_BufInfo info)

Resets and initializes C3D_BufInfo structure to default values.

Parameters
[out]infoPointer to vertex buffer info structure.

◆ C3D_GetBufInfo()

C3D_BufInfo* C3D_GetBufInfo ( void  )

Gets pointer to the global C3D_BufInfo structure.

Returns
Pointer to C3D_BufInfo. This should not be freed.

◆ C3D_SetBufInfo()

void C3D_SetBufInfo ( C3D_BufInfo info)

Sets global C3D_BufInfo structure. Copies values from the specified C3D_BufInfo structure to the global C3D_BufInfo structure.

Parameters
[in]infoPointer to user C3D_BufInfo.