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:
authorSergey Sharybin <sergey.vfx@gmail.com>2017-04-19 11:46:05 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2017-04-19 16:22:58 +0300
commit3f11be3f7de90517826cb114f648b06fc85b67d4 (patch)
tree3698f730600c6fe119df84c759376f5c2d4fc130 /source/blender/gpu/intern/gpu_matrix.c
parent288892bf08f380afdfe7f2f8f5b1ca2d2e037fe3 (diff)
Get rid of glMatrixMode calls
With the explicit calls we don't need to worry about current state outside of the GPU module now. In fact. we don't need to worry about current matrix mode in core profile at all. Legacy OpenGL now has some code which ensures current matrix mode when using explicit calls to push/pop matrix.
Diffstat (limited to 'source/blender/gpu/intern/gpu_matrix.c')
-rw-r--r--source/blender/gpu/intern/gpu_matrix.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/source/blender/gpu/intern/gpu_matrix.c b/source/blender/gpu/intern/gpu_matrix.c
index deb920c2582..8bf17653850 100644
--- a/source/blender/gpu/intern/gpu_matrix.c
+++ b/source/blender/gpu/intern/gpu_matrix.c
@@ -119,7 +119,18 @@ void gpuPushMatrix(void)
{
#if SUPPORT_LEGACY_MATRIX
{
+ GLenum mode;
+ glGetIntegerv(GL_MATRIX_MODE, (GLint*)&mode);
+ if (mode != GL_MODELVIEW) {
+ glMatrixMode(GL_MODELVIEW);
+ }
+
glPushMatrix();
+
+ if (mode != GL_MODELVIEW) {
+ glMatrixMode(mode); /* restore */
+ }
+
state.dirty = true;
return;
}
@@ -134,7 +145,18 @@ void gpuPopMatrix(void)
{
#if SUPPORT_LEGACY_MATRIX
{
+ GLenum mode;
+ glGetIntegerv(GL_MATRIX_MODE, (GLint*)&mode);
+ if (mode != GL_MODELVIEW) {
+ glMatrixMode(GL_MODELVIEW);
+ }
+
glPopMatrix();
+
+ if (mode != GL_MODELVIEW) {
+ glMatrixMode(mode); /* restore */
+ }
+
state.dirty = true;
return;
}
@@ -149,7 +171,18 @@ void gpuPushProjectionMatrix(void)
{
#if SUPPORT_LEGACY_MATRIX
{
+ GLenum mode;
+ glGetIntegerv(GL_MATRIX_MODE, (GLint*)&mode);
+ if (mode != GL_PROJECTION) {
+ glMatrixMode(GL_PROJECTION);
+ }
+
glPushMatrix();
+
+ if (mode != GL_PROJECTION) {
+ glMatrixMode(mode); /* restore */
+ }
+
state.dirty = true;
return;
}
@@ -164,7 +197,18 @@ void gpuPopProjectionMatrix(void)
{
#if SUPPORT_LEGACY_MATRIX
{
+ GLenum mode;
+ glGetIntegerv(GL_MATRIX_MODE, (GLint*)&mode);
+ if (mode != GL_PROJECTION) {
+ glMatrixMode(GL_PROJECTION);
+ }
+
glPopMatrix();
+
+ if (mode != GL_PROJECTION) {
+ glMatrixMode(mode); /* restore */
+ }
+
state.dirty = true;
return;
}
@@ -190,6 +234,32 @@ void gpuLoadMatrix(const float m[4][4])
state.dirty = true;
}
+void gpuLoadIdentityProjectionMatrix(void)
+{
+#if SUPPORT_LEGACY_MATRIX
+ {
+ GLenum mode;
+ glGetIntegerv(GL_MATRIX_MODE, (GLint*)&mode);
+ if (mode != GL_PROJECTION) {
+ glMatrixMode(GL_PROJECTION);
+ }
+
+ glLoadIdentity();
+
+ if (mode != GL_PROJECTION_MATRIX) {
+ glMatrixMode(mode); /* restore */
+ }
+
+ state.dirty = true;
+ return;
+ }
+#endif
+
+ unit_m4(Projection);
+ CHECKMAT(Projection3D);
+ state.dirty = true;
+}
+
void gpuLoadProjectionMatrix(const float m[4][4])
{
#if SUPPORT_LEGACY_MATRIX