summaryrefslogtreecommitdiff
path: root/indra/llrender/llgl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llrender/llgl.cpp')
-rw-r--r--indra/llrender/llgl.cpp43
1 files changed, 21 insertions, 22 deletions
diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp
index 0db1e27b01..c62cacdce6 100644
--- a/indra/llrender/llgl.cpp
+++ b/indra/llrender/llgl.cpp
@@ -50,6 +50,10 @@
#include "llglheaders.h"
#include "llglslshader.h"
+#include "glm/glm.hpp"
+#include <glm/gtc/matrix_access.hpp>
+#include "glm/gtc/type_ptr.hpp"
+
#if LL_WINDOWS
#include "lldxhardware.h"
#endif
@@ -2694,7 +2698,7 @@ void parse_glsl_version(S32& major, S32& minor)
LLStringUtil::convertToS32(minor_str, minor);
}
-LLGLUserClipPlane::LLGLUserClipPlane(const LLPlane& p, const glh::matrix4f& modelview, const glh::matrix4f& projection, bool apply)
+LLGLUserClipPlane::LLGLUserClipPlane(const LLPlane& p, const glm::mat4& modelview, const glm::mat4& projection, bool apply)
{
mApply = apply;
@@ -2721,13 +2725,12 @@ void LLGLUserClipPlane::disable()
void LLGLUserClipPlane::setPlane(F32 a, F32 b, F32 c, F32 d)
{
- glh::matrix4f& P = mProjection;
- glh::matrix4f& M = mModelview;
+ const glm::mat4& P = mProjection;
+ const glm::mat4& M = mModelview;
- glh::matrix4f invtrans_MVP = (P * M).inverse().transpose();
- glh::vec4f oplane(a,b,c,d);
- glh::vec4f cplane;
- invtrans_MVP.mult_matrix_vec(oplane, cplane);
+ glm::mat4 invtrans_MVP = glm::transpose(glm::inverse(P*M));
+ glm::vec4 oplane(a,b,c,d);
+ glm::vec4 cplane = invtrans_MVP * oplane;
cplane /= fabs(cplane[2]); // normalize such that depth is not scaled
cplane[3] -= 1;
@@ -2735,13 +2738,13 @@ void LLGLUserClipPlane::setPlane(F32 a, F32 b, F32 c, F32 d)
if(cplane[2] < 0)
cplane *= -1;
- glh::matrix4f suffix;
- suffix.set_row(2, cplane);
- glh::matrix4f newP = suffix * P;
+ glm::mat4 suffix;
+ suffix = glm::row(suffix, 2, cplane);
+ glm::mat4 newP = suffix * P;
gGL.matrixMode(LLRender::MM_PROJECTION);
gGL.pushMatrix();
- gGL.loadMatrix(newP.m);
- gGLObliqueProjectionInverse = LLMatrix4(newP.inverse().transpose().m);
+ gGL.loadMatrix(glm::value_ptr(newP));
+ gGLObliqueProjectionInverse = LLMatrix4(glm::value_ptr(glm::transpose(glm::inverse(newP))));
gGL.matrixMode(LLRender::MM_MODELVIEW);
}
@@ -2838,31 +2841,27 @@ void LLGLDepthTest::checkState()
LLGLSquashToFarClip::LLGLSquashToFarClip()
{
- glh::matrix4f proj = get_current_projection();
+ glm::mat4 proj = get_current_projection();
setProjectionMatrix(proj, 0);
}
-LLGLSquashToFarClip::LLGLSquashToFarClip(glh::matrix4f& P, U32 layer)
+LLGLSquashToFarClip::LLGLSquashToFarClip(const glm::mat4& P, U32 layer)
{
setProjectionMatrix(P, layer);
}
-
-void LLGLSquashToFarClip::setProjectionMatrix(glh::matrix4f& projection, U32 layer)
+void LLGLSquashToFarClip::setProjectionMatrix(glm::mat4 projection, U32 layer)
{
-
F32 depth = 0.99999f - 0.0001f * layer;
- for (U32 i = 0; i < 4; i++)
- {
- projection.element(2, i) = projection.element(3, i) * depth;
- }
+ glm::vec4 P_row_3 = glm::row(projection, 3) * depth;
+ projection = glm::row(projection, 2, P_row_3);
LLRender::eMatrixMode last_matrix_mode = gGL.getMatrixMode();
gGL.matrixMode(LLRender::MM_PROJECTION);
gGL.pushMatrix();
- gGL.loadMatrix(projection.m);
+ gGL.loadMatrix(glm::value_ptr(projection));
gGL.matrixMode(last_matrix_mode);
}