1
0
Fork 0
mirror of https://github.com/halpz/re3.git synced 2024-12-28 18:35:29 +00:00
re3/src/render/RenderBuffer.cpp

54 lines
1.6 KiB
C++
Raw Normal View History

2019-05-15 14:52:37 +00:00
#include "common.h"
2020-04-17 13:31:11 +00:00
2019-05-15 14:52:37 +00:00
#include "RenderBuffer.h"
2020-04-17 05:54:14 +00:00
int32 TempBufferVerticesStored;
int32 TempBufferIndicesStored;
2019-05-15 14:52:37 +00:00
2020-06-07 01:11:10 +00:00
RwIm2DVertex TempVertexBuffer[TEMPBUFFERVERTSIZE];
RwIm3DVertex *TempBufferRenderVertices = (RwIm3DVertex * )TempVertexBuffer;
2020-04-17 05:54:14 +00:00
RwImVertexIndex TempBufferRenderIndexList[TEMPBUFFERINDEXSIZE];
2019-05-15 14:52:37 +00:00
2020-04-17 05:54:14 +00:00
int RenderBuffer::VerticesToBeStored;
int RenderBuffer::IndicesToBeStored;
2019-05-15 14:52:37 +00:00
void
RenderBuffer::ClearRenderBuffer(void)
{
TempBufferVerticesStored = 0;
TempBufferIndicesStored = 0;
}
void
RenderBuffer::StartStoring(int numIndices, int numVertices, RwImVertexIndex **indexStart, RwIm3DVertex **vertexStart)
{
2019-07-11 00:22:01 +00:00
if(TempBufferIndicesStored + numIndices >= TEMPBUFFERINDEXSIZE)
2019-05-15 14:52:37 +00:00
RenderStuffInBuffer();
2019-07-11 00:22:01 +00:00
if(TempBufferVerticesStored + numVertices >= TEMPBUFFERVERTSIZE)
2019-05-15 14:52:37 +00:00
RenderStuffInBuffer();
*indexStart = &TempBufferRenderIndexList[TempBufferIndicesStored];
2019-07-11 00:22:01 +00:00
*vertexStart = &TempBufferRenderVertices[TempBufferVerticesStored];
2019-05-15 14:52:37 +00:00
IndicesToBeStored = numIndices;
VerticesToBeStored = numVertices;
}
void
RenderBuffer::StopStoring(void)
{
int i;
for(i = TempBufferIndicesStored; i < TempBufferIndicesStored+IndicesToBeStored; i++)
TempBufferRenderIndexList[i] += TempBufferVerticesStored;
TempBufferIndicesStored += IndicesToBeStored;
TempBufferVerticesStored += VerticesToBeStored;
}
void
RenderBuffer::RenderStuffInBuffer(void)
{
2019-07-11 00:22:01 +00:00
if(TempBufferVerticesStored && RwIm3DTransform(TempBufferRenderVertices, TempBufferVerticesStored, nil, rwIM3D_VERTEXUV)){
2019-05-15 14:52:37 +00:00
RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, TempBufferRenderIndexList, TempBufferIndicesStored);
RwIm3DEnd();
}
ClearRenderBuffer();
}