Rename love.graphics.drawShaderVertices to drawFromShader.

This commit is contained in:
Sasha Szpakowski
2023-02-05 15:16:10 -04:00
parent e13b0078a2
commit d3747cebb1
4 changed files with 20 additions and 20 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ Released: N/A
* Added Compute Shader support via new 'computemain' shader entry point. * Added Compute Shader support via new 'computemain' shader entry point.
* Added love.graphics.dispatchThreadgroups for running compute shaders. * Added love.graphics.dispatchThreadgroups for running compute shaders.
* Added Shader:hasStage. * Added Shader:hasStage.
* Added love.graphics.drawShaderVertices. * Added love.graphics.drawFromShader.
* Added love.graphics.getQuadIndexBuffer. * Added love.graphics.getQuadIndexBuffer.
* Added variants of love.graphics.applyTransform and replaceTransform which accept x,y,angle,sx,sy,ox,oy parameters. * Added variants of love.graphics.applyTransform and replaceTransform which accept x,y,angle,sx,sy,ox,oy parameters.
* Added APIs to override the default orthographic projection: love.graphics.setOrthoProjection, setPerspectiveProjection, and resetProjection. * Added APIs to override the default orthographic projection: love.graphics.setOrthoProjection, setPerspectiveProjection, and resetProjection.
+13 -13
View File
@@ -1819,29 +1819,29 @@ void Graphics::drawInstanced(Mesh *mesh, const Matrix4 &m, int instancecount)
mesh->drawInstanced(this, m, instancecount); mesh->drawInstanced(this, m, instancecount);
} }
void Graphics::drawShaderVertices(PrimitiveType primtype, int vertexcount, int instancecount, Texture *maintexture) void Graphics::drawFromShader(PrimitiveType primtype, int vertexcount, int instancecount, Texture *maintexture)
{ {
if (primtype == PRIMITIVE_TRIANGLE_FAN && vertexcount > LOVE_UINT16_MAX) if (primtype == PRIMITIVE_TRIANGLE_FAN && vertexcount > LOVE_UINT16_MAX)
throw love::Exception("drawShaderVertices cannot draw more than %d vertices when the 'fan' draw mode is used.", LOVE_UINT16_MAX); throw love::Exception("drawFromShader cannot draw more than %d vertices when the 'fan' draw mode is used.", LOVE_UINT16_MAX);
// Emulated triangle fan via an index buffer. // Emulated triangle fan via an index buffer.
if (primtype == PRIMITIVE_TRIANGLE_FAN && getFanIndexBuffer()) if (primtype == PRIMITIVE_TRIANGLE_FAN && getFanIndexBuffer())
{ {
int indexcount = getIndexCount(TRIANGLEINDEX_FAN, vertexcount); int indexcount = getIndexCount(TRIANGLEINDEX_FAN, vertexcount);
drawShaderVertices(getFanIndexBuffer(), indexcount, instancecount, 0, maintexture); drawFromShader(getFanIndexBuffer(), indexcount, instancecount, 0, maintexture);
return; return;
} }
flushBatchedDraws(); flushBatchedDraws();
if (!capabilities.features[FEATURE_GLSL3]) if (!capabilities.features[FEATURE_GLSL3])
throw love::Exception("drawShaderVertices is not supported on this system (GLSL3 support is required.)"); throw love::Exception("drawFromShader is not supported on this system (GLSL3 support is required.)");
if (Shader::isDefaultActive() || !Shader::current) if (Shader::isDefaultActive() || !Shader::current)
throw love::Exception("drawShaderVertices can only be used with a custom shader."); throw love::Exception("drawFromShader can only be used with a custom shader.");
if (vertexcount < 0 || instancecount < 0) if (vertexcount < 0 || instancecount < 0)
throw love::Exception("drawShaderVertices vertex and instance count parameters must not be negative."); throw love::Exception("drawFromShader vertex and instance count parameters must not be negative.");
Shader::current->validateDrawState(primtype, maintexture); Shader::current->validateDrawState(primtype, maintexture);
@@ -1858,27 +1858,27 @@ void Graphics::drawShaderVertices(PrimitiveType primtype, int vertexcount, int i
draw(cmd); draw(cmd);
} }
void Graphics::drawShaderVertices(Buffer *indexbuffer, int indexcount, int instancecount, int startindex, Texture *maintexture) void Graphics::drawFromShader(Buffer *indexbuffer, int indexcount, int instancecount, int startindex, Texture *maintexture)
{ {
flushBatchedDraws(); flushBatchedDraws();
if (!capabilities.features[FEATURE_GLSL3]) if (!capabilities.features[FEATURE_GLSL3])
throw love::Exception("drawShaderVertices is not supported on this system (GLSL3 support is required.)"); throw love::Exception("drawFromShader is not supported on this system (GLSL3 support is required.)");
if (!(indexbuffer->getUsageFlags() & BUFFERUSAGEFLAG_INDEX)) if (!(indexbuffer->getUsageFlags() & BUFFERUSAGEFLAG_INDEX))
throw love::Exception("The buffer passed to drawShaderVertices must be an index buffer."); throw love::Exception("The buffer passed to drawFromShader must be an index buffer.");
if (startindex < 0) if (startindex < 0)
throw love::Exception("drawShaderVertices startindex parameter must not be negative."); throw love::Exception("drawFromShader startindex parameter must not be negative.");
if (indexcount < 0 || instancecount < 0) if (indexcount < 0 || instancecount < 0)
throw love::Exception("drawShaderVertices index and instance count parameters must not be negative."); throw love::Exception("drawFromShader index and instance count parameters must not be negative.");
if ((size_t)(startindex + indexcount) > indexbuffer->getArrayLength() * indexbuffer->getDataMembers().size()) if ((size_t)(startindex + indexcount) > indexbuffer->getArrayLength() * indexbuffer->getDataMembers().size())
throw love::Exception("drawShaderVertices startindex and index count parameters do not fit in the given index buffer."); throw love::Exception("drawFromShader startindex and index count parameters do not fit in the given index buffer.");
if (Shader::isDefaultActive() || !Shader::current) if (Shader::isDefaultActive() || !Shader::current)
throw love::Exception("drawShaderVertices can only be used with a custom shader."); throw love::Exception("drawFromShader can only be used with a custom shader.");
Shader::current->validateDrawState(PRIMITIVE_TRIANGLES, maintexture); Shader::current->validateDrawState(PRIMITIVE_TRIANGLES, maintexture);
+2 -2
View File
@@ -697,8 +697,8 @@ public:
void drawLayer(Texture *texture, int layer, Quad *quad, const Matrix4 &m); void drawLayer(Texture *texture, int layer, Quad *quad, const Matrix4 &m);
void drawInstanced(Mesh *mesh, const Matrix4 &m, int instancecount); void drawInstanced(Mesh *mesh, const Matrix4 &m, int instancecount);
void drawShaderVertices(PrimitiveType primtype, int vertexcount, int instancecount, Texture *maintexture); void drawFromShader(PrimitiveType primtype, int vertexcount, int instancecount, Texture *maintexture);
void drawShaderVertices(Buffer *indexbuffer, int indexcount, int instancecount, int startindex, Texture *maintexture); void drawFromShader(Buffer *indexbuffer, int indexcount, int instancecount, int startindex, Texture *maintexture);
/** /**
* Draws text at the specified coordinates * Draws text at the specified coordinates
+4 -4
View File
@@ -3099,7 +3099,7 @@ int w_drawInstanced(lua_State *L)
return 0; return 0;
} }
int w_drawShaderVertices(lua_State *L) int w_drawFromShader(lua_State *L)
{ {
if (luax_istype(L, 1, Buffer::type)) if (luax_istype(L, 1, Buffer::type))
{ {
@@ -3114,7 +3114,7 @@ int w_drawShaderVertices(lua_State *L)
if (!lua_isnoneornil(L, 5)) if (!lua_isnoneornil(L, 5))
tex = luax_checktexture(L, 5); tex = luax_checktexture(L, 5);
luax_catchexcept(L, [&]() { instance()->drawShaderVertices(t, indexcount, instancecount, indexstart, tex); }); luax_catchexcept(L, [&]() { instance()->drawFromShader(t, indexcount, instancecount, indexstart, tex); });
} }
else else
{ {
@@ -3130,7 +3130,7 @@ int w_drawShaderVertices(lua_State *L)
if (!lua_isnoneornil(L, 4)) if (!lua_isnoneornil(L, 4))
tex = luax_checktexture(L, 4); tex = luax_checktexture(L, 4);
luax_catchexcept(L, [&]() { instance()->drawShaderVertices(primtype, vertexcount, instancecount, tex); }); luax_catchexcept(L, [&]() { instance()->drawFromShader(primtype, vertexcount, instancecount, tex); });
} }
return 0; return 0;
} }
@@ -3844,7 +3844,7 @@ static const luaL_Reg functions[] =
{ "draw", w_draw }, { "draw", w_draw },
{ "drawLayer", w_drawLayer }, { "drawLayer", w_drawLayer },
{ "drawInstanced", w_drawInstanced }, { "drawInstanced", w_drawInstanced },
{ "drawShaderVertices", w_drawShaderVertices }, { "drawFromShader", w_drawFromShader },
{ "print", w_print }, { "print", w_print },
{ "printf", w_printf }, { "printf", w_printf },