diff options
Diffstat (limited to 'indra/newview/llviewerdisplay.cpp')
-rw-r--r-- | indra/newview/llviewerdisplay.cpp | 57 |
1 files changed, 31 insertions, 26 deletions
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 9bd0973cc0..301ea5c5f6 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -81,6 +81,10 @@ #include "llenvironment.h" #include "llperfstats.h" +#include <glm/glm.hpp> +#include <glm/gtc/matrix_transform.hpp> +#include <glm/gtc/type_ptr.hpp> + extern LLPointer<LLViewerTexture> gStartTexture; extern bool gShiftFrame; @@ -760,8 +764,8 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) LLGLState::checkStates(); - glh::matrix4f proj = get_current_projection(); - glh::matrix4f mod = get_current_modelview(); + glm::mat4 proj = get_current_projection(); + glm::mat4 mod = get_current_modelview(); glViewport(0,0,512,512); LLVOAvatar::updateImpostors(); @@ -769,9 +773,9 @@ void display(bool rebuild, F32 zoom_factor, int subfield, bool for_snapshot) set_current_projection(proj); set_current_modelview(mod); gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.loadMatrix(proj.m); + gGL.loadMatrix(glm::value_ptr(proj)); gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.loadMatrix(mod.m); + gGL.loadMatrix(glm::value_ptr(mod)); gViewerWindow->setup3DViewport(); LLGLState::checkStates(); @@ -1148,8 +1152,8 @@ void render_hud_attachments() gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.pushMatrix(); - glh::matrix4f current_proj = get_current_projection(); - glh::matrix4f current_mod = get_current_modelview(); + glm::mat4 current_proj = get_current_projection(); + glm::mat4 current_mod = get_current_modelview(); // clamp target zoom level to reasonable values gAgentCamera.mHUDTargetZoom = llclamp(gAgentCamera.mHUDTargetZoom, 0.1f, 1.f); @@ -1273,7 +1277,7 @@ LLRect get_whole_screen_region() return whole_screen; } -bool get_hud_matrices(const LLRect& screen_region, glh::matrix4f &proj, glh::matrix4f &model) +bool get_hud_matrices(const LLRect& screen_region, glm::mat4 &proj, glm::mat4&model) { if (isAgentAvatarValid() && gAgentAvatarp->hasHUDAttachment()) { @@ -1281,28 +1285,29 @@ bool get_hud_matrices(const LLRect& screen_region, glh::matrix4f &proj, glh::mat LLBBox hud_bbox = gAgentAvatarp->getHUDBBox(); F32 hud_depth = llmax(1.f, hud_bbox.getExtentLocal().mV[VX] * 1.1f); - proj = gl_ortho(-0.5f * LLViewerCamera::getInstance()->getAspect(), 0.5f * LLViewerCamera::getInstance()->getAspect(), -0.5f, 0.5f, 0.f, hud_depth); - proj.element(2,2) = -0.01f; + proj = glm::ortho(-0.5f * LLViewerCamera::getInstance()->getAspect(), 0.5f * LLViewerCamera::getInstance()->getAspect(), -0.5f, 0.5f, 0.f, hud_depth); + proj[2][2] = -0.01f; F32 aspect_ratio = LLViewerCamera::getInstance()->getAspect(); - glh::matrix4f mat; F32 scale_x = (F32)gViewerWindow->getWorldViewWidthScaled() / (F32)screen_region.getWidth(); F32 scale_y = (F32)gViewerWindow->getWorldViewHeightScaled() / (F32)screen_region.getHeight(); - mat.set_scale(glh::vec3f(scale_x, scale_y, 1.f)); - mat.set_translate( - glh::vec3f(clamp_rescale((F32)(screen_region.getCenterX() - screen_region.mLeft), 0.f, (F32)gViewerWindow->getWorldViewWidthScaled(), 0.5f * scale_x * aspect_ratio, -0.5f * scale_x * aspect_ratio), - clamp_rescale((F32)(screen_region.getCenterY() - screen_region.mBottom), 0.f, (F32)gViewerWindow->getWorldViewHeightScaled(), 0.5f * scale_y, -0.5f * scale_y), - 0.f)); - proj *= mat; - - glh::matrix4f tmp_model((GLfloat*) OGL_TO_CFR_ROTATION); - mat.set_scale(glh::vec3f(zoom_level, zoom_level, zoom_level)); - mat.set_translate(glh::vec3f(-hud_bbox.getCenterLocal().mV[VX] + (hud_depth * 0.5f), 0.f, 0.f)); + glm::mat4 mat = glm::identity<glm::mat4>(); + mat = glm::translate(mat, + glm::vec3(clamp_rescale((F32)(screen_region.getCenterX() - screen_region.mLeft), 0.f, (F32)gViewerWindow->getWorldViewWidthScaled(), 0.5f * scale_x * aspect_ratio, -0.5f * scale_x * aspect_ratio), + clamp_rescale((F32)(screen_region.getCenterY() - screen_region.mBottom), 0.f, (F32)gViewerWindow->getWorldViewHeightScaled(), 0.5f * scale_y, -0.5f * scale_y), + 0.f)); + mat = glm::scale(mat, glm::vec3(scale_x, scale_y, 1.f)); + proj *= mat; + glm::mat4 tmp_model = glm::make_mat4(OGL_TO_CFR_ROTATION); + mat = glm::identity<glm::mat4>(); + mat = glm::translate(mat, glm::vec3(-hud_bbox.getCenterLocal().mV[VX] + (hud_depth * 0.5f), 0.f, 0.f)); + mat = glm::scale(mat, glm::vec3(zoom_level)); tmp_model *= mat; model = tmp_model; + return true; } else @@ -1311,7 +1316,7 @@ bool get_hud_matrices(const LLRect& screen_region, glh::matrix4f &proj, glh::mat } } -bool get_hud_matrices(glh::matrix4f &proj, glh::matrix4f &model) +bool get_hud_matrices(glm::mat4 &proj, glm::mat4&model) { LLRect whole_screen = get_whole_screen_region(); return get_hud_matrices(whole_screen, proj, model); @@ -1325,17 +1330,17 @@ bool setup_hud_matrices() bool setup_hud_matrices(const LLRect& screen_region) { - glh::matrix4f proj, model; + glm::mat4 proj, model; bool result = get_hud_matrices(screen_region, proj, model); if (!result) return result; // set up transform to keep HUD objects in front of camera gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.loadMatrix(proj.m); + gGL.loadMatrix(glm::value_ptr(proj)); set_current_projection(proj); gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.loadMatrix(model.m); + gGL.loadMatrix(glm::value_ptr(model)); set_current_modelview(model); return true; } @@ -1347,13 +1352,13 @@ void render_ui(F32 zoom_factor, int subfield) LL_PROFILE_GPU_ZONE("ui"); LLGLState::checkStates(); - glh::matrix4f saved_view = get_current_modelview(); + glm::mat4 saved_view = get_current_modelview(); if (!gSnapshot) { gGL.pushMatrix(); gGL.loadMatrix(gGLLastModelView); - set_current_modelview(copy_matrix(gGLLastModelView)); + set_current_modelview(glm::make_mat4(gGLLastModelView)); } if(LLSceneMonitor::getInstance()->needsUpdate()) |