Simplify Drawable code

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2016-10-18 22:06:52 -03:00
parent a844c16657
commit b8b670e0ae
23 changed files with 93 additions and 159 deletions
+3 -12
View File
@@ -23,6 +23,7 @@
// LOVE
#include "common/Object.h"
#include "common/Matrix.h"
namespace love
{
@@ -43,19 +44,9 @@ public:
virtual ~Drawable() {}
/**
* Draws the object with the specified transformation.
*
* @param x The position of the object along the x-axis.
* @param y The position of the object along the y-axis.
* @param angle The angle of the object (in radians).
* @param sx The scale factor along the x-axis.
* @param sy The scale factor along the y-axis.
* @param ox The origin offset along the x-axis.
* @param oy The origin offset along the y-axis.
* @param kx Shear along the x-axis.
* @param ky Shear along the y-axis.
* Draws the object with the specified transformation matrix.
**/
virtual void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) = 0;
virtual void draw(const Matrix4 &m) = 0;
};
} // graphics
+1 -12
View File
@@ -76,19 +76,8 @@ public:
/**
* Draws the texture using the specified transformation with a Quad applied.
*
* @param quad The Quad object to use to draw the object.
* @param x The position of the object along the x-axis.
* @param y The position of the object along the y-axis.
* @param angle The angle of the object (in radians).
* @param sx The scale factor along the x-axis.
* @param sy The scale factor along the y-axis.
* @param ox The origin offset along the x-axis.
* @param oy The origin offset along the y-axis.
* @param kx Shear along the x-axis.
* @param ky Shear along the y-axis.
**/
virtual void drawq(Quad *quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) = 0;
virtual void drawq(Quad *quad, const Matrix4 &m) = 0;
virtual int getWidth() const;
virtual int getHeight() const;
+4 -8
View File
@@ -322,18 +322,14 @@ void Canvas::drawv(const Matrix4 &t, const Vertex *v)
gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
void Canvas::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
void Canvas::draw(const Matrix4 &m)
{
Matrix4 t(x, y, angle, sx, sy, ox, oy, kx, ky);
drawv(t, vertices);
drawv(m, vertices);
}
void Canvas::drawq(Quad *quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
void Canvas::drawq(Quad *quad, const Matrix4 &m)
{
Matrix4 t(x, y, angle, sx, sy, ox, oy, kx, ky);
drawv(t, quad->getVertices());
drawv(m, quad->getVertices());
}
void Canvas::setFilter(const Texture::Filter &f)
+7 -7
View File
@@ -70,17 +70,17 @@ public:
virtual ~Canvas();
// Implements Volatile.
virtual bool loadVolatile();
virtual void unloadVolatile();
bool loadVolatile() override;
void unloadVolatile() override;
// Implements Drawable.
virtual void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
void draw(const Matrix4 &m) override;
// Implements Texture.
virtual void drawq(Quad *quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
virtual void setFilter(const Texture::Filter &f);
virtual bool setWrap(const Texture::Wrap &w);
virtual const void *getHandle() const;
void drawq(Quad *quad, const Matrix4 &m) override;
void setFilter(const Texture::Filter &f) override;
bool setWrap(const Texture::Wrap &w) override;
const void *getHandle() const override;
/**
* @param canvases A list of other canvases to temporarily attach to this one,
+4 -8
View File
@@ -703,7 +703,7 @@ void Font::printv(const Matrix4 &t, const std::vector<DrawCommand> &drawcommands
drawVertices(drawcommands, false);
}
void Font::print(const std::vector<ColoredString> &text, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
void Font::print(const std::vector<ColoredString> &text, const Matrix4 &m)
{
ColoredCodepoints codepoints;
getCodepointsFromString(text, codepoints);
@@ -711,12 +711,10 @@ void Font::print(const std::vector<ColoredString> &text, float x, float y, float
std::vector<GlyphVertex> vertices;
std::vector<DrawCommand> drawcommands = generateVertices(codepoints, vertices);
Matrix4 t(x, y, angle, sx, sy, ox, oy, kx, ky);
printv(t, drawcommands, vertices);
printv(m, drawcommands, vertices);
}
void Font::printf(const std::vector<ColoredString> &text, float x, float y, float wrap, AlignMode align, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
void Font::printf(const std::vector<ColoredString> &text, float wrap, AlignMode align, const Matrix4 &m)
{
ColoredCodepoints codepoints;
getCodepointsFromString(text, codepoints);
@@ -724,9 +722,7 @@ void Font::printf(const std::vector<ColoredString> &text, float x, float y, floa
std::vector<GlyphVertex> vertices;
std::vector<DrawCommand> drawcommands = generateVerticesFormatted(codepoints, wrap, align, vertices);
Matrix4 t(x, y, angle, sx, sy, ox, oy, kx, ky);
printv(t, drawcommands, vertices);
printv(m, drawcommands, vertices);
}
int Font::getWidth(const std::string &str)
+3 -15
View File
@@ -115,22 +115,10 @@ public:
static void getCodepointsFromString(const std::vector<ColoredString> &strs, ColoredCodepoints &codepoints);
/**
* Prints the text at the designated position with rotation and scaling.
*
* @param text A string.
* @param x The x-coordinate.
* @param y The y-coordinate.
* @param angle The amount of rotation.
* @param sx Scale along the x axis.
* @param sy Scale along the y axis.
* @param ox The origin offset along the x-axis.
* @param oy The origin offset along the y-axis.
* @param kx Shear along the x axis.
* @param ky Shear along the y axis.
* Draws the text at the designated position with a transformation applied.
**/
void print(const std::vector<ColoredString> &text, float x, float y, float angle = 0.0f, float sx = 1.0f, float sy = 1.0f, float ox = 0.0f, float oy = 0.0f, float kx = 0.0f, float ky = 0.0f);
void printf(const std::vector<ColoredString> &text, float x, float y, float wrap, AlignMode align, float angle = 0.0f, float sx = 1.0f, float sy = 1.0f, float ox = 0.0f, float oy = 0.0f, float kx = 0.0f, float ky = 0.0f);
void print(const std::vector<ColoredString> &text, const Matrix4 &m);
void printf(const std::vector<ColoredString> &text, float wrap, AlignMode align, const Matrix4 &m);
/**
* Returns the height of the font.
+4 -4
View File
@@ -1258,24 +1258,24 @@ bool Graphics::isWireframe() const
return states.back().wireframe;
}
void Graphics::print(const std::vector<Font::ColoredString> &str, float x, float y , float angle, float sx, float sy, float ox, float oy, float kx, float ky)
void Graphics::print(const std::vector<Font::ColoredString> &str, const Matrix4 &m)
{
checkSetDefaultFont();
DisplayState &state = states.back();
if (state.font.get() != nullptr)
state.font->print(str, x, y, angle, sx, sy, ox, oy, kx, ky);
state.font->print(str, m);
}
void Graphics::printf(const std::vector<Font::ColoredString> &str, float x, float y, float wrap, Font::AlignMode align, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
void Graphics::printf(const std::vector<Font::ColoredString> &str, float wrap, Font::AlignMode align, const Matrix4 &m)
{
checkSetDefaultFont();
DisplayState &state = states.back();
if (state.font.get() != nullptr)
state.font->printf(str, x, y, wrap, align, angle, sx, sy, ox, oy, kx, ky);
state.font->printf(str, wrap, align, m);
}
/**
+4 -27
View File
@@ -331,37 +331,14 @@ public:
bool isWireframe() const;
/**
* Draws text at the specified coordinates, with rotation and
* scaling along both axes.
* @param x The x-coordinate.
* @param y The y-coordinate.
* @param angle The amount of rotation.
* @param sx The scale factor along the x-axis. (1 = normal).
* @param sy The scale factor along the y-axis. (1 = normal).
* @param ox The origin offset along the x-axis.
* @param oy The origin offset along the y-axis.
* @param kx Shear along the x-axis.
* @param ky Shear along the y-axis.
* Draws text at the specified coordinates
**/
void print(const std::vector<Font::ColoredString> &str, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
void print(const std::vector<Font::ColoredString> &str, const Matrix4 &m);
/**
* Draw formatted text on screen at the specified coordinates.
*
* @param str A string of text.
* @param x The x-coordinate.
* @param y The y-coordinate.
* @param wrap The maximum width of the text area.
* @param align Where to align the text.
* @param angle The amount of rotation.
* @param sx The scale factor along the x-axis. (1 = normal).
* @param sy The scale factor along the y-axis. (1 = normal).
* @param ox The origin offset along the x-axis.
* @param oy The origin offset along the y-axis.
* @param kx Shear along the x-axis.
* @param ky Shear along the y-axis.
* Draws formatted text on screen at the specified coordinates.
**/
void printf(const std::vector<Font::ColoredString> &str, float x, float y, float wrap, Font::AlignMode align, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
void printf(const std::vector<Font::ColoredString> &str, float wrap, Font::AlignMode align, const Matrix4 &m);
/**
* Draws a point at (x,y).
+4 -8
View File
@@ -460,18 +460,14 @@ void Image::drawv(const Matrix4 &t, const Vertex *v)
gl.drawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
void Image::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
void Image::draw(const Matrix4 &m)
{
Matrix4 t(x, y, angle, sx, sy, ox, oy, kx, ky);
drawv(t, vertices);
drawv(m, vertices);
}
void Image::drawq(Quad *quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
void Image::drawq(Quad *quad, const Matrix4 &m)
{
Matrix4 t(x, y, angle, sx, sy, ox, oy, kx, ky);
drawv(t, quad->getVertices());
drawv(m, quad->getVertices());
}
const void *Image::getHandle() const
+7 -7
View File
@@ -85,26 +85,26 @@ public:
virtual ~Image();
// Implements Volatile.
bool loadVolatile();
void unloadVolatile();
bool loadVolatile() override;
void unloadVolatile() override;
/**
* @copydoc Drawable::draw()
**/
void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
void draw(const Matrix4 &m) override;
/**
* @copydoc Texture::drawq()
**/
void drawq(Quad *quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
void drawq(Quad *quad, const Matrix4 &m) override;
virtual const void *getHandle() const;
const void *getHandle() const override;
const std::vector<StrongRef<love::image::ImageData>> &getImageData() const;
const std::vector<StrongRef<love::image::CompressedImageData>> &getCompressedData() const;
virtual void setFilter(const Texture::Filter &f);
virtual bool setWrap(const Texture::Wrap &w);
void setFilter(const Texture::Filter &f) override;
bool setWrap(const Texture::Wrap &w) override;
void setMipmapSharpness(float sharpness);
float getMipmapSharpness() const;
+1 -3
View File
@@ -574,7 +574,7 @@ int Mesh::bindAttributeToShaderInput(int attributeindex, const std::string &inpu
return attriblocation;
}
void Mesh::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
void Mesh::draw(const Matrix4 &m)
{
if (vertexCount <= 0)
return;
@@ -606,8 +606,6 @@ void Mesh::draw(float x, float y, float angle, float sx, float sy, float ox, flo
else
gl.bindTexture(gl.getDefaultTexture());
Matrix4 m(x, y, angle, sx, sy, ox, oy, kx, ky);
OpenGL::TempTransform transform(gl);
transform.get() *= m;
+1 -1
View File
@@ -197,7 +197,7 @@ public:
int bindAttributeToShaderInput(int attributeindex, const std::string &inputname);
// Implements Drawable.
void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) override;
void draw(const Matrix4 &m) override;
static GLenum getGLBufferUsage(Usage usage);
@@ -84,7 +84,7 @@ void ParticleSystem::setBufferSize(uint32 size)
createVertices(size);
}
void ParticleSystem::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
void ParticleSystem::draw(const Matrix4 &m)
{
uint32 pCount = getCount();
@@ -94,7 +94,7 @@ void ParticleSystem::draw(float x, float y, float angle, float sx, float sy, flo
OpenGL::TempDebugGroup debuggroup("ParticleSystem draw");
OpenGL::TempTransform transform(gl);
transform.get() *= Matrix4(x, y, angle, sx, sy, ox, oy, kx, ky);
transform.get() *= m;
const Vertex *textureVerts = texture->getVertices();
Vertex *pVerts = particleVerts;
+1 -1
View File
@@ -43,7 +43,7 @@ public:
ParticleSystem *clone() override;
void setBufferSize(uint32 size) override;
void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) override;
void draw(const Matrix4 &m) override;
private:
+7 -11
View File
@@ -66,7 +66,7 @@ SpriteBatch::~SpriteBatch()
delete array_buf;
}
int SpriteBatch::add(float x, float y, float a, float sx, float sy, float ox, float oy, float kx, float ky, int index /*= -1*/)
int SpriteBatch::add(const Matrix4 &m, int index /*= -1*/)
{
if (index < -1 || index >= size)
throw love::Exception("Invalid sprite index: %d", index + 1);
@@ -74,9 +74,7 @@ int SpriteBatch::add(float x, float y, float a, float sx, float sy, float ox, fl
if (index == -1 && next >= size)
setBufferSize(size * 2);
Matrix3 t(x, y, a, sx, sy, ox, oy, kx, ky);
addv(texture->getVertices(), t, (index == -1) ? next : index);
addv(texture->getVertices(), m, (index == -1) ? next : index);
// Increment counter.
if (index == -1)
@@ -85,7 +83,7 @@ int SpriteBatch::add(float x, float y, float a, float sx, float sy, float ox, fl
return index;
}
int SpriteBatch::addq(Quad *quad, float x, float y, float a, float sx, float sy, float ox, float oy, float kx, float ky, int index /*= -1*/)
int SpriteBatch::addq(Quad *quad, const Matrix4 &m, int index /*= -1*/)
{
if (index < -1 || index >= size)
throw love::Exception("Invalid sprite index: %d", index + 1);
@@ -93,9 +91,7 @@ int SpriteBatch::addq(Quad *quad, float x, float y, float a, float sx, float sy,
if (index == -1 && next >= size)
setBufferSize(size * 2);
Matrix3 t(x, y, a, sx, sy, ox, oy, kx, ky);
addv(quad->getVertices(), t, (index == -1) ? next : index);
addv(quad->getVertices(), m, (index == -1) ? next : index);
// Increment counter.
if (index == -1)
@@ -249,7 +245,7 @@ bool SpriteBatch::getDrawRange(int &start, int &count) const
return true;
}
void SpriteBatch::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
void SpriteBatch::draw(const Matrix4 &m)
{
const size_t pos_offset = offsetof(Vertex, x);
const size_t texel_offset = offsetof(Vertex, s);
@@ -261,7 +257,7 @@ void SpriteBatch::draw(float x, float y, float angle, float sx, float sy, float
OpenGL::TempDebugGroup debuggroup("SpriteBatch draw");
OpenGL::TempTransform transform(gl);
transform.get() *= Matrix4(x, y, angle, sx, sy, ox, oy, kx, ky);
transform.get() *= m;
gl.bindTexture(*(GLuint *) texture->getHandle());
@@ -320,7 +316,7 @@ void SpriteBatch::draw(float x, float y, float angle, float sx, float sy, float
gl.drawElements(GL_TRIANGLES, (GLsizei) quad_indices.getIndexCount(count), quad_indices.getType(), indices);
}
void SpriteBatch::addv(const Vertex *v, const Matrix3 &m, int index)
void SpriteBatch::addv(const Vertex *v, const Matrix4 &m, int index)
{
// Needed for colors.
Vertex sprite[4] = {v[0], v[1], v[2], v[3]};
+4 -4
View File
@@ -55,8 +55,8 @@ public:
SpriteBatch(Texture *texture, int size, Mesh::Usage usage);
virtual ~SpriteBatch();
int add(float x, float y, float a, float sx, float sy, float ox, float oy, float kx, float ky, int index = -1);
int addq(Quad *quad, float x, float y, float a, float sx, float sy, float ox, float oy, float kx, float ky, int index = -1);
int add(const Matrix4 &m, int index = -1);
int addq(Quad *quad, const Matrix4 &m, int index = -1);
void clear();
void flush();
@@ -106,7 +106,7 @@ public:
bool getDrawRange(int &start, int &count) const;
// Implements Drawable.
void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
void draw(const Matrix4 &m) override;
private:
@@ -122,7 +122,7 @@ private:
**/
void setBufferSize(int newsize);
void addv(const Vertex *v, const Matrix3 &m, int index);
void addv(const Vertex *v, const Matrix4 &m, int index);
/**
* Set the color for vertices.
+6 -8
View File
@@ -182,21 +182,19 @@ void Text::set(const std::vector<Font::ColoredString> &text, float wrap, Font::A
Font::ColoredCodepoints codepoints;
Font::getCodepointsFromString(text, codepoints);
addTextData({codepoints, wrap, align, {}, false, false, Matrix3()});
addTextData({codepoints, wrap, align, {}, false, false, Matrix4()});
}
int Text::add(const std::vector<Font::ColoredString> &text, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
int Text::add(const std::vector<Font::ColoredString> &text, const Matrix4 &m)
{
return addf(text, -1.0f, Font::ALIGN_MAX_ENUM, x, y, angle, sx, sy, ox, oy, kx, ky);
return addf(text, -1.0f, Font::ALIGN_MAX_ENUM, m);
}
int Text::addf(const std::vector<Font::ColoredString> &text, float wrap, Font::AlignMode align, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
int Text::addf(const std::vector<Font::ColoredString> &text, float wrap, Font::AlignMode align, const Matrix4 &m)
{
Font::ColoredCodepoints codepoints;
Font::getCodepointsFromString(text, codepoints);
Matrix3 m(x, y, angle, sx, sy, ox, oy, kx, ky);
addTextData({codepoints, wrap, align, {}, true, true, m});
return (int) text_data.size() - 1;
@@ -210,7 +208,7 @@ void Text::clear()
vert_offset = 0;
}
void Text::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
void Text::draw(const Matrix4 &m)
{
if (vbo == nullptr || draw_commands.empty())
return;
@@ -227,7 +225,7 @@ void Text::draw(float x, float y, float angle, float sx, float sy, float ox, flo
const size_t stride = sizeof(Font::GlyphVertex);
OpenGL::TempTransform transform(gl);
transform.get() *= Matrix4(x, y, angle, sx, sy, ox, oy, kx, ky);
transform.get() *= m;
{
GLBuffer::Bind bind(*vbo);
+5 -4
View File
@@ -44,12 +44,13 @@ public:
void set(const std::vector<Font::ColoredString> &text);
void set(const std::vector<Font::ColoredString> &text, float wrap, Font::AlignMode align);
int add(const std::vector<Font::ColoredString> &text, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
int addf(const std::vector<Font::ColoredString> &text, float wrap, Font::AlignMode align, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
int add(const std::vector<Font::ColoredString> &text, const Matrix4 &m);
int addf(const std::vector<Font::ColoredString> &text, float wrap, Font::AlignMode align, const Matrix4 &m);
void clear();
// Implements Drawable.
virtual void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
void draw(const Matrix4 &m) override;
void setFont(Font *f);
Font *getFont() const;
@@ -74,7 +75,7 @@ private:
Font::TextInfo text_info;
bool use_matrix;
bool append_vertices;
Matrix3 matrix;
Matrix4 matrix;
};
void uploadVertices(const std::vector<Font::GlyphVertex> &vertices, size_t vertoffset);
+2 -2
View File
@@ -114,7 +114,7 @@ love::video::VideoStream *Video::getStream()
return stream;
}
void Video::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
void Video::draw(const Matrix4 &m)
{
update();
@@ -130,7 +130,7 @@ void Video::draw(float x, float y, float angle, float sx, float sy, float ox, fl
shader->setVideoTextures(textures[0], textures[1], textures[2]);
OpenGL::TempTransform transform(gl);
transform.get() *= Matrix4(x, y, angle, sx, sy, ox, oy, kx, ky);
transform.get() *= m;
gl.useVertexAttribArrays(ATTRIBFLAG_POS | ATTRIBFLAG_TEXCOORD);
+5 -3
View File
@@ -44,11 +44,13 @@ public:
~Video();
// Volatile
bool loadVolatile();
void unloadVolatile();
bool loadVolatile() override;
void unloadVolatile() override;
// Drawable
void draw(const Matrix4 &m) override;
love::video::VideoStream *getStream();
void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky);
love::audio::Source *getSource();
void setSource(love::audio::Source *source);
+10 -8
View File
@@ -1551,11 +1551,13 @@ int w_draw(lua_State *L)
float kx = (float) luaL_optnumber(L, startidx + 7, 0.0);
float ky = (float) luaL_optnumber(L, startidx + 8, 0.0);
Matrix4 m(x, y, a, sx, sy, ox, oy, kx, ky);
luax_catchexcept(L, [&]() {
if (texture && quad)
texture->drawq(quad, x, y, a, sx, sy, ox, oy, kx, ky);
texture->drawq(quad, m);
else if (drawable)
drawable->draw(x, y, a, sx, sy, ox, oy, kx, ky);
drawable->draw(m);
});
return 0;
@@ -1576,9 +1578,9 @@ int w_print(lua_State *L)
float kx = (float)luaL_optnumber(L, 9, 0.0f);
float ky = (float)luaL_optnumber(L, 10, 0.0f);
luax_catchexcept(L,
[&](){ instance()->print(str, x, y, angle, sx, sy, ox, oy, kx,ky); }
);
Matrix4 m(x, y, angle, sx, sy, ox, oy, kx, ky);
luax_catchexcept(L, [&](){ instance()->print(str, m); });
return 0;
}
@@ -1616,9 +1618,9 @@ int w_printf(lua_State *L)
ky = (float) luaL_optnumber(L, 12, 0.0f);
}
luax_catchexcept(L,
[&](){ instance()->printf(str, x, y, wrap, align, angle, sx, sy, ox, oy, kx, ky); }
);
Matrix4 m(x, y, angle, sx, sy, ox, oy, kx, ky);
luax_catchexcept(L, [&](){ instance()->printf(str, wrap, align, m); });
return 0;
}
@@ -61,11 +61,13 @@ static inline int w_SpriteBatch_add_or_set(lua_State *L, SpriteBatch *t, int sta
float kx = (float) luaL_optnumber(L, startidx + 7, 0.0);
float ky = (float) luaL_optnumber(L, startidx + 8, 0.0);
Matrix4 m(x, y, a, sx, sy, ox, oy, kx, ky);
luax_catchexcept(L, [&]() {
if (quad)
index = t->addq(quad, x, y, a, sx, sy, ox, oy, kx, ky, index);
index = t->addq(quad, m, index);
else
index = t->add(x, y, a, sx, sy, ox, oy, kx, ky, index);
index = t->add(m, index);
});
return index;
+4 -2
View File
@@ -139,8 +139,9 @@ int w_Text_add(lua_State *L)
float kx = (float) luaL_optnumber(L, 10, 0.0);
float ky = (float) luaL_optnumber(L, 11, 0.0);
Matrix4 m(x, y, a, sx, sy, ox, oy, kx, ky);
int index = 0;
luax_catchexcept(L, [&](){ index = t->add(text, x, y, a, sx, sy, ox, oy, kx, ky); });
luax_catchexcept(L, [&](){ index = t->add(text, m); });
lua_pushnumber(L, index + 1);
return 1;
@@ -171,8 +172,9 @@ int w_Text_addf(lua_State *L)
float kx = (float) luaL_optnumber(L, 12, 0.0);
float ky = (float) luaL_optnumber(L, 13, 0.0);
Matrix4 m(x, y, a, sx, sy, ox, oy, kx, ky);
int index = 0;
luax_catchexcept(L, [&](){ index = t->addf(text, wrap, align, x, y, a, sx, sy, ox, oy, kx, ky); });
luax_catchexcept(L, [&](){ index = t->addf(text, wrap, align, m); });
lua_pushnumber(L, index + 1);
return 1;