mirror of
https://github.com/love2d/love.git
synced 2026-08-17 02:58:31 +02:00
Renamed the internal 'Matrix' class to 'Matrix4'.
This commit is contained in:
@@ -298,7 +298,7 @@ void Canvas::unloadVolatile()
|
||||
texture_memory = 0;
|
||||
}
|
||||
|
||||
void Canvas::drawv(const Matrix &t, const Vertex *v)
|
||||
void Canvas::drawv(const Matrix4 &t, const Vertex *v)
|
||||
{
|
||||
OpenGL::TempDebugGroup debuggroup("Canvas draw");
|
||||
|
||||
@@ -318,14 +318,14 @@ void Canvas::drawv(const Matrix &t, const Vertex *v)
|
||||
|
||||
void Canvas::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
|
||||
{
|
||||
Matrix t(x, y, angle, sx, sy, ox, oy, kx, ky);
|
||||
Matrix4 t(x, y, angle, sx, sy, ox, oy, kx, ky);
|
||||
|
||||
drawv(t, vertices);
|
||||
}
|
||||
|
||||
void Canvas::drawq(Quad *quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
|
||||
{
|
||||
Matrix t(x, y, angle, sx, sy, ox, oy, kx, ky);
|
||||
Matrix4 t(x, y, angle, sx, sy, ox, oy, kx, ky);
|
||||
|
||||
const Vertex *v = quad->getVertices();
|
||||
drawv(t, v);
|
||||
@@ -390,7 +390,7 @@ void Canvas::setupGrab()
|
||||
gl.setViewport({0, 0, width, height});
|
||||
|
||||
// Set up the projection matrix
|
||||
gl.matrices.projection.push_back(Matrix::ortho(0.0, (float) width, 0.0, (float) height));
|
||||
gl.matrices.projection.push_back(Matrix4::ortho(0.0, (float) width, 0.0, (float) height));
|
||||
}
|
||||
|
||||
void Canvas::startGrab(const std::vector<Canvas *> &canvases)
|
||||
|
||||
@@ -142,7 +142,7 @@ private:
|
||||
bool createMSAAFBO(GLenum internalformat);
|
||||
bool resolveMSAA(bool restoreprev);
|
||||
|
||||
void drawv(const Matrix &t, const Vertex *v);
|
||||
void drawv(const Matrix4 &t, const Vertex *v);
|
||||
|
||||
static Format getSizedFormat(Format format);
|
||||
static void convertFormat(Format format, GLenum &internalformat, GLenum &externalformat, GLenum &type);
|
||||
|
||||
@@ -554,7 +554,7 @@ void Font::drawVertices(const std::vector<DrawCommand> &drawcommands)
|
||||
}
|
||||
}
|
||||
|
||||
void Font::printv(const Matrix &t, const std::vector<DrawCommand> &drawcommands, const std::vector<GlyphVertex> &vertices)
|
||||
void Font::printv(const Matrix4 &t, const std::vector<DrawCommand> &drawcommands, const std::vector<GlyphVertex> &vertices)
|
||||
{
|
||||
if (vertices.empty() || drawcommands.empty())
|
||||
return;
|
||||
@@ -577,7 +577,7 @@ void Font::print(const std::string &text, float x, float y, float angle, float s
|
||||
std::vector<GlyphVertex> vertices;
|
||||
std::vector<DrawCommand> drawcommands = generateVertices(text, vertices);
|
||||
|
||||
Matrix t(ceilf(x), ceilf(y), angle, sx, sy, ox, oy, kx, ky);
|
||||
Matrix4 t(ceilf(x), ceilf(y), angle, sx, sy, ox, oy, kx, ky);
|
||||
|
||||
printv(t, drawcommands, vertices);
|
||||
}
|
||||
@@ -587,7 +587,7 @@ void Font::printf(const std::string &text, float x, float y, float wrap, AlignMo
|
||||
std::vector<GlyphVertex> vertices;
|
||||
std::vector<DrawCommand> drawcommands = generateVerticesFormatted(text, wrap, align, vertices);
|
||||
|
||||
Matrix t(ceilf(x), ceilf(y), angle, sx, sy, ox, oy, kx, ky);
|
||||
Matrix4 t(ceilf(x), ceilf(y), angle, sx, sy, ox, oy, kx, ky);
|
||||
|
||||
printv(t, drawcommands, vertices);
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ private:
|
||||
love::font::GlyphData *getRasterizerGlyphData(uint32 glyph);
|
||||
const Glyph &addGlyph(uint32 glyph);
|
||||
const Glyph &findGlyph(uint32 glyph);
|
||||
void printv(const Matrix &t, const std::vector<DrawCommand> &drawcommands, const std::vector<GlyphVertex> &vertices);
|
||||
void printv(const Matrix4 &t, const std::vector<DrawCommand> &drawcommands, const std::vector<GlyphVertex> &vertices);
|
||||
|
||||
std::vector<StrongRef<love::font::Rasterizer>> rasterizers;
|
||||
|
||||
|
||||
@@ -230,7 +230,7 @@ void Graphics::setViewportSize(int width, int height)
|
||||
Canvas::systemViewport = gl.getViewport();
|
||||
|
||||
// Set up the projection matrix
|
||||
gl.matrices.projection.back() = Matrix::ortho(0.0, (float) width, (float) height, 0.0);
|
||||
gl.matrices.projection.back() = Matrix4::ortho(0.0, (float) width, (float) height, 0.0);
|
||||
|
||||
// Restore the previously active Canvas.
|
||||
setCanvas(canvases);
|
||||
|
||||
@@ -351,7 +351,7 @@ bool Image::refresh(int xoffset, int yoffset, int w, int h)
|
||||
return true;
|
||||
}
|
||||
|
||||
void Image::drawv(const Matrix &t, const Vertex *v)
|
||||
void Image::drawv(const Matrix4 &t, const Vertex *v)
|
||||
{
|
||||
OpenGL::TempDebugGroup debuggroup("Image draw");
|
||||
|
||||
@@ -371,14 +371,14 @@ void Image::drawv(const Matrix &t, const Vertex *v)
|
||||
|
||||
void Image::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
|
||||
{
|
||||
Matrix t(x, y, angle, sx, sy, ox, oy, kx, ky);
|
||||
Matrix4 t(x, y, angle, sx, sy, ox, oy, kx, ky);
|
||||
|
||||
drawv(t, vertices);
|
||||
}
|
||||
|
||||
void Image::drawq(Quad *quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
|
||||
{
|
||||
Matrix t(x, y, angle, sx, sy, ox, oy, kx, ky);
|
||||
Matrix4 t(x, y, angle, sx, sy, ox, oy, kx, ky);
|
||||
|
||||
drawv(t, quad->getVertices());
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
void drawv(const Matrix &t, const Vertex *v);
|
||||
void drawv(const Matrix4 &t, const Vertex *v);
|
||||
|
||||
void preload();
|
||||
|
||||
|
||||
@@ -600,7 +600,7 @@ void Mesh::draw(float x, float y, float angle, float sx, float sy, float ox, flo
|
||||
else
|
||||
gl.bindTexture(gl.getDefaultTexture());
|
||||
|
||||
Matrix m(x, y, angle, sx, sy, ox, oy, kx, ky);
|
||||
Matrix4 m(x, y, angle, sx, sy, ox, oy, kx, ky);
|
||||
|
||||
OpenGL::TempTransform transform(gl);
|
||||
transform.get() *= m;
|
||||
|
||||
@@ -274,8 +274,8 @@ void OpenGL::initMatrices()
|
||||
matrices.transform.clear();
|
||||
matrices.projection.clear();
|
||||
|
||||
matrices.transform.push_back(Matrix());
|
||||
matrices.projection.push_back(Matrix());
|
||||
matrices.transform.push_back(Matrix4());
|
||||
matrices.projection.push_back(Matrix4());
|
||||
}
|
||||
|
||||
void OpenGL::createDefaultTexture()
|
||||
@@ -312,7 +312,7 @@ void OpenGL::popTransform()
|
||||
matrices.transform.pop_back();
|
||||
}
|
||||
|
||||
Matrix &OpenGL::getTransform()
|
||||
Matrix4 &OpenGL::getTransform()
|
||||
{
|
||||
return matrices.transform.back();
|
||||
}
|
||||
@@ -329,11 +329,11 @@ void OpenGL::prepareDraw()
|
||||
// because uniform uploads can be significantly slower than glLoadMatrix.
|
||||
if (GLAD_VERSION_1_0)
|
||||
{
|
||||
const Matrix &curproj = matrices.projection.back();
|
||||
const Matrix &curxform = matrices.transform.back();
|
||||
const Matrix4 &curproj = matrices.projection.back();
|
||||
const Matrix4 &curxform = matrices.transform.back();
|
||||
|
||||
const Matrix &lastproj = state.lastProjectionMatrix;
|
||||
const Matrix &lastxform = state.lastTransformMatrix;
|
||||
const Matrix4 &lastproj = state.lastProjectionMatrix;
|
||||
const Matrix4 &lastxform = state.lastTransformMatrix;
|
||||
|
||||
// We only need to re-upload the projection matrix if it's changed.
|
||||
if (memcmp(curproj.getElements(), lastproj.getElements(), sizeof(float) * 16) != 0)
|
||||
|
||||
@@ -111,8 +111,8 @@ public:
|
||||
|
||||
struct
|
||||
{
|
||||
std::vector<Matrix> transform;
|
||||
std::vector<Matrix> projection;
|
||||
std::vector<Matrix4> transform;
|
||||
std::vector<Matrix4> projection;
|
||||
} matrices;
|
||||
|
||||
class TempTransform
|
||||
@@ -130,7 +130,7 @@ public:
|
||||
gl.popTransform();
|
||||
}
|
||||
|
||||
Matrix &get()
|
||||
Matrix4 &get()
|
||||
{
|
||||
return gl.getTransform();
|
||||
}
|
||||
@@ -191,7 +191,7 @@ public:
|
||||
|
||||
void pushTransform();
|
||||
void popTransform();
|
||||
Matrix &getTransform();
|
||||
Matrix4 &getTransform();
|
||||
|
||||
/**
|
||||
* Set up necessary state (LOVE-provided shader uniforms, etc.) for drawing.
|
||||
@@ -382,8 +382,8 @@ private:
|
||||
|
||||
GLuint defaultTexture;
|
||||
|
||||
Matrix lastProjectionMatrix;
|
||||
Matrix lastTransformMatrix;
|
||||
Matrix4 lastProjectionMatrix;
|
||||
Matrix4 lastTransformMatrix;
|
||||
|
||||
} state;
|
||||
|
||||
|
||||
@@ -854,7 +854,7 @@ void ParticleSystem::draw(float x, float y, float angle, float sx, float sy, flo
|
||||
|
||||
OpenGL::TempDebugGroup debuggroup("ParticleSystem draw");
|
||||
|
||||
Matrix t(x, y, angle, sx, sy, ox, oy, kx, ky);
|
||||
Matrix4 t(x, y, angle, sx, sy, ox, oy, kx, ky);
|
||||
|
||||
OpenGL::TempTransform transform(gl);
|
||||
transform.get() *= t;
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace
|
||||
~TemporaryAttacher()
|
||||
{
|
||||
if (prevShader != nullptr)
|
||||
prevShader->attach(true);
|
||||
prevShader->attach();
|
||||
else
|
||||
curShader->detach();
|
||||
}
|
||||
@@ -702,8 +702,8 @@ void Shader::checkSetBuiltinUniforms()
|
||||
{
|
||||
checkSetPointSize(gl.getPointSize());
|
||||
|
||||
const Matrix &curxform = gl.matrices.transform.back();
|
||||
const Matrix &curproj = gl.matrices.projection.back();
|
||||
const Matrix4 &curxform = gl.matrices.transform.back();
|
||||
const Matrix4 &curproj = gl.matrices.projection.back();
|
||||
|
||||
TemporaryAttacher attacher(this);
|
||||
|
||||
@@ -735,7 +735,7 @@ void Shader::checkSetBuiltinUniforms()
|
||||
GLint location = builtinUniforms[BUILTIN_TRANSFORM_PROJECTION_MATRIX];
|
||||
if (location >= 0)
|
||||
{
|
||||
Matrix tp_matrix(curproj * curxform);
|
||||
Matrix4 tp_matrix(curproj * curxform);
|
||||
glUniformMatrix4fv(location, 1, GL_FALSE, tp_matrix.getElements());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,8 +259,8 @@ private:
|
||||
|
||||
float lastPointSize;
|
||||
|
||||
Matrix lastTransformMatrix;
|
||||
Matrix lastProjectionMatrix;
|
||||
Matrix4 lastTransformMatrix;
|
||||
Matrix4 lastProjectionMatrix;
|
||||
|
||||
// Counts total number of textures bound to each texture unit in all shaders
|
||||
static std::vector<int> textureCounters;
|
||||
|
||||
@@ -86,7 +86,7 @@ int SpriteBatch::add(float x, float y, float a, float sx, float sy, float ox, fl
|
||||
if ((index == -1 && next >= size) || index < -1 || index >= size)
|
||||
return -1;
|
||||
|
||||
Matrix t(x, y, a, sx, sy, ox, oy, kx, ky);
|
||||
Matrix4 t(x, y, a, sx, sy, ox, oy, kx, ky);
|
||||
|
||||
addv(texture->getVertices(), t, (index == -1) ? next : index);
|
||||
|
||||
@@ -103,7 +103,7 @@ int SpriteBatch::addq(Quad *quad, float x, float y, float a, float sx, float sy,
|
||||
if ((index == -1 && next >= size) || index < -1 || index >= next)
|
||||
return -1;
|
||||
|
||||
Matrix t(x, y, a, sx, sy, ox, oy, kx, ky);
|
||||
Matrix4 t(x, y, a, sx, sy, ox, oy, kx, ky);
|
||||
|
||||
addv(quad->getVertices(), t, (index == -1) ? next : index);
|
||||
|
||||
@@ -222,7 +222,7 @@ void SpriteBatch::draw(float x, float y, float angle, float sx, float sy, float
|
||||
|
||||
OpenGL::TempDebugGroup debuggroup("SpriteBatch draw");
|
||||
|
||||
Matrix t(x, y, angle, sx, sy, ox, oy, kx, ky);
|
||||
Matrix4 t(x, y, angle, sx, sy, ox, oy, kx, ky);
|
||||
|
||||
OpenGL::TempTransform transform(gl);
|
||||
transform.get() *= t;
|
||||
@@ -254,7 +254,7 @@ void SpriteBatch::draw(float x, float y, float angle, float sx, float sy, float
|
||||
gl.drawElements(GL_TRIANGLES, (GLsizei) quad_indices.getIndexCount(next), quad_indices.getType(), quad_indices.getPointer(0));
|
||||
}
|
||||
|
||||
void SpriteBatch::addv(const Vertex *v, const Matrix &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]};
|
||||
|
||||
@@ -103,7 +103,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
void addv(const Vertex *v, const Matrix &m, int index);
|
||||
void addv(const Vertex *v, const Matrix4 &m, int index);
|
||||
|
||||
/**
|
||||
* Set the color for vertices.
|
||||
|
||||
@@ -170,7 +170,7 @@ void Text::set(const std::string &text)
|
||||
if (text.empty())
|
||||
return set();
|
||||
|
||||
addTextData({text, -1.0f, Font::ALIGN_MAX_ENUM, false, false, Matrix()});
|
||||
addTextData({text, -1.0f, Font::ALIGN_MAX_ENUM, false, false, Matrix4()});
|
||||
}
|
||||
|
||||
void Text::set(const std::string &text, float wrap, Font::AlignMode align)
|
||||
@@ -178,7 +178,7 @@ void Text::set(const std::string &text, float wrap, Font::AlignMode align)
|
||||
if (text.empty())
|
||||
return set();
|
||||
|
||||
addTextData({text, wrap, align, false, false, Matrix()});
|
||||
addTextData({text, wrap, align, false, false, Matrix4()});
|
||||
}
|
||||
|
||||
void Text::set()
|
||||
@@ -191,8 +191,7 @@ void Text::add(const std::string &text, float x, float y, float angle, float sx,
|
||||
if (text.empty())
|
||||
return;
|
||||
|
||||
Matrix m;
|
||||
m.setTransformation(x, y, angle, sx, sy, ox, oy, kx, ky);
|
||||
Matrix4 m(x, y, angle, sx, sy, ox, oy, kx, ky);
|
||||
|
||||
addTextData({text, -1.0f, Font::ALIGN_MAX_ENUM, true, true, m});
|
||||
}
|
||||
@@ -202,8 +201,7 @@ void Text::addf(const std::string &text, float wrap, Font::AlignMode align, floa
|
||||
if (text.empty())
|
||||
return;
|
||||
|
||||
Matrix m;
|
||||
m.setTransformation(x, y, angle, sx, sy, ox, oy, kx, ky);
|
||||
Matrix4 m(x, y, angle, sx, sy, ox, oy, kx, ky);
|
||||
|
||||
addTextData({text, wrap, align, true, true, m});
|
||||
}
|
||||
@@ -232,7 +230,7 @@ void Text::draw(float x, float y, float angle, float sx, float sy, float ox, flo
|
||||
const size_t tex_offset = offsetof(Font::GlyphVertex, s);
|
||||
const size_t stride = sizeof(Font::GlyphVertex);
|
||||
|
||||
Matrix t(ceilf(x), ceilf(y), angle, sx, sy, ox, oy, kx, ky);
|
||||
Matrix4 t(ceilf(x), ceilf(y), angle, sx, sy, ox, oy, kx, ky);
|
||||
|
||||
OpenGL::TempTransform transform(gl);
|
||||
transform.get() *= t;
|
||||
|
||||
@@ -74,7 +74,7 @@ private:
|
||||
Font::AlignMode align;
|
||||
bool use_matrix;
|
||||
bool append_vertices;
|
||||
Matrix matrix;
|
||||
Matrix4 matrix;
|
||||
};
|
||||
|
||||
void uploadVertices(const std::vector<Font::GlyphVertex> &vertices, size_t vertoffset);
|
||||
|
||||
Reference in New Issue
Block a user