From 39a4d2c1d5278681bcb153b8a3c38b048adbe0ae Mon Sep 17 00:00:00 2001 From: bjorn Date: Sat, 20 Feb 2021 17:41:50 -0700 Subject: [PATCH] rm lovr.graphics.triangle; --- src/api/l_graphics.c | 18 ------------------ src/modules/graphics/graphics.c | 28 ---------------------------- src/modules/graphics/graphics.h | 1 - 3 files changed, 47 deletions(-) diff --git a/src/api/l_graphics.c b/src/api/l_graphics.c index 69d96dae..059e2b2e 100644 --- a/src/api/l_graphics.c +++ b/src/api/l_graphics.c @@ -931,23 +931,6 @@ static int l_lovrGraphicsLine(lua_State* L) { return 0; } -static int l_lovrGraphicsTriangle(lua_State* L) { - DrawStyle style = STYLE_FILL; - Material* material = NULL; - if (lua_isuserdata(L, 1)) { - material = luax_checktype(L, 1, Material); - } else { - style = luax_checkenum(L, 1, DrawStyle, NULL); - } - - float* vertices; - uint32_t count = luax_getvertexcount(L, 2); - lovrAssert(count % 3 == 0, "Triangle vertex count must be a multiple of 3"); - lovrGraphicsTriangle(style, material, count, &vertices); - luax_readvertices(L, 2, vertices, count); - return 0; -} - static int l_lovrGraphicsPlane(lua_State* L) { DrawStyle style = STYLE_FILL; Material* material = NULL; @@ -1809,7 +1792,6 @@ static const luaL_Reg lovrGraphics[] = { { "flush", l_lovrGraphicsFlush }, { "points", l_lovrGraphicsPoints }, { "line", l_lovrGraphicsLine }, - { "triangle", l_lovrGraphicsTriangle }, { "plane", l_lovrGraphicsPlane }, { "cube", l_lovrGraphicsCube }, { "box", l_lovrGraphicsBox }, diff --git a/src/modules/graphics/graphics.c b/src/modules/graphics/graphics.c index d0816a25..0448047e 100644 --- a/src/modules/graphics/graphics.c +++ b/src/modules/graphics/graphics.c @@ -32,7 +32,6 @@ typedef enum { typedef enum { BATCH_POINTS, BATCH_LINES, - BATCH_TRIANGLES, BATCH_PLANE, BATCH_BOX, BATCH_ARC, @@ -867,33 +866,6 @@ void lovrGraphicsLine(uint32_t count, float** vertices) { } } -void lovrGraphicsTriangle(DrawStyle style, Material* material, uint32_t count, float** vertices) { - uint32_t indexCount = style == STYLE_LINE ? (4 * count / 3) : 0; - uint16_t* indices; - uint16_t baseVertex; - - lovrGraphicsBatch(&(BatchRequest) { - .type = BATCH_TRIANGLES, - .params.triangles.style = style, - .topology = style == STYLE_LINE ? DRAW_LINE_LOOP : DRAW_TRIANGLES, - .material = material, - .vertexCount = count, - .vertices = vertices, - .indexCount = indexCount, - .indices = &indices, - .baseVertex = &baseVertex - }); - - if (style == STYLE_LINE) { - for (uint32_t i = 0; i < count; i += 3) { - *indices++ = 0xffff; - *indices++ = baseVertex + i + 0; - *indices++ = baseVertex + i + 1; - *indices++ = baseVertex + i + 2; - } - } -} - void lovrGraphicsPlane(DrawStyle style, Material* material, mat4 transform, float u, float v, float w, float h) { float* vertices = NULL; uint16_t* indices = NULL; diff --git a/src/modules/graphics/graphics.h b/src/modules/graphics/graphics.h index 82213409..268f7e78 100644 --- a/src/modules/graphics/graphics.h +++ b/src/modules/graphics/graphics.h @@ -157,7 +157,6 @@ void lovrGraphicsClear(Color* color, float* depth, int* stencil); void lovrGraphicsDiscard(bool color, bool depth, bool stencil); void lovrGraphicsPoints(uint32_t count, float** vertices); void lovrGraphicsLine(uint32_t count, float** vertices); -void lovrGraphicsTriangle(DrawStyle style, struct Material* material, uint32_t count, float** vertices); void lovrGraphicsPlane(DrawStyle style, struct Material* material, mat4 transform, float u, float v, float w, float h); void lovrGraphicsBox(DrawStyle style, struct Material* material, mat4 transform); void lovrGraphicsArc(DrawStyle style, ArcMode mode, struct Material* material, mat4 transform, float r1, float r2, int segments);