mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-05-05 11:44:49 +12:00
Use std::span
to pass vertex data
Starts utilizing [std::span](https://en.cppreference.com/w/cpp/container/span) to indicate a non-owning view of a contiguous array of elements rather than `T* data, usize count`.
This commit is contained in:
parent
c6f5d19983
commit
553d23974a
5 changed files with 32 additions and 24 deletions
|
@ -1,7 +1,10 @@
|
|||
#include "PICA/gpu.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <cstdio>
|
||||
|
||||
#include "PICA/float_types.hpp"
|
||||
#include "PICA/regs.hpp"
|
||||
#include <cstdio>
|
||||
|
||||
using namespace Floats;
|
||||
|
||||
|
@ -41,7 +44,7 @@ void GPU::drawArrays(bool indexed) {
|
|||
drawArrays<false>();
|
||||
}
|
||||
|
||||
Vertex* vertices = new Vertex[Renderer::vertexBufferSize];
|
||||
static std::array<Vertex, Renderer::vertexBufferSize> vertices;
|
||||
|
||||
template <bool indexed>
|
||||
void GPU::drawArrays() {
|
||||
|
@ -205,7 +208,7 @@ void GPU::drawArrays() {
|
|||
OpenGL::Triangle, OpenGL::TriangleStrip, OpenGL::TriangleFan, OpenGL::Triangle
|
||||
};
|
||||
const auto shape = primTypes[primType];
|
||||
renderer.drawVertices(shape, vertices, vertexCount);
|
||||
renderer.drawVertices(shape, std::span(vertices).first(vertexCount));
|
||||
}
|
||||
|
||||
Vertex GPU::getImmediateModeVertex() {
|
||||
|
|
|
@ -157,7 +157,7 @@ void GPU::writeInternalReg(u32 index, u32 value, u32 mask) {
|
|||
// If we've reached 3 verts, issue a draw call
|
||||
// Handle rendering depending on the primitive type
|
||||
if (immediateModeVertIndex == 3) {
|
||||
renderer.drawVertices(OpenGL::Triangle, &immediateModeVertices[0], 3);
|
||||
renderer.drawVertices(OpenGL::Triangle, immediateModeVertices);
|
||||
|
||||
switch (primType) {
|
||||
// Triangle or geometry primitive. Draw a triangle and discard all vertices
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue