Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Erwin <significant.bit@gmail.com>2017-03-22 22:52:48 +0300
committerMike Erwin <significant.bit@gmail.com>2017-03-22 22:52:48 +0300
commit4646ecf74917d5cee0a4f0d330a1306acd086a61 (patch)
treeae65b9d853962440c87ccbb10227434c9b27b502 /source/blender/gpu/intern/gpu_matrix.c
parent98a0dd6888b74de132fa936e15f5d589042e8f91 (diff)
OpenGL: use new API for persp & ortho projection
Still using legacy GL within the GPU library itself, but we'll be able to switch soon. Part of T49450
Diffstat (limited to 'source/blender/gpu/intern/gpu_matrix.c')
-rw-r--r--source/blender/gpu/intern/gpu_matrix.c60
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);