diff options
Diffstat (limited to 'src/libjin/Graphics/je_graphic.cpp')
-rw-r--r-- | src/libjin/Graphics/je_graphic.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/libjin/Graphics/je_graphic.cpp b/src/libjin/Graphics/je_graphic.cpp index 0bb3fe1..552eac6 100644 --- a/src/libjin/Graphics/je_graphic.cpp +++ b/src/libjin/Graphics/je_graphic.cpp @@ -4,10 +4,12 @@ #include <stdlib.h> #include "../math/je_matrix.h" +#include "../math/je_vector2.hpp" #include "shaders/je_shader.h" #include "je_graphic.h" +using namespace JinEngine::Math; using namespace JinEngine::Graphics::Shaders; namespace JinEngine @@ -45,7 +47,7 @@ namespace JinEngine void Graphic::render(int x, int y, float sx, float sy, float r, float ox, float oy) const { - Math::Matrix modelMatrix = gl.getModelViewMatrix(x, y, r, sx, sy, ox, oy); + Math::Matrix modelMatrix = gl.getModelViewMatrix(x, y, sx, sy, r, ox, oy); int w = getWidth(), h = getHeight(); static float vertexCoords[8]; static float textureCoords[8]; @@ -91,7 +93,7 @@ namespace JinEngine textureCoords[4] = slx + slw; textureCoords[5] = sly + slh; textureCoords[6] = slx + slw; textureCoords[7] = sly; - Math::Matrix modelMatrix = gl.getModelViewMatrix(x, y, r, sx, sy, ax, ay); + Math::Matrix modelMatrix = gl.getModelViewMatrix(x, y, sx, sy, r, ax, ay); Shader* shader = Shader::getCurrentShader(); shader->sendMatrix4(SHADER_MODELVIEW_MATRIX, &modelMatrix); @@ -104,6 +106,24 @@ namespace JinEngine gl.bindTexture(0); } + void Graphic::render(const Math::Transform& transform) const + { + Vector2<float> position = transform.getPosition(); + Vector2<float> origin = transform.getOrigin(); + Vector2<float> scale = transform.getScale(); + float angle = transform.getRotation(); + render(position.x, position.y, scale.x, scale.y, angle, origin.x, origin.y); + } + + void Graphic::render(const Math::Quad& slice, const Math::Transform& transform) const + { + Vector2<float> position = transform.getPosition(); + Vector2<float> origin = transform.getOrigin(); + Vector2<float> scale = transform.getScale(); + float angle = transform.getRotation(); + render(slice, position.x, position.y, scale.x, scale.y, angle, origin.x, origin.y); + } + //void Graphic::setFilter(GLint min, GLint max) //{ // glTexParameteri(GL_) |