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:13:10 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2017-04-19 16:22:58 +0300
commitba4d23fe37ee626c92c61bf0f78f64dcc2d95114 (patch)
tree68e34d845b87dbaa19b24dd04952aa71068ca16c /source/blender/gpu/intern/gpu_matrix.c
parent781108cdc6095f126ad0c77411d39acb52f11aa0 (diff)
Fix node editor drawing when built with core profile
There are two major things in this commit. First one is to have proper stack for projection matrices. This is something what OpenGL specification grants to have at least 2 elements for and what is required to have for proper editor drawing without refactoring the way how we restore projection matrix. Supporting this stack have following advantages: - Our GPU stack is closer to OpenGL specs, making it easier to follow by other developers who are always familiar with OpenGL. - Makes it easier to port all editors to a new API. - Should help us getting rid of extra matrix push/pop added in various commits to 2.8 branch. The new API follows the following convention: - gpuPushMatrix/gpuPopMatrix ALWAYS deals with model view matrix and nothing more. While this name does not fully indicate that it's only model view matrix operator, it matches behavior of other matrix operations such as transform which also doesn't indicate what matrix type they are operating on. - Projection matrix has dedicated calls for push/pop which are gpuPushProjectionMatrix/gpuPopProjectionMatrix.
Diffstat (limited to 'source/blender/gpu/intern/gpu_matrix.c')
-rw-r--r--source/blender/gpu/intern/gpu_matrix.c66
1 files changed, 51 insertions, 15 deletions
diff --git a/source/blender/gpu/intern/gpu_matrix.c b/source/blender/gpu/intern/gpu_matrix.c
index d958b012fa2..deb920c2582 100644
--- a/source/blender/gpu/intern/gpu_matrix.c
+++ b/source/blender/gpu/intern/gpu_matrix.c
@@ -44,11 +44,14 @@
typedef float Mat4[4][4];
typedef float Mat3[3][3];
-typedef struct {
- Mat4 ModelViewStack[MATRIX_STACK_DEPTH];
- Mat4 ProjectionMatrix;
+typedef struct MatrixStack {
+ Mat4 stack[MATRIX_STACK_DEPTH];
+ unsigned int top;
+} MatrixStack;
- unsigned top; /* of ModelView stack */
+typedef struct {
+ MatrixStack model_view_stack;
+ MatrixStack projection_stack;
bool dirty;
@@ -66,20 +69,23 @@ typedef struct {
{0.0f, 0.0f, 0.0f, 1.0f}}
static MatrixState state = {
- .ModelViewStack = {MATRIX_4X4_IDENTITY},
- .ProjectionMatrix = MATRIX_4X4_IDENTITY,
- .top = 0,
+ .model_view_stack = {{MATRIX_4X4_IDENTITY}, 0},
+ .projection_stack = {{MATRIX_4X4_IDENTITY}, 0},
.dirty = true
};
#undef MATRIX_4X4_IDENTITY
-#define ModelView state.ModelViewStack[state.top]
-#define Projection state.ProjectionMatrix
+#define ModelViewStack state.model_view_stack
+#define ModelView ModelViewStack.stack[ModelViewStack.top]
+
+#define ProjectionStack state.projection_stack
+#define Projection ProjectionStack.stack[ProjectionStack.top]
void gpuMatrixReset(void)
{
- state.top = 0;
+ state.model_view_stack.top = 0;
+ state.projection_stack.top = 0;
unit_m4(ModelView);
unit_m4(Projection);
state.dirty = true;
@@ -119,9 +125,9 @@ void gpuPushMatrix(void)
}
#endif
- BLI_assert(state.top < MATRIX_STACK_DEPTH);
- state.top++;
- copy_m4_m4(ModelView, state.ModelViewStack[state.top - 1]);
+ BLI_assert(ModelViewStack.top < MATRIX_STACK_DEPTH);
+ ModelViewStack.top++;
+ copy_m4_m4(ModelView, ModelViewStack.stack[ModelViewStack.top - 1]);
}
void gpuPopMatrix(void)
@@ -134,8 +140,38 @@ void gpuPopMatrix(void)
}
#endif
- BLI_assert(state.top > 0);
- state.top--;
+ BLI_assert(ModelViewStack.top > 0);
+ ModelViewStack.top--;
+ state.dirty = true;
+}
+
+void gpuPushProjectionMatrix(void)
+{
+#if SUPPORT_LEGACY_MATRIX
+ {
+ glPushMatrix();
+ state.dirty = true;
+ return;
+ }
+#endif
+
+ BLI_assert(ProjectionStack.top < MATRIX_STACK_DEPTH);
+ ProjectionStack.top++;
+ copy_m4_m4(Projection, ProjectionStack.stack[ProjectionStack.top - 1]);
+}
+
+void gpuPopProjectionMatrix(void)
+{
+#if SUPPORT_LEGACY_MATRIX
+ {
+ glPopMatrix();
+ state.dirty = true;
+ return;
+ }
+#endif
+
+ BLI_assert(ProjectionStack.top > 0);
+ ProjectionStack.top--;
state.dirty = true;
}