citro3d/source/drawArrays.c

32 lines
1.1 KiB
C
Raw Permalink Normal View History

2017-02-09 04:30:25 +01:00
#include "internal.h"
2014-12-20 21:34:19 +01:00
void C3D_DrawArrays(GPU_Primitive_t primitive, int first, int size)
2014-12-20 21:34:19 +01:00
{
C3Di_UpdateContext();
// Set primitive type
2015-03-05 17:56:33 +01:00
GPUCMD_AddMaskedWrite(GPUREG_PRIMITIVE_CONFIG, 2, primitive);
// Start a new primitive (breaks off a triangle strip/fan)
GPUCMD_AddWrite(GPUREG_RESTART_PRIMITIVE, 1);
// The index buffer is not used, but this command is still required
2015-03-05 17:56:33 +01:00
GPUCMD_AddWrite(GPUREG_INDEXBUFFER_CONFIG, 0x80000000);
2014-12-20 21:34:19 +01:00
// Number of vertices
GPUCMD_AddWrite(GPUREG_NUMVERTICES, size);
// First vertex
2015-09-07 19:31:48 +02:00
GPUCMD_AddWrite(GPUREG_VERTEX_OFFSET, first);
// Enable array drawing mode
GPUCMD_AddMaskedWrite(GPUREG_GEOSTAGE_CONFIG2, 1, 1);
// Enable drawing mode
GPUCMD_AddMaskedWrite(GPUREG_START_DRAW_FUNC0, 1, 0);
// Trigger array drawing
GPUCMD_AddWrite(GPUREG_DRAWARRAYS, 1);
// Go back to configuration mode
GPUCMD_AddMaskedWrite(GPUREG_START_DRAW_FUNC0, 1, 1);
// Disable array drawing mode
GPUCMD_AddMaskedWrite(GPUREG_GEOSTAGE_CONFIG2, 1, 0);
// Clear the post-vertex cache
GPUCMD_AddWrite(GPUREG_VTX_FUNC, 1);
2014-12-20 21:34:19 +01:00
2015-09-20 14:04:50 +02:00
C3Di_GetContext()->flags |= C3DiF_DrawUsed;
2014-12-20 21:34:19 +01:00
}