Skip to content

Commit

Permalink
gfx: track rendered polygon count
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Oct 4, 2024
1 parent 990aa11 commit 0851ff6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/libtrx/gfx/3d/3d_renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ void GFX_3D_Renderer_RenderBegin(GFX_3D_RENDERER *renderer)
renderer->config->enable_wireframe ? GL_LINE : GL_FILL);
GFX_GL_CheckError();

renderer->vertex_stream.rendered_count = 0;

GFX_GL_Program_Bind(&renderer->program);
GFX_3D_VertexStream_Bind(&renderer->vertex_stream);
GFX_GL_Sampler_Bind(&renderer->sampler, 0);
Expand Down
2 changes: 2 additions & 0 deletions src/libtrx/gfx/3d/vertex_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ void GFX_3D_VertexStream_Init(GFX_3D_VERTEX_STREAM *vertex_stream)
vertex_stream->pending_vertices.data = NULL;
vertex_stream->pending_vertices.count = 0;
vertex_stream->pending_vertices.capacity = 0;
vertex_stream->rendered_count = 0;

GFX_GL_Buffer_Init(&vertex_stream->buffer, GL_ARRAY_BUFFER);
GFX_GL_Buffer_Bind(&vertex_stream->buffer);
Expand Down Expand Up @@ -156,5 +157,6 @@ void GFX_3D_VertexStream_RenderPending(GFX_3D_VERTEX_STREAM *vertex_stream)
vertex_stream->pending_vertices.count);
GFX_GL_CheckError();

vertex_stream->rendered_count += vertex_stream->pending_vertices.count;
vertex_stream->pending_vertices.count = 0;
}
1 change: 1 addition & 0 deletions src/libtrx/include/libtrx/gfx/3d/vertex_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ typedef struct {
size_t count;
size_t capacity;
} pending_vertices;
size_t rendered_count;
} GFX_3D_VERTEX_STREAM;

void GFX_3D_VertexStream_Init(GFX_3D_VERTEX_STREAM *vertex_stream);
Expand Down

0 comments on commit 0851ff6

Please sign in to comment.