OpenGL: add gpuLoadProjectionMatrix3D function
Make an existing 4x4 matrix the current projection. Found a need for this while converting code to new API. Part of T49450
This commit is contained in:
parent
6d2aca5a96
commit
0a274df536
|
@ -106,6 +106,8 @@ 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);
|
||||
|
@ -174,6 +176,8 @@ bool gpuMatricesDirty(void); /* since last bind */
|
|||
# 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))
|
||||
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#define SUPPRESS_GENERIC_MATRIX_API
|
||||
#include "GPU_matrix.h"
|
||||
|
||||
#include "BIF_glutil.h"
|
||||
|
||||
#include "BLI_math_matrix.h"
|
||||
#include "BLI_math_rotation.h"
|
||||
#include "BLI_math_vector.h"
|
||||
|
@ -185,6 +187,32 @@ void gpuLoadMatrix3D(const float m[4][4])
|
|||
state.dirty = true;
|
||||
}
|
||||
|
||||
void gpuLoadProjectionMatrix3D(const float m[4][4])
|
||||
{
|
||||
#if SUPPORT_LEGACY_MATRIX
|
||||
if (state.mode == MATRIX_MODE_INACTIVE) {
|
||||
GLenum mode = glaGetOneInt(GL_MATRIX_MODE);
|
||||
if (mode != GL_PROJECTION_MATRIX) {
|
||||
glMatrixMode(GL_PROJECTION_MATRIX);
|
||||
}
|
||||
|
||||
glLoadMatrixf((const float*) m);
|
||||
|
||||
if (mode != GL_PROJECTION_MATRIX) {
|
||||
glMatrixMode(mode); /* restore */
|
||||
}
|
||||
|
||||
state.dirty = true;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
BLI_assert(state.mode == MATRIX_MODE_3D);
|
||||
copy_m4_m4(Projection3D, m);
|
||||
CHECKMAT(Projection3D);
|
||||
state.dirty = true;
|
||||
}
|
||||
|
||||
void gpuLoadMatrix2D(const float m[3][3])
|
||||
{
|
||||
BLI_assert(state.mode == MATRIX_MODE_2D);
|
||||
|
|
Loading…
Reference in New Issue