diff options
Diffstat (limited to 'source/blender/gpu/intern/gpu_matrix.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_matrix.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/source/blender/gpu/intern/gpu_matrix.c b/source/blender/gpu/intern/gpu_matrix.c index eecb87a74c0..5f6c1ed279b 100644 --- a/source/blender/gpu/intern/gpu_matrix.c +++ b/source/blender/gpu/intern/gpu_matrix.c @@ -578,6 +578,26 @@ static void mat4_look_from_origin(float m[4][4], float lookdir[3], float camup[3 void gpuOrtho(float left, float right, float bottom, float top, float near, float far) { +#if SUPPORT_LEGACY_MATRIX + if (state.mode == MATRIX_MODE_INACTIVE) { + GLenum mode; + glGetIntegerv(GL_MATRIX_MODE, (GLint*)&mode); + if (mode != GL_PROJECTION) { + glMatrixMode(GL_PROJECTION); + } + + glLoadIdentity(); + glOrtho(left, right, bottom, top, near, far); + + if (mode != GL_PROJECTION_MATRIX) { + glMatrixMode(mode); /* restore */ + } + + state.dirty = true; + return; + } +#endif + BLI_assert(state.mode == MATRIX_MODE_3D); mat4_ortho_set(Projection3D, left, right, bottom, top, near, far); CHECKMAT(Projection3D); @@ -586,6 +606,26 @@ void gpuOrtho(float left, float right, float bottom, float top, float near, floa void gpuOrtho2D(float left, float right, float bottom, float top) { +#if SUPPORT_LEGACY_MATRIX + if (state.mode == MATRIX_MODE_INACTIVE) { + GLenum mode; + glGetIntegerv(GL_MATRIX_MODE, (GLint*)&mode); + if (mode != GL_PROJECTION) { + glMatrixMode(GL_PROJECTION); + } + + glLoadIdentity(); + glOrtho(left, right, bottom, top, -1.0f, 1.0f); + + if (mode != GL_PROJECTION_MATRIX) { + glMatrixMode(mode); /* restore */ + } + + state.dirty = true; + return; + } +#endif + /* TODO: this function, but correct */ BLI_assert(state.mode == MATRIX_MODE_2D); Mat4 m; @@ -597,6 +637,26 @@ void gpuOrtho2D(float left, float right, float bottom, float top) void gpuFrustum(float left, float right, float bottom, float top, float near, float far) { +#if SUPPORT_LEGACY_MATRIX + if (state.mode == MATRIX_MODE_INACTIVE) { + GLenum mode; + glGetIntegerv(GL_MATRIX_MODE, (GLint*)&mode); + if (mode != GL_PROJECTION) { + glMatrixMode(GL_PROJECTION); + } + + glLoadIdentity(); + glFrustum(left, right, bottom, top, near, far); + + if (mode != GL_PROJECTION_MATRIX) { + glMatrixMode(mode); /* restore */ + } + + state.dirty = true; + return; + } +#endif + BLI_assert(state.mode == MATRIX_MODE_3D); mat4_frustum_set(Projection3D, left, right, bottom, top, near, far); CHECKMAT(Projection3D); |