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:
Diffstat (limited to 'source/blender/gpu/GPU_matrix.h')
-rw-r--r--source/blender/gpu/GPU_matrix.h71
1 files changed, 53 insertions, 18 deletions
diff --git a/source/blender/gpu/GPU_matrix.h b/source/blender/gpu/GPU_matrix.h
index 43a03f8e4b6..85b1b5c7acf 100644
--- a/source/blender/gpu/GPU_matrix.h
+++ b/source/blender/gpu/GPU_matrix.h
@@ -1,6 +1,3 @@
-#ifndef _GPU_MATRIX_H_
-#define _GPU_MATRIX_H_
-
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
@@ -32,8 +29,11 @@
* \ingroup gpu
*/
+#ifndef _GPU_MATRIX_H_
+#define _GPU_MATRIX_H_
+
+#include "BLI_sys_types.h"
#include "GPU_glew.h"
-#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
@@ -84,6 +84,7 @@ void gpuTranslate3f(float x, float y, float z);
void gpuTranslate3fv(const float vec[3]);
void gpuScale3f(float x, float y, float z);
void gpuScale3fv(const float vec[3]);
+void gpuRotate3f(float deg, float x, float y, float z); /* axis of rotation should be a unit vector */
void gpuRotate3fv(float deg, const float axis[3]); /* axis of rotation should be a unit vector */
void gpuRotateAxis(float deg, char axis); /* TODO: enum for axis? */
@@ -105,16 +106,16 @@ void gpuRotate2D(float deg);
/* 3D Projection Matrix */
+void gpuLoadProjectionMatrix3D(const float m[4][4]);
+
void gpuOrtho(float left, float right, float bottom, float top, float near, float far);
void gpuFrustum(float left, float right, float bottom, float top, float near, float far);
void gpuPerspective(float fovy, float aspect, float near, float far);
-/* pass vector through current transform (world --> screen) */
-void gpuProject(const float obj[3], const float model[4][4], const float proj[4][4], const GLint view[4], float win[3]);
-
-/* pass vector through inverse transform (world <-- screen) */
-bool gpuUnProject(const float win[3], const float model[4][4], const float proj[4][4], const GLint view[4], float obj[3]);
+/* 3D Projection between Window and World Space */
+void gpuProject(const float world[3], const float model[4][4], const float proj[4][4], const int view[4], float win[3]);
+bool gpuUnProject(const float win[3], const float model[4][4], const float proj[4][4], const int view[4], float world[3]);
/* 2D Projection Matrix */
@@ -130,15 +131,6 @@ const float *gpuGetNormalMatrix(float m[3][3]);
const float *gpuGetNormalMatrixInverse(float m[3][3]);
-#if SUPPORT_LEGACY_MATRIX
-/* copy top matrix from each legacy stack into new fresh stack */
-void gpuMatrixBegin3D_legacy(void);
-
-/* call after using glScale, glTranslate, etc. between draw calls */
-void gpuMatrixUpdate_legacy(void);
-#endif
-
-
/* set uniform values for currently bound shader */
void gpuBindMatrices(GLuint program);
bool gpuMatricesDirty(void); /* since last bind */
@@ -147,4 +139,47 @@ bool gpuMatricesDirty(void); /* since last bind */
}
#endif
+
+#ifndef SUPPRESS_GENERIC_MATRIX_API
+/* make matrix inputs generic, to avoid warnings */
+#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
+# define gpuMultMatrix3D(x) \
+ gpuMultMatrix3D(_Generic((x), \
+ float *: (const float (*)[4])(x), \
+ float [16]: (const float (*)[4])(x), \
+ float (*)[4]: (const float (*)[4])(x), \
+ float [4][4]: (const float (*)[4])(x), \
+ const float *: (const float (*)[4])(x), \
+ const float [16]: (const float (*)[4])(x), \
+ const float (*)[4]: (const float (*)[4])(x), \
+ const float [4][4]: (const float (*)[4])(x)) \
+)
+# define gpuLoadMatrix3D(x) \
+ gpuLoadMatrix3D(_Generic((x), \
+ float *: (const float (*)[4])(x), \
+ float [16]: (const float (*)[4])(x), \
+ float (*)[4]: (const float (*)[4])(x), \
+ float [4][4]: (const float (*)[4])(x), \
+ const float *: (const float (*)[4])(x), \
+ const float [16]: (const float (*)[4])(x), \
+ const float (*)[4]: (const float (*)[4])(x), \
+ const float [4][4]: (const float (*)[4])(x)) \
+)
+/* TODO: finish this in a simpler way --^ */
+#else
+# define gpuMultMatrix3D(x) gpuMultMatrix3D((const float (*)[4])(x))
+# define gpuLoadMatrix3D(x) gpuLoadMatrix3D((const float (*)[4])(x))
+
+# define gpuLoadProjectionMatrix3D(x) gpuLoadProjectionMatrix3D((const float (*)[4])(x))
+
+# define gpuMultMatrix2D(x) gpuMultMatrix2D((const float (*)[3])(x))
+# define gpuLoadMatrix2D(x) gpuLoadMatrix2D((const float (*)[3])(x))
+
+# define gpuGetModelViewMatrix3D(x) gpuGetModelViewMatrix3D((float (*)[4])(x))
+# define gpuGetProjectionMatrix3D(x) gpuGetProjectionMatrix3D((float (*)[4])(x))
+# define gpuGetModelViewProjectionMatrix3D(x) gpuGetModelViewProjectionMatrix3D((float (*)[4])(x))
+# define gpuGetNormalMatrix(x) gpuGetNormalMatrix((float (*)[3])(x))
+# define gpuGetNormalMatrixInverse(x) gpuGetNormalMatrixInverse((float (*)[3])(x))
+#endif /* C11 */
+#endif /* SUPPRESS_GENERIC_MATRIX_API */
#endif /* GPU_MATRIX_H */