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:
-rw-r--r--source/blender/draw/intern/draw_manager.c4
-rw-r--r--source/blender/draw/intern/draw_view.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c4
-rw-r--r--source/blender/gpu/GPU_matrix.h16
-rw-r--r--source/blender/gpu/intern/gpu_framebuffer.c5
-rw-r--r--source/blender/gpu/intern/gpu_matrix.c347
6 files changed, 78 insertions, 302 deletions
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index bdc57140e05..2f8bc59a781 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -1856,8 +1856,6 @@ void DRW_draw_view(const bContext *C)
/* Start Drawing */
DRW_engines_draw_background();
- gpuMatrixBegin3D();
-
DRW_draw_callbacks_pre_scene();
// DRW_draw_grid();
DRW_engines_draw_scene();
@@ -1865,8 +1863,6 @@ void DRW_draw_view(const bContext *C)
DRW_draw_manipulator();
- gpuMatrixEnd();
-
DRW_draw_region_info();
if (G.debug_value > 20) {
diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c
index 5fc7fe1d8f4..f5ddd05e915 100644
--- a/source/blender/draw/intern/draw_view.c
+++ b/source/blender/draw/intern/draw_view.c
@@ -554,8 +554,6 @@ void DRW_draw_background(void)
if (UI_GetThemeValue(TH_SHOW_BACK_GRAD)) {
/* Gradient background Color */
- gpuMatrixBegin3D(); /* TODO: finish 2D API */
-
glDisable(GL_DEPTH_TEST);
VertexFormat *format = immVertexFormat();
@@ -580,8 +578,6 @@ void DRW_draw_background(void)
immUnbindProgram();
- gpuMatrixEnd();
-
glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
}
else {
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 0d5e6440355..c9f70945866 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -2294,8 +2294,6 @@ static void view3d_draw_view(const bContext *C, ARegion *ar, DrawData *draw_data
glClear(GL_DEPTH_BUFFER_BIT);
// glDisable(GL_DEPTH_TEST); /* should be set by default */
- gpuMatrixBegin3D();
-
view3d_draw_background(C); /* clears/overwrites entire color buffer */
view3d_draw_setup_view(C, ar);
@@ -2318,8 +2316,6 @@ static void view3d_draw_view(const bContext *C, ARegion *ar, DrawData *draw_data
view3d_draw_reference_images(C);
view3d_draw_manipulators(C, ar);
- gpuMatrixEnd();
-
glDisable(GL_DEPTH_TEST);
view3d_draw_region_info(C, ar);
diff --git a/source/blender/gpu/GPU_matrix.h b/source/blender/gpu/GPU_matrix.h
index 62b5b7f8ba5..4a47f55a6c6 100644
--- a/source/blender/gpu/GPU_matrix.h
+++ b/source/blender/gpu/GPU_matrix.h
@@ -69,12 +69,6 @@ typedef enum {
MatrixMode gpuMatrixMode(void);
-void gpuMatrixBegin2D(void);
-void gpuMatrixBegin3D(void);
-void gpuMatrixEnd(void);
-/* TODO: gpuMatrixResume2D & gpuMatrixResume3D to switch modes but not reset stack */
-
-
/* ModelView Matrix (2D or 3D) */
void gpuPushMatrix(void); /* TODO: PushCopy vs PushIdentity? */
@@ -105,12 +99,7 @@ void gpuLookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY,
/* 2D ModelView Matrix */
-#if MATRIX_2D_4x4
void gpuMultMatrix2D(const float m[4][4]);
-#else
-void gpuLoadMatrix2D(const float m[3][3]);
-void gpuMultMatrix2D(const float m[3][3]);
-#endif
void gpuTranslate2f(float x, float y);
void gpuTranslate2fv(const float vec[2]);
@@ -187,12 +176,7 @@ bool gpuMatricesDirty(void); /* since last bind */
# define gpuLoadProjectionMatrix3D(x) gpuLoadProjectionMatrix3D((const float (*)[4])(x))
-# if MATRIX_2D_4x4
# define gpuMultMatrix2D(x) gpuMultMatrix2D((const float (*)[4])(x))
-# else
-# define gpuMultMatrix2D(x) gpuMultMatrix2D((const float (*)[3])(x))
-# define gpuLoadMatrix2D(x) gpuLoadMatrix2D((const float (*)[3])(x))
-# endif
# define gpuGetModelViewMatrix3D(x) gpuGetModelViewMatrix3D((float (*)[4])(x))
# define gpuGetProjectionMatrix3D(x) gpuGetProjectionMatrix3D((float (*)[4])(x))
diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c
index 5e66c691f37..fc6eb6baf51 100644
--- a/source/blender/gpu/intern/gpu_framebuffer.c
+++ b/source/blender/gpu/intern/gpu_framebuffer.c
@@ -415,9 +415,6 @@ void GPU_framebuffer_blur(
glDisable(GL_DEPTH_TEST);
- /* Load fresh matrices */
- gpuMatrixBegin3D(); /* TODO: finish 2D API */
-
/* Blurring horizontally */
/* We do the bind ourselves rather than using GPU_framebuffer_texture_bind() to avoid
* pushing unnecessary matrices onto the OpenGL stack. */
@@ -451,8 +448,6 @@ void GPU_framebuffer_blur(
Batch_Uniform2f(&batch, "ScaleU", scalev[0], scalev[1]);
Batch_Uniform1i(&batch, "textureSource", GL_TEXTURE0);
Batch_draw(&batch);
-
- gpuMatrixEnd();
}
void GPU_framebuffer_blit(GPUFrameBuffer *fb_read, int read_slot, GPUFrameBuffer *fb_write, int write_slot, bool use_depth)
diff --git a/source/blender/gpu/intern/gpu_matrix.c b/source/blender/gpu/intern/gpu_matrix.c
index 186e14e825f..8b58a981a65 100644
--- a/source/blender/gpu/intern/gpu_matrix.c
+++ b/source/blender/gpu/intern/gpu_matrix.c
@@ -48,15 +48,6 @@ typedef struct {
Mat4 ModelViewStack3D[MATRIX_STACK_DEPTH];
Mat4 ProjectionMatrix3D;
-#if MATRIX_2D_4x4
- Mat4 ModelViewStack2D[MATRIX_STACK_DEPTH];
- Mat4 ProjectionMatrix2D;
-#else
- Mat3 ModelViewStack2D[MATRIX_STACK_DEPTH];
- Mat3 ProjectionMatrix2D;
-#endif
-
- MatrixMode mode;
unsigned top; /* of current stack (would have to replicate if gpuResume2D/3D are implemented) */
bool dirty;
@@ -69,55 +60,33 @@ typedef struct {
*/
} MatrixState;
-static MatrixState state; /* TODO(merwin): make part of GPUContext, alongside immediate mode & state tracker */
+#define MATRIX_4X4_IDENTITY {{1.0f, 0.0f, 0.0f, 0.0f}, \
+ {0.0f, 1.0f, 0.0f, 0.0f}, \
+ {0.0f, 0.0f, 1.0f, 0.0f}, \
+ {0.0f, 0.0f, 0.0f, 1.0f}}
+
+/* TODO(merwin): make part of GPUContext, alongside immediate mode & state tracker */
+static MatrixState state = {
+ .ModelViewStack3D = {MATRIX_4X4_IDENTITY},
+ .ProjectionMatrix3D = MATRIX_4X4_IDENTITY,
+};
+
+#undef MATRIX_4X4_IDENTITY
#define ModelView3D state.ModelViewStack3D[state.top]
-#define ModelView2D state.ModelViewStack2D[state.top]
#define Projection3D state.ProjectionMatrix3D
-#define Projection2D state.ProjectionMatrix2D
void gpuMatrixInit(void)
{
memset(&state, 0, sizeof(MatrixState));
}
-void gpuMatrixBegin2D(void)
-{
- state.mode = MATRIX_MODE_2D;
- state.top = 0;
-#if MATRIX_2D_4x4
- unit_m4(ModelView2D);
- unit_m4(Projection2D);
-#else
- unit_m3(ModelView2D);
- unit_m3(Projection2D);
-#endif
-}
-
-void gpuMatrixBegin3D(void)
-{
- state.mode = MATRIX_MODE_3D;
- state.top = 0;
- unit_m4(ModelView3D);
- unit_m4(Projection3D);
-}
-
-void gpuMatrixEnd(void)
-{
- state.mode = MATRIX_MODE_INACTIVE;
-}
-
-
#ifdef WITH_GPU_SAFETY
/* Check if matrix is numerically good */
static void checkmat(cosnt float *m)
{
-#if MATRIX_2D_4x4
const int n = 16;
-#else
- const int n = state.mode == MATRIX_MODE_3D ? 16 : 9;
-#endif
for (int i = 0; i < n; i++) {
#if _MSC_VER
BLI_assert(_finite(m[i]));
@@ -139,37 +108,28 @@ static void checkmat(cosnt float *m)
void gpuPushMatrix(void)
{
#if SUPPORT_LEGACY_MATRIX
- if (state.mode == MATRIX_MODE_INACTIVE) {
+ {
glPushMatrix();
state.dirty = true;
return;
}
#endif
- BLI_assert(state.mode != MATRIX_MODE_INACTIVE);
BLI_assert(state.top < MATRIX_STACK_DEPTH);
state.top++;
- if (state.mode == MATRIX_MODE_3D)
- copy_m4_m4(ModelView3D, state.ModelViewStack3D[state.top - 1]);
- else
-#if MATRIX_2D_4x4
- copy_m4_m4(ModelView2D, state.ModelViewStack2D[state.top - 1]);
-#else
- copy_m3_m3(ModelView2D, state.ModelViewStack2D[state.top - 1]);
-#endif
+ copy_m4_m4(ModelView3D, state.ModelViewStack3D[state.top - 1]);
}
void gpuPopMatrix(void)
{
#if SUPPORT_LEGACY_MATRIX
- if (state.mode == MATRIX_MODE_INACTIVE) {
+ {
glPopMatrix();
state.dirty = true;
return;
}
#endif
- BLI_assert(state.mode != MATRIX_MODE_INACTIVE);
BLI_assert(state.top > 0);
state.top--;
state.dirty = true;
@@ -178,14 +138,13 @@ void gpuPopMatrix(void)
void gpuLoadMatrix3D(const float m[4][4])
{
#if SUPPORT_LEGACY_MATRIX
- if (state.mode == MATRIX_MODE_INACTIVE) {
+ {
glLoadMatrixf((const float*) m);
state.dirty = true;
return;
}
#endif
- BLI_assert(state.mode == MATRIX_MODE_3D);
copy_m4_m4(ModelView3D, m);
CHECKMAT(ModelView3D);
state.dirty = true;
@@ -194,7 +153,7 @@ void gpuLoadMatrix3D(const float m[4][4])
void gpuLoadProjectionMatrix3D(const float m[4][4])
{
#if SUPPORT_LEGACY_MATRIX
- if (state.mode == MATRIX_MODE_INACTIVE) {
+ {
GLenum mode;
glGetIntegerv(GL_MATRIX_MODE, (GLint*)&mode);
if (mode != GL_PROJECTION) {
@@ -212,7 +171,6 @@ void gpuLoadProjectionMatrix3D(const float m[4][4])
}
#endif
- BLI_assert(state.mode == MATRIX_MODE_3D);
copy_m4_m4(Projection3D, m);
CHECKMAT(Projection3D);
state.dirty = true;
@@ -221,7 +179,6 @@ void gpuLoadProjectionMatrix3D(const float m[4][4])
#if 0 /* unused at the moment */
void gpuLoadMatrix2D(const float m[3][3])
{
- BLI_assert(state.mode == MATRIX_MODE_2D);
copy_m3_m3(ModelView2D, m);
CHECKMAT(ModelView2D);
state.dirty = true;
@@ -230,49 +187,27 @@ void gpuLoadMatrix2D(const float m[3][3])
void gpuLoadIdentity(void)
{
- switch (state.mode) {
- case MATRIX_MODE_3D:
- unit_m4(ModelView3D);
- break;
- case MATRIX_MODE_2D:
-#if MATRIX_2D_4x4
- unit_m4(ModelView2D);
-#else
- unit_m3(ModelView2D);
-#endif
- break;
+ unit_m4(ModelView3D);
#if SUPPORT_LEGACY_MATRIX
- case MATRIX_MODE_INACTIVE:
- glLoadIdentity();
- break;
+ glLoadIdentity();
#endif
- default:
- BLI_assert(false);
- }
state.dirty = true;
}
void gpuTranslate2f(float x, float y)
{
#if SUPPORT_LEGACY_MATRIX
- if (state.mode == MATRIX_MODE_INACTIVE) {
+ {
glTranslatef(x, y, 0.0f);
state.dirty = true;
return;
}
#endif
-#if MATRIX_2D_4x4
Mat4 m;
unit_m4(m);
m[3][0] = x;
m[3][1] = y;
-#else
- Mat3 m;
- unit_m3(m);
- m[2][0] = x;
- m[2][1] = y;
-#endif
gpuMultMatrix2D(m);
}
@@ -284,14 +219,13 @@ void gpuTranslate2fv(const float vec[2])
void gpuTranslate3f(float x, float y, float z)
{
#if SUPPORT_LEGACY_MATRIX
- if (state.mode == MATRIX_MODE_INACTIVE) {
+ {
glTranslatef(x, y, z);
state.dirty = true;
return;
}
#endif
- BLI_assert(state.mode == MATRIX_MODE_3D);
#if 1
translate_m4(ModelView3D, x, y, z);
CHECKMAT(ModelView3D);
@@ -313,64 +247,31 @@ void gpuTranslate3fv(const float vec[3])
void gpuScaleUniform(float factor)
{
- switch (state.mode) {
- case MATRIX_MODE_3D:
- {
- Mat4 m;
- scale_m4_fl(m, factor);
- gpuMultMatrix3D(m);
- break;
- }
- case MATRIX_MODE_2D:
- {
-#if MATRIX_2D_4x4
- Mat4 m = {{0.0f}};
- m[0][0] = factor;
- m[1][1] = factor;
- m[2][2] = 1.0f;
- m[3][3] = 1.0f;
-#else
- Mat3 m = {{0.0f}};
- m[0][0] = factor;
- m[1][1] = factor;
- m[2][2] = 1.0f;
-#endif
- gpuMultMatrix2D(m);
- break;
- }
+ Mat4 m;
+ scale_m4_fl(m, factor);
+ gpuMultMatrix3D(m);
+
#if SUPPORT_LEGACY_MATRIX
- case MATRIX_MODE_INACTIVE:
- glScalef(factor, factor, factor); /* always scale Z since we can't distinguish 2D from 3D */
- state.dirty = true;
- break;
+ glScalef(factor, factor, factor); /* always scale Z since we can't distinguish 2D from 3D */
+ state.dirty = true;
#endif
- default:
- BLI_assert(false);
- }
}
void gpuScale2f(float x, float y)
{
#if SUPPORT_LEGACY_MATRIX
- if (state.mode == MATRIX_MODE_INACTIVE) {
+ {
glScalef(x, y, 1.0f);
state.dirty = true;
return;
}
#endif
-#if MATRIX_2D_4x4
Mat4 m = {{0.0f}};
m[0][0] = x;
m[1][1] = y;
m[2][2] = 1.0f;
m[3][3] = 1.0f;
-#else
- Mat3 m = {{0.0f}};
- m[0][0] = x;
- m[1][1] = y;
- m[2][2] = 1.0f;
-#endif
gpuMultMatrix2D(m);
}
@@ -382,7 +283,7 @@ void gpuScale2fv(const float vec[2])
void gpuScale3f(float x, float y, float z)
{
#if SUPPORT_LEGACY_MATRIX
- if (state.mode == MATRIX_MODE_INACTIVE) {
+ {
glScalef(x, y, z);
state.dirty = true;
return;
@@ -405,14 +306,13 @@ void gpuScale3fv(const float vec[3])
void gpuMultMatrix3D(const float m[4][4])
{
#if SUPPORT_LEGACY_MATRIX
- if (state.mode == MATRIX_MODE_INACTIVE) {
+ {
glMultMatrixf((const float*) m);
state.dirty = true;
return;
}
#endif
- BLI_assert(state.mode == MATRIX_MODE_3D);
mul_m4_m4_post(ModelView3D, m);
CHECKMAT(ModelView3D);
state.dirty = true;
@@ -421,15 +321,13 @@ void gpuMultMatrix3D(const float m[4][4])
#if MATRIX_2D_4x4
void gpuMultMatrix2D(const float m[4][4])
{
- BLI_assert(state.mode == MATRIX_MODE_2D);
- mul_m4_m4_post(ModelView2D, m);
+ mul_m4_m4_post(ModelView3D, m);
CHECKMAT(ModelView2D);
state.dirty = true;
}
#else
void gpuMultMatrix2D(const float m[3][3])
{
- BLI_assert(state.mode == MATRIX_MODE_2D);
mul_m3_m3_post(ModelView2D, m);
CHECKMAT(ModelView2D);
state.dirty = true;
@@ -439,21 +337,17 @@ void gpuMultMatrix2D(const float m[3][3])
void gpuRotate2D(float deg)
{
#if SUPPORT_LEGACY_MATRIX
- if (state.mode == MATRIX_MODE_INACTIVE) {
+ {
glRotatef(deg, 0.0f, 0.0f, 1.0f);
state.dirty = true;
return;
}
#endif
-#if MATRIX_2D_4x4
/* essentially RotateAxis('Z')
* TODO: simpler math for 2D case
*/
- rotate_m4(ModelView2D, 'Z', DEG2RADF(deg));
-#else
- BLI_assert(false); /* TODO: finish for MATRIX_MODE_2D */
-#endif
+ rotate_m4(ModelView3D, 'Z', DEG2RADF(deg));
}
void gpuRotate3f(float deg, float x, float y, float z)
@@ -465,7 +359,7 @@ void gpuRotate3f(float deg, float x, float y, float z)
void gpuRotate3fv(float deg, const float axis[3])
{
#if SUPPORT_LEGACY_MATRIX
- if (state.mode == MATRIX_MODE_INACTIVE) {
+ {
glRotatef(deg, axis[0], axis[1], axis[2]);
state.dirty = true;
return;
@@ -480,7 +374,7 @@ void gpuRotate3fv(float deg, const float axis[3])
void gpuRotateAxis(float deg, char axis)
{
#if SUPPORT_LEGACY_MATRIX
- if (state.mode == MATRIX_MODE_INACTIVE) {
+ {
float a[3] = { 0.0f };
switch (axis) {
case 'X': a[0] = 1.0f; break;
@@ -494,7 +388,6 @@ void gpuRotateAxis(float deg, char axis)
}
#endif
- BLI_assert(state.mode == MATRIX_MODE_3D);
/* rotate_m4 works in place */
rotate_m4(ModelView3D, axis, DEG2RADF(deg));
CHECKMAT(ModelView3D);
@@ -620,7 +513,7 @@ 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) {
@@ -639,7 +532,6 @@ void gpuOrtho(float left, float right, float bottom, float top, float near, floa
}
#endif
- BLI_assert(state.mode == MATRIX_MODE_3D);
mat4_ortho_set(Projection3D, left, right, bottom, top, near, far);
CHECKMAT(Projection3D);
state.dirty = true;
@@ -648,7 +540,7 @@ 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) {
@@ -667,13 +559,8 @@ void gpuOrtho2D(float left, float right, float bottom, float top)
}
#endif
- BLI_assert(state.mode == MATRIX_MODE_2D);
-#if MATRIX_2D_4x4
Mat4 m;
mat4_ortho_set(m, left, right, bottom, top, -1.0f, 1.0f);
-#else
- /* TODO: correct 3x3 implementation */
-#endif
CHECKMAT(Projection2D);
state.dirty = true;
}
@@ -681,7 +568,7 @@ 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) {
@@ -700,7 +587,6 @@ void gpuFrustum(float left, float right, float bottom, float top, float near, fl
}
#endif
- BLI_assert(state.mode == MATRIX_MODE_3D);
mat4_frustum_set(Projection3D, left, right, bottom, top, near, far);
CHECKMAT(Projection3D);
state.dirty = true;
@@ -786,7 +672,7 @@ bool gpuUnProject(const float win[3], const float model[4][4], const float proj[
const float *gpuGetModelViewMatrix3D(float m[4][4])
{
#if SUPPORT_LEGACY_MATRIX
- if (state.mode == MATRIX_MODE_INACTIVE) {
+ {
if (m == NULL) {
static Mat4 temp;
m = temp;
@@ -797,8 +683,6 @@ const float *gpuGetModelViewMatrix3D(float m[4][4])
}
#endif
- BLI_assert(state.mode == MATRIX_MODE_3D);
-
if (m) {
copy_m4_m4(m, ModelView3D);
return (const float*)m;
@@ -811,7 +695,7 @@ const float *gpuGetModelViewMatrix3D(float m[4][4])
const float *gpuGetProjectionMatrix3D(float m[4][4])
{
#if SUPPORT_LEGACY_MATRIX
- if (state.mode == MATRIX_MODE_INACTIVE) {
+ {
if (m == NULL) {
static Mat4 temp;
m = temp;
@@ -822,8 +706,6 @@ const float *gpuGetProjectionMatrix3D(float m[4][4])
}
#endif
- BLI_assert(state.mode == MATRIX_MODE_3D);
-
if (m) {
copy_m4_m4(m, Projection3D);
return (const float*)m;
@@ -841,7 +723,7 @@ const float *gpuGetModelViewProjectionMatrix3D(float m[4][4])
}
#if SUPPORT_LEGACY_MATRIX
- if (state.mode == MATRIX_MODE_INACTIVE) {
+ {
Mat4 proj;
glGetFloatv(GL_MODELVIEW_MATRIX, (float*)m);
glGetFloatv(GL_PROJECTION_MATRIX, (float*)proj);
@@ -850,8 +732,6 @@ const float *gpuGetModelViewProjectionMatrix3D(float m[4][4])
}
#endif
- BLI_assert(state.mode == MATRIX_MODE_3D);
-
mul_m4_m4m4(m, Projection3D, ModelView3D);
return (const float*)m;
}
@@ -884,49 +764,6 @@ const float *gpuGetNormalMatrixInverse(float m[3][3])
return (const float*)m;
}
-#if MATRIX_2D_4x4
-static const float *gpuGetModelViewMatrix2D(float m[4][4])
-{
- BLI_assert(state.mode == MATRIX_MODE_2D);
-
- if (m) {
- copy_m4_m4(m, ModelView2D);
- return (const float*)m;
- }
- else {
- return (const float*)ModelView2D;
- }
-}
-
-static const float *gpuGetProjectionMatrix2D(float m[4][4])
-{
- BLI_assert(state.mode == MATRIX_MODE_2D);
-
- if (m) {
- copy_m4_m4(m, Projection2D);
- return (const float*)m;
- }
- else {
- return (const float*)Projection2D;
- }
-}
-
-static const float *gpuGetModelViewProjectionMatrix2D(float m[4][4])
-{
- BLI_assert(state.mode == MATRIX_MODE_2D);
-
- if (m == NULL) {
- static Mat4 temp;
- m = temp;
- }
-
- mul_m4_m4m4(m, Projection2D, ModelView2D);
- return (const float*)m;
-}
-#else /* not MATRIX_2D_4x4 */
-/* TODO: implement 3x3 getters */
-#endif
-
void gpuBindMatrices(const ShaderInterface* shaderface)
{
/* set uniform values to matrix stack values
@@ -937,83 +774,55 @@ void gpuBindMatrices(const ShaderInterface* shaderface)
const ShaderInput *MV = ShaderInterface_builtin_uniform(shaderface, UNIFORM_MODELVIEW_3D);
const ShaderInput *P = ShaderInterface_builtin_uniform(shaderface, UNIFORM_PROJECTION_3D);
const ShaderInput *MVP = ShaderInterface_builtin_uniform(shaderface, UNIFORM_MVP_3D);
- /* TODO: teach ShaderInterface to distinguish 2D from 3D --^ */
-
- if (state.mode == MATRIX_MODE_2D) {
- if (MV) {
- #if DEBUG_MATRIX_BIND
- puts("setting 2D MV matrix");
- #endif
- glUniformMatrix4fv(MV->location, 1, GL_FALSE, gpuGetModelViewMatrix2D(NULL));
- }
+ const ShaderInput *N = ShaderInterface_builtin_uniform(shaderface, UNIFORM_NORMAL_3D);
+ const ShaderInput *MV_inv = ShaderInterface_builtin_uniform(shaderface, UNIFORM_MODELVIEW_INV_3D);
+ const ShaderInput *P_inv = ShaderInterface_builtin_uniform(shaderface, UNIFORM_PROJECTION_INV_3D);
- if (P) {
- #if DEBUG_MATRIX_BIND
- puts("setting 2D P matrix");
- #endif
+ if (MV) {
+ #if DEBUG_MATRIX_BIND
+ puts("setting 3D MV matrix");
+ #endif
- glUniformMatrix4fv(P->location, 1, GL_FALSE, gpuGetProjectionMatrix2D(NULL));
- }
-
- if (MVP) {
- #if DEBUG_MATRIX_BIND
- puts("setting 2D MVP matrix");
- #endif
-
- glUniformMatrix4fv(MVP->location, 1, GL_FALSE, gpuGetModelViewProjectionMatrix2D(NULL));
- }
+ glUniformMatrix4fv(MV->location, 1, GL_FALSE, gpuGetModelViewMatrix3D(NULL));
}
- else {
- const ShaderInput *N = ShaderInterface_builtin_uniform(shaderface, UNIFORM_NORMAL_3D);
- const ShaderInput *MV_inv = ShaderInterface_builtin_uniform(shaderface, UNIFORM_MODELVIEW_INV_3D);
- const ShaderInput *P_inv = ShaderInterface_builtin_uniform(shaderface, UNIFORM_PROJECTION_INV_3D);
-
- if (MV) {
- #if DEBUG_MATRIX_BIND
- puts("setting 3D MV matrix");
- #endif
-
- glUniformMatrix4fv(MV->location, 1, GL_FALSE, gpuGetModelViewMatrix3D(NULL));
- }
- if (P) {
- #if DEBUG_MATRIX_BIND
- puts("setting 3D P matrix");
- #endif
+ if (P) {
+ #if DEBUG_MATRIX_BIND
+ puts("setting 3D P matrix");
+ #endif
- glUniformMatrix4fv(P->location, 1, GL_FALSE, gpuGetProjectionMatrix3D(NULL));
- }
+ glUniformMatrix4fv(P->location, 1, GL_FALSE, gpuGetProjectionMatrix3D(NULL));
+ }
- if (MVP) {
- #if DEBUG_MATRIX_BIND
- puts("setting 3D MVP matrix");
- #endif
+ if (MVP) {
+ #if DEBUG_MATRIX_BIND
+ puts("setting 3D MVP matrix");
+ #endif
- glUniformMatrix4fv(MVP->location, 1, GL_FALSE, gpuGetModelViewProjectionMatrix3D(NULL));
- }
+ glUniformMatrix4fv(MVP->location, 1, GL_FALSE, gpuGetModelViewProjectionMatrix3D(NULL));
+ }
- if (N) {
- #if DEBUG_MATRIX_BIND
- puts("setting 3D normal matrix");
- #endif
+ if (N) {
+ #if DEBUG_MATRIX_BIND
+ puts("setting 3D normal matrix");
+ #endif
- glUniformMatrix3fv(N->location, 1, GL_FALSE, gpuGetNormalMatrix(NULL));
- }
+ glUniformMatrix3fv(N->location, 1, GL_FALSE, gpuGetNormalMatrix(NULL));
+ }
- if (MV_inv) {
- Mat4 m;
- gpuGetModelViewMatrix3D(m);
- invert_m4(m);
- glUniformMatrix4fv(MV_inv->location, 1, GL_FALSE, (const float*) m);
- }
+ if (MV_inv) {
+ Mat4 m;
+ gpuGetModelViewMatrix3D(m);
+ invert_m4(m);
+ glUniformMatrix4fv(MV_inv->location, 1, GL_FALSE, (const float*) m);
+ }
- if (P_inv) {
- Mat4 m;
- gpuGetProjectionMatrix3D(m);
- invert_m4(m);
- glUniformMatrix4fv(P_inv->location, 1, GL_FALSE, (const float*) m);
- }
+ if (P_inv) {
+ Mat4 m;
+ gpuGetProjectionMatrix3D(m);
+ invert_m4(m);
+ glUniformMatrix4fv(P_inv->location, 1, GL_FALSE, (const float*) m);
}
state.dirty = false;