summaryrefslogtreecommitdiffstats
path: root/src/renderer/RenderBuffer.cpp
diff options
context:
space:
mode:
authorNikolay Korolev <nickvnuk@gmail.com>2021-07-23 23:47:04 +0200
committerNikolay Korolev <nickvnuk@gmail.com>2021-07-23 23:47:04 +0200
commita7e673c2ec6a5ed25f3bae8caab90e2113158c03 (patch)
tree8c88859a32b0613a4c28fd1a0432504403e5a5e6 /src/renderer/RenderBuffer.cpp
parentfix premake (diff)
downloadre3-a7e673c2ec6a5ed25f3bae8caab90e2113158c03.tar
re3-a7e673c2ec6a5ed25f3bae8caab90e2113158c03.tar.gz
re3-a7e673c2ec6a5ed25f3bae8caab90e2113158c03.tar.bz2
re3-a7e673c2ec6a5ed25f3bae8caab90e2113158c03.tar.lz
re3-a7e673c2ec6a5ed25f3bae8caab90e2113158c03.tar.xz
re3-a7e673c2ec6a5ed25f3bae8caab90e2113158c03.tar.zst
re3-a7e673c2ec6a5ed25f3bae8caab90e2113158c03.zip
Diffstat (limited to 'src/renderer/RenderBuffer.cpp')
-rw-r--r--src/renderer/RenderBuffer.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/renderer/RenderBuffer.cpp b/src/renderer/RenderBuffer.cpp
new file mode 100644
index 00000000..6120dfe2
--- /dev/null
+++ b/src/renderer/RenderBuffer.cpp
@@ -0,0 +1,52 @@
+#include "common.h"
+
+#include "RenderBuffer.h"
+
+int32 TempBufferVerticesStored;
+int32 TempBufferIndicesStored;
+
+RwIm3DVertex TempBufferRenderVertices[TEMPBUFFERVERTSIZE];
+RwImVertexIndex TempBufferRenderIndexList[TEMPBUFFERINDEXSIZE];
+
+int RenderBuffer::VerticesToBeStored;
+int RenderBuffer::IndicesToBeStored;
+
+void
+RenderBuffer::ClearRenderBuffer(void)
+{
+ TempBufferVerticesStored = 0;
+ TempBufferIndicesStored = 0;
+}
+
+void
+RenderBuffer::StartStoring(int numIndices, int numVertices, RwImVertexIndex **indexStart, RwIm3DVertex **vertexStart)
+{
+ if(TempBufferIndicesStored + numIndices >= TEMPBUFFERINDEXSIZE)
+ RenderStuffInBuffer();
+ if(TempBufferVerticesStored + numVertices >= TEMPBUFFERVERTSIZE)
+ RenderStuffInBuffer();
+ *indexStart = &TempBufferRenderIndexList[TempBufferIndicesStored];
+ *vertexStart = &TempBufferRenderVertices[TempBufferVerticesStored];
+ 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)
+{
+ if(TempBufferVerticesStored && RwIm3DTransform(TempBufferRenderVertices, TempBufferVerticesStored, nil, rwIM3D_VERTEXUV)){
+ RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, TempBufferRenderIndexList, TempBufferIndicesStored);
+ RwIm3DEnd();
+ }
+ ClearRenderBuffer();
+}