mirror of
https://github.com/love2d/love.git
synced 2026-08-14 01:20:56 +02:00
Add love.graphics.drawShaderVertices (name subject to change).
It draws a number of vertices, or a number of indices from an index buffer, without using any vertex data from a vertex buffer. A custom shader is required while using it. It is useful when a custom GLSL3 vertex shader which uses love_VertexID is used to pull or compute per-vertex information from other sources.
This commit is contained in:
@@ -2938,6 +2938,42 @@ int w_drawInstanced(lua_State *L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_drawShaderVertices(lua_State *L)
|
||||
{
|
||||
if (luax_istype(L, 1, Buffer::type))
|
||||
{
|
||||
// Indexed drawing.
|
||||
Buffer *t = luax_checkbuffer(L, 1);
|
||||
|
||||
int indexcount = (int) luaL_checkinteger(L, 2);
|
||||
int instancecount = (int) luaL_optinteger(L, 3, 1);
|
||||
int indexstart = (int) luaL_optinteger(L, 4, 1) - 1;
|
||||
|
||||
Texture *tex = nullptr;
|
||||
if (!lua_isnoneornil(L, 5))
|
||||
tex = luax_checktexture(L, 5);
|
||||
|
||||
luax_catchexcept(L, [&]() { instance()->drawShaderVertices(t, indexcount, instancecount, indexstart, tex); });
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *primstr = luaL_checkstring(L, 1);
|
||||
PrimitiveType primtype = PRIMITIVE_TRIANGLES;
|
||||
if (!getConstant(primstr, primtype))
|
||||
return luax_enumerror(L, "primitive type", getConstants(primtype), primstr);
|
||||
|
||||
int vertexcount = (int) luaL_checkinteger(L, 2);
|
||||
int instancecount = (int) luaL_optinteger(L, 3, 1);
|
||||
|
||||
Texture *tex = nullptr;
|
||||
if (!lua_isnoneornil(L, 4))
|
||||
tex = luax_checktexture(L, 4);
|
||||
|
||||
luax_catchexcept(L, [&]() { instance()->drawShaderVertices(primtype, vertexcount, instancecount, tex); });
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_print(lua_State *L)
|
||||
{
|
||||
std::vector<Font::ColoredString> str;
|
||||
@@ -3614,6 +3650,7 @@ static const luaL_Reg functions[] =
|
||||
{ "draw", w_draw },
|
||||
{ "drawLayer", w_drawLayer },
|
||||
{ "drawInstanced", w_drawInstanced },
|
||||
{ "drawShaderVertices", w_drawShaderVertices },
|
||||
|
||||
{ "print", w_print },
|
||||
{ "printf", w_printf },
|
||||
|
||||
Reference in New Issue
Block a user