citro3d
Macros | Enumerations | Functions
base.h File Reference

Base citro3d functions. More...

#include "buffers.h"
#include "maths.h"

Go to the source code of this file.

Macros

#define C3D_DEFAULT_CMDBUF_SIZE   0x40000
 Default command buffer size.
 

Enumerations

enum  {
  C3D_UNSIGNED_BYTE = 0 ,
  C3D_UNSIGNED_SHORT = 1
}
 Data type of indices for use with C3D_DrawElements(). More...
 

Functions

bool C3D_Init (size_t cmdBufSize)
 Initializes citro3d. More...
 
void C3D_Fini (void)
 Deinitializes citro3d. More...
 
float C3D_GetCmdBufUsage (void)
 Retrieves the current command buffer usage. More...
 
void C3D_BindProgram (shaderProgram_s *program)
 Binds a shader program to the current rendering state. More...
 
void C3D_SetViewport (u32 x, u32 y, u32 w, u32 h)
 Sets the viewport for the current framebuffer. More...
 
void C3D_SetScissor (GPU_SCISSORMODE mode, u32 left, u32 top, u32 right, u32 bottom)
 Defines the scissor box. More...
 
void C3D_DrawArrays (GPU_Primitive_t primitive, int first, int size)
 Renders primitives from current vertex array buffer. More...
 
void C3D_DrawElements (GPU_Primitive_t primitive, int count, int type, const void *indices)
 Renders primitives from current vertex array buffer in a manually specified order. More...
 
Immediate-mode vertex submission
void C3D_ImmDrawBegin (GPU_Primitive_t primitive)
 Delimits the vertices of a primitive or a group of like primitives. More...
 
void C3D_ImmSendAttrib (float x, float y, float z, float w)
 Specifies an immediate attribute. More...
 
void C3D_ImmDrawEnd (void)
 Delimits the vertices of a primitive or a group of like primitives. More...
 
static void C3D_ImmDrawRestartPrim (void)
 Specifies the end of the previous strip/fan and the beginning of a new one. More...
 
Fixed vertex attributes
C3D_FVecC3D_FixedAttribGetWritePtr (int id)
 Gets the pointer to the fixed attribute vector for the specified attribute index. More...
 
static void C3D_FixedAttribSet (int id, float x, float y, float z, float w)
 Sets fixed attribute vector for the specified attribute index. More...
 

Detailed Description

Base citro3d functions.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Data type of indices for use with C3D_DrawElements().

Enumerator
C3D_UNSIGNED_BYTE 

Unsigned 8-bit integer.

C3D_UNSIGNED_SHORT 

Unsigned 16-bit integer.

Function Documentation

◆ C3D_BindProgram()

void C3D_BindProgram ( shaderProgram_s program)

Binds a shader program to the current rendering state.

Parameters
[in]programSpecifies the pointer to a shader program object whose executables are to be used as part of the current rendering state.

◆ C3D_DrawArrays()

void C3D_DrawArrays ( GPU_Primitive_t  primitive,
int  first,
int  size 
)

Renders primitives from current vertex array buffer.

Parameters
[in]primitiveSpecifies what kind of primitives to render.
[in]firstSpecifies the starting index in the current buffers.
[in]sizeSpecifies the number of indices to be rendered.

◆ C3D_DrawElements()

void C3D_DrawElements ( GPU_Primitive_t  primitive,
int  count,
int  type,
const void *  indices 
)

Renders primitives from current vertex array buffer in a manually specified order.

Parameters
[in]primitiveSpecifies what kind of primitives to render.
[in]countSpecifies the number of indices to be rendered.
[in]typeSpecifies the data type of the indices. May be C3D_UNSIGNED_BYTE or C3D_UNSIGNED_SHORT.
[in]indicesSpecifies a pointer to where the indices are stored.

◆ C3D_Fini()

void C3D_Fini ( void  )

Deinitializes citro3d.

See also
C3D_Init()

◆ C3D_FixedAttribGetWritePtr()

C3D_FVec* C3D_FixedAttribGetWritePtr ( int  id)

Gets the pointer to the fixed attribute vector for the specified attribute index.

Parameters
[in]idAttribute index.
Returns
Pointer to the fixed attribute vector for the current attribute.
See also
C3D_FixedAttribSet()

◆ C3D_FixedAttribSet()

static void C3D_FixedAttribSet ( int  id,
float  x,
float  y,
float  z,
float  w 
)
inlinestatic

Sets fixed attribute vector for the specified attribute index.

Note
The attribute index should be the same as returned by AttrInfo_AddFixed().
Parameters
[in]idAttribute index.
[in]xSpecifies the X value of the attribute.
[in]ySpecifies the Y value of the attribute.
[in]zSpecifies the Z value of the attribute.
[in]wSpecifies the W value of the attribute.

◆ C3D_GetCmdBufUsage()

float C3D_GetCmdBufUsage ( void  )

Retrieves the current command buffer usage.

Returns
Fraction of command buffer used. (0.0f to 1.0f)

◆ C3D_ImmDrawBegin()

void C3D_ImmDrawBegin ( GPU_Primitive_t  primitive)

Delimits the vertices of a primitive or a group of like primitives.

Parameters
[in]primitiveSpecifies type of primitive or primitives that will be created using the vertices specified between C3D_ImmDrawBegin() and C3D_ImmDrawEnd().

◆ C3D_ImmDrawEnd()

void C3D_ImmDrawEnd ( void  )

Delimits the vertices of a primitive or a group of like primitives.

See also
C3D_ImmDrawBegin()

◆ C3D_ImmDrawRestartPrim()

static void C3D_ImmDrawRestartPrim ( void  )
inlinestatic

Specifies the end of the previous strip/fan and the beginning of a new one.

See also
C3D_ImmDrawBegin()

◆ C3D_ImmSendAttrib()

void C3D_ImmSendAttrib ( float  x,
float  y,
float  z,
float  w 
)

Specifies an immediate attribute.

Note
Attributes must be specified in the same order they were specified using AttrInfo_AddLoader().
Parameters
[in]xSpecifies the X value of the current attribute.
[in]ySpecifies the Y value of the current attribute.
[in]zSpecifies the Z value of the current attribute.
[in]wSpecifies the W value of the current attribute.

◆ C3D_Init()

bool C3D_Init ( size_t  cmdBufSize)

Initializes citro3d.

Parameters
[in]cmdBufSizeDesired size of GPU command buffer. C3D_DEFAULT_CMDBUF_SIZE should generally be used here.
Note
If you have a particularly complex scene you might need to specify a larger cmdBufSize. Conversely, you may want to decrease it if you're particularly concerned about memory consumption.
Returns
true if library was initialized successfully, false if there was an error.

◆ C3D_SetScissor()

void C3D_SetScissor ( GPU_SCISSORMODE  mode,
u32  left,
u32  top,
u32  right,
u32  bottom 
)

Defines the scissor box.

Note
When using this with a rendertarget intended for display, keep in mind the orientation of the screens.
Parameters
[in]modeSpecifies scissoring mode.
[in]leftLeftmost boundary in pixels.
[in]topTopmost boundary in pixels.
[in]rightRightmost boundary in pixels.
[in]bottomBottommost boundary in pixels.

◆ C3D_SetViewport()

void C3D_SetViewport ( u32  x,
u32  y,
u32  w,
u32  h 
)

Sets the viewport for the current framebuffer.

Note
This function is called by C3D_FrameDrawOn(). (using values specified by C3D_RenderTargetCreate())
When using this with a rendertarget intended for display, keep in mind the orientation of the screens.
Parameters
[in]xX offset from the origin of the viewport in pixels.
[in]yY offset from the origin of the viewport in pixels.
[in]wWidth of the viewport in pixels.
[in]hHeight of the viewport in pixels.