diff options
author | chai <chaifix@163.com> | 2019-05-11 12:08:45 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-05-11 12:08:45 +0800 |
commit | f6c0498c9728a286c13980ed3b60763d02e1b3a0 (patch) | |
tree | c07b283cb2183b320730cf3811b130eca3d90353 /source/modules/asura-core/graphics/gl.cpp | |
parent | 59a0e32991b5b714b6bdba504b6fbacdcd4b907a (diff) |
*misc
Diffstat (limited to 'source/modules/asura-core/graphics/gl.cpp')
-rw-r--r-- | source/modules/asura-core/graphics/gl.cpp | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/source/modules/asura-core/graphics/gl.cpp b/source/modules/asura-core/graphics/gl.cpp index 08c50c3..5e6f216 100644 --- a/source/modules/asura-core/graphics/gl.cpp +++ b/source/modules/asura-core/graphics/gl.cpp @@ -21,6 +21,7 @@ namespace AsuraEngine OpenGL gl; OpenGL::OpenGL() + : mUpdateMVPMatrix(true) { #if ASURA_DEBUG ASSERT(!_instantiated); @@ -137,36 +138,50 @@ namespace AsuraEngine void OpenGL::PushMatrix() { state.matrix[state.matrixMode].Push(); + + mUpdateMVPMatrix = true; } void OpenGL::PopMatrix() { state.matrix[state.matrixMode].Pop(); + + mUpdateMVPMatrix = true; } void OpenGL::LoadIdentity() { state.matrix[state.matrixMode].LoadIdentity(); + + mUpdateMVPMatrix = true; } void OpenGL::Rotate(float angle) { state.matrix[state.matrixMode].Rotate(angle); + + mUpdateMVPMatrix = true; } void OpenGL::Translate(float x, float y) { state.matrix[state.matrixMode].Translate(x, y); + + mUpdateMVPMatrix = true; } void OpenGL::Scale(float x, float y) { state.matrix[state.matrixMode].Scale(x, y); + + mUpdateMVPMatrix = true; } void OpenGL::Ortho(float l, float r, float b, float t, float n, float f) { state.matrix[state.matrixMode].Ortho(l, r, b, t, n, f); + + mUpdateMVPMatrix = true; } AEMath::Matrix44& OpenGL::GetMatrix(MatrixMode mode) @@ -176,9 +191,16 @@ namespace AsuraEngine AEMath::Matrix44 OpenGL::GetMVPMatrix() { - return state.matrix[MATRIX_MODE_MODEL].GetTop() - * state.matrix[MATRIX_MODE_MODEL].GetTop() - * state.matrix[MATRIX_MODE_MODEL].GetTop(); + if (mUpdateMVPMatrix) + { + Matrix44& m = state.matrix[MATRIX_MODE_MODEL].GetTop(); + Matrix44& v = state.matrix[MATRIX_MODE_VIEW].GetTop(); + Matrix44& p = state.matrix[MATRIX_MODE_PROJECTION].GetTop(); + state.mvpMatrix = p * (v * m); + + mUpdateMVPMatrix = false; + } + return state.mvpMatrix; } uint OpenGL::GetMatrixDepth() |