diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llhudrender.cpp | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/llhudrender.cpp')
-rw-r--r-- | linden/indra/newview/llhudrender.cpp | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/linden/indra/newview/llhudrender.cpp b/linden/indra/newview/llhudrender.cpp new file mode 100644 index 0000000..8060318 --- /dev/null +++ b/linden/indra/newview/llhudrender.cpp | |||
@@ -0,0 +1,132 @@ | |||
1 | /** | ||
2 | * @file llhudrender.cpp | ||
3 | * @brief LLHUDRender class implementation | ||
4 | * | ||
5 | * Copyright (c) 2002-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #include "llviewerprecompiledheaders.h" | ||
29 | |||
30 | #include "llhudrender.h" | ||
31 | |||
32 | #include "llgl.h" | ||
33 | #include "llviewercamera.h" | ||
34 | #include "v3math.h" | ||
35 | #include "llquaternion.h" | ||
36 | #include "llfontgl.h" | ||
37 | #include "llimagegl.h" | ||
38 | #include "llglheaders.h" | ||
39 | #include "llviewerwindow.h" | ||
40 | |||
41 | void hud_render_utf8text(const std::string &str, const LLVector3 &pos_agent, | ||
42 | const LLFontGL &font, | ||
43 | const U8 style, | ||
44 | const F32 x_offset, const F32 y_offset, | ||
45 | const LLColor4& color, | ||
46 | const BOOL orthographic) | ||
47 | { | ||
48 | LLWString wstr(utf8str_to_wstring(str)); | ||
49 | hud_render_text(wstr, pos_agent, font, style, x_offset, y_offset, color, orthographic); | ||
50 | } | ||
51 | |||
52 | void hud_render_text(const LLWString &wstr, const LLVector3 &pos_agent, | ||
53 | const LLFontGL &font, | ||
54 | const U8 style, | ||
55 | const F32 x_offset, const F32 y_offset, | ||
56 | const LLColor4& color, | ||
57 | const BOOL orthographic) | ||
58 | { | ||
59 | // Do cheap plane culling | ||
60 | LLVector3 dir_vec = pos_agent - gCamera->getOrigin(); | ||
61 | dir_vec /= dir_vec.magVec(); | ||
62 | |||
63 | if (wstr.empty() || (!orthographic && dir_vec * gCamera->getAtAxis() <= 0.f)) | ||
64 | { | ||
65 | return; | ||
66 | } | ||
67 | |||
68 | LLVector3 right_axis; | ||
69 | LLVector3 up_axis; | ||
70 | if (orthographic) | ||
71 | { | ||
72 | right_axis.setVec(0.f, -1.f / gViewerWindow->getWindowHeight(), 0.f); | ||
73 | up_axis.setVec(0.f, 0.f, 1.f / gViewerWindow->getWindowHeight()); | ||
74 | } | ||
75 | else | ||
76 | { | ||
77 | gCamera->getPixelVectors(pos_agent, up_axis, right_axis); | ||
78 | } | ||
79 | LLCoordFrame render_frame = *gCamera; | ||
80 | LLQuaternion rot; | ||
81 | if (!orthographic) | ||
82 | { | ||
83 | rot = render_frame.getQuaternion(); | ||
84 | rot = rot * LLQuaternion(-F_PI_BY_TWO, gCamera->getYAxis()); | ||
85 | rot = rot * LLQuaternion(F_PI_BY_TWO, gCamera->getXAxis()); | ||
86 | } | ||
87 | else | ||
88 | { | ||
89 | rot = LLQuaternion(-F_PI_BY_TWO, LLVector3(0.f, 0.f, 1.f)); | ||
90 | rot = rot * LLQuaternion(-F_PI_BY_TWO, LLVector3(0.f, 1.f, 0.f)); | ||
91 | } | ||
92 | F32 angle; | ||
93 | LLVector3 axis; | ||
94 | rot.getAngleAxis(&angle, axis); | ||
95 | |||
96 | LLVector3 render_pos = pos_agent + (floorf(x_offset) * right_axis) + (floorf(y_offset) * up_axis); | ||
97 | |||
98 | //get the render_pos in screen space | ||
99 | F64 modelview[16]; | ||
100 | F64 projection[16]; | ||
101 | GLint viewport[4]; | ||
102 | glGetDoublev(GL_MODELVIEW_MATRIX, modelview); | ||
103 | glGetDoublev(GL_PROJECTION_MATRIX, projection); | ||
104 | glGetIntegerv(GL_VIEWPORT, viewport); | ||
105 | |||
106 | F64 winX, winY, winZ; | ||
107 | gluProject(render_pos.mV[0], render_pos.mV[1], render_pos.mV[2], | ||
108 | modelview, projection, viewport, | ||
109 | &winX, &winY, &winZ); | ||
110 | |||
111 | //fonts all render orthographically, set up projection | ||
112 | glMatrixMode(GL_PROJECTION); | ||
113 | glPushMatrix(); | ||
114 | glMatrixMode(GL_MODELVIEW); | ||
115 | |||
116 | LLUI::pushMatrix(); | ||
117 | |||
118 | gViewerWindow->setup2DRender(); | ||
119 | |||
120 | LLUI::loadIdentity(); | ||
121 | LLUI::translate((F32) winX*1.0f/LLFontGL::sScaleX, (F32) winY*1.0f/(LLFontGL::sScaleY), -(((F32) winZ*2.f)-1.f)); | ||
122 | //glRotatef(angle * RAD_TO_DEG, axis.mV[VX], axis.mV[VY], axis.mV[VZ]); | ||
123 | //glScalef(right_scale, up_scale, 1.f); | ||
124 | F32 right_x; | ||
125 | |||
126 | font.render(wstr, 0, 0, 0, color, LLFontGL::LEFT, LLFontGL::BASELINE, style, wstr.length(), 1000, &right_x); | ||
127 | LLUI::popMatrix(); | ||
128 | |||
129 | glMatrixMode(GL_PROJECTION); | ||
130 | glPopMatrix(); | ||
131 | glMatrixMode(GL_MODELVIEW); | ||
132 | } | ||