diff options
Diffstat (limited to 'src/ral/backends/opengl')
-rw-r--r-- | src/ral/backends/opengl/backend_opengl.c | 14 | ||||
-rw-r--r-- | src/ral/backends/opengl/opengl_helpers.h | 13 |
2 files changed, 25 insertions, 2 deletions
diff --git a/src/ral/backends/opengl/backend_opengl.c b/src/ral/backends/opengl/backend_opengl.c index 3822220..613d7e1 100644 --- a/src/ral/backends/opengl/backend_opengl.c +++ b/src/ral/backends/opengl/backend_opengl.c @@ -411,11 +411,21 @@ void GPU_EncodeSetIndexBuffer(GPU_CmdEncoder* encoder, BufferHandle buf) { GPU_Buffer* buffer = BUFFER_GET(buf); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer->id.ibo); } -void GPU_EncodeDraw(GPU_CmdEncoder* encoder, u64 count) { glDrawArrays(GL_TRIANGLES, 0, count); } -void GPU_EncodeDrawIndexed(GPU_CmdEncoder* encoder, u64 index_count) { +void GPU_EncodeDrawTris(GPU_CmdEncoder* encoder, u64 count) { + glDrawArrays(GL_TRIANGLES, 0, count); +} +void GPU_EncodeDrawIndexedTris(GPU_CmdEncoder* encoder, u64 index_count) { glDrawElements(GL_TRIANGLES, index_count, GL_UNSIGNED_INT, 0); } +PUB void GPU_EncodeDraw(GPU_CmdEncoder* encoder, PrimitiveTopology topology, u64 count) { + glDrawArrays(opengl_prim_topology(topology), 0, count); +} +PUB void GPU_EncodeDrawIndexed(GPU_CmdEncoder* encoder, PrimitiveTopology topology, + u64 index_count) { + glDrawElements(opengl_prim_topology(topology), index_count, GL_UNSIGNED_INT, 0); +} + PUB void GPU_WriteTextureRegion(GPU_CmdEncoder* encoder, TextureHandle dst, u32 x_offset, u32 y_offset, u32 width, u32 height, const void* data) { CASSERT_MSG(data, "const void* data must not be NULL"); diff --git a/src/ral/backends/opengl/opengl_helpers.h b/src/ral/backends/opengl/opengl_helpers.h index 8a78de5..b73eaea 100644 --- a/src/ral/backends/opengl/opengl_helpers.h +++ b/src/ral/backends/opengl/opengl_helpers.h @@ -138,4 +138,17 @@ static GLenum opengl_tex_type(GPU_TextureType tex_type) { } } +static GLenum opengl_prim_topology(PrimitiveTopology t) { + switch (t) { + case CEL_POINT: return GL_POINT; + case CEL_LINE: return GL_LINES; + case CEL_LINE_STRIP: return GL_LINE_STRIP; + case CEL_TRI: return GL_TRIANGLES; + case CEL_TRI_STRIP: return GL_TRIANGLE_STRIP; + case PRIMITIVE_TOPOLOGY_COUNT: + WARN("Invalid PrimitiveTopology value"); + break; + } +} + #endif |