aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Graphics/je_gl.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-11-16 21:29:52 +0800
committerchai <chaifix@163.com>2018-11-16 21:29:52 +0800
commita4db0e0622a3764d090a8c2ecf8bd5b56442ccef (patch)
tree7073a0bfb5dd7f83162fc62eb67d3c5a6168cf9e /src/libjin/Graphics/je_gl.cpp
parent0056e468d9c3291443d87bfc05441e375a315433 (diff)
*更新渲染minimal
Diffstat (limited to 'src/libjin/Graphics/je_gl.cpp')
-rw-r--r--src/libjin/Graphics/je_gl.cpp56
1 files changed, 33 insertions, 23 deletions
diff --git a/src/libjin/Graphics/je_gl.cpp b/src/libjin/Graphics/je_gl.cpp
index a559c07..f098f97 100644
--- a/src/libjin/Graphics/je_gl.cpp
+++ b/src/libjin/Graphics/je_gl.cpp
@@ -14,7 +14,7 @@ namespace JinEngine
OpenGL::OpenGL()
: ogl2d::OpenGL()
{
- mMatrices.push_back(Matrix());
+ mModelViewMatrices.push_back(Matrix());
solve();
}
@@ -36,68 +36,78 @@ namespace JinEngine
void OpenGL::clearMatrix()
{
- mMatrices.clear();
- mMatrices.push_back(Matrix());
- mMatrix.setIdentity();
+ mModelViewMatrices.clear();
+ mModelViewMatrices.push_back(Matrix());
+ mModelViewMatrix.setIdentity();
}
void OpenGL::push()
{
- mMatrices.push_back(Matrix());
+ mModelViewMatrices.push_back(Matrix());
}
void OpenGL::pop()
{
- if (mMatrices.size() == 1)
+ if (mModelViewMatrices.size() == 1)
return;
- mMatrices.pop_back();
+ mModelViewMatrices.pop_back();
solve();
}
void OpenGL::solve()
{
- mMatrix.setIdentity();
- for (Matrix& m : mMatrices)
- mMatrix *= m;
+ mModelViewMatrix.setIdentity();
+ for (Matrix& m : mModelViewMatrices)
+ mModelViewMatrix *= m;
}
void OpenGL::translate(float x, float y)
{
- if (mMatrices.size() == 1)
+ if (mModelViewMatrices.size() == 1)
return;
- Matrix& m = mMatrices.back();
+ Matrix& m = mModelViewMatrices.back();
m.translate(x, y);
- mMatrix.translate(x, y);
+ mModelViewMatrix.translate(x, y);
}
void OpenGL::scale(float sx, float sy)
{
- if (mMatrices.size() == 1)
+ if (mModelViewMatrices.size() == 1)
return;
- Matrix& m = mMatrices.back();
+ Matrix& m = mModelViewMatrices.back();
m.scale(sx, sy);
- mMatrix.scale(sx, sy);
+ mModelViewMatrix.scale(sx, sy);
}
void OpenGL::rotate(float r)
{
- if (mMatrices.size() == 1)
+ if (mModelViewMatrices.size() == 1)
return;
- Matrix& m = mMatrices.back();
+ Matrix& m = mModelViewMatrices.back();
m.rotate(r);
- mMatrix.rotate(r);
+ mModelViewMatrix.rotate(r);
}
- Matrix OpenGL::getModelMatrix(float x, float y, float sx, float sy, float r, float ox, float oy)
+ Matrix OpenGL::getModelViewMatrix(float x, float y, float sx, float sy, float r, float ox, float oy)
{
Matrix m;
m.setTransformation(x, y, sx, sy, r, ox, oy);
- return mMatrix*m;
+ return mModelViewMatrix*m;
}
- Math::Matrix OpenGL::getModelMatrix()
+ Matrix OpenGL::getModelViewMatrix()
{
- return mMatrix;
+ return mModelViewMatrix;
+ }
+
+ const Matrix& OpenGL::getProjectionMatrix()
+ {
+ return mProjectionMatrix;
+ }
+
+ void OpenGL::setProjectionMatrix(float l, float r, float b, float t, float n, float f)
+ {
+ mProjectionMatrix.setOrtho(l, r, b, t, n, f);
}
} // namespace Graphics