aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llbox.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llbox.cpp
parentREADME.txt (diff)
downloadmeta-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/llbox.cpp')
-rw-r--r--linden/indra/newview/llbox.cpp124
1 files changed, 124 insertions, 0 deletions
diff --git a/linden/indra/newview/llbox.cpp b/linden/indra/newview/llbox.cpp
new file mode 100644
index 0000000..8f51c4f
--- /dev/null
+++ b/linden/indra/newview/llbox.cpp
@@ -0,0 +1,124 @@
1/**
2 * @file llbox.cpp
3 * @brief Draws a box using display lists for speed.
4 *
5 * Copyright (c) 2001-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 "llbox.h"
31
32#include "llgl.h"
33#include "llglheaders.h"
34
35LLBox gBox;
36
37// These routines support multiple textures on a box
38void LLBox::prerender()
39{
40 F32 size = 1.f;
41
42 mTriangleCount = 6 * 2;
43
44 mVertex[0][0] = mVertex[1][0] = mVertex[2][0] = mVertex[3][0] = -size / 2;
45 mVertex[4][0] = mVertex[5][0] = mVertex[6][0] = mVertex[7][0] = size / 2;
46 mVertex[0][1] = mVertex[1][1] = mVertex[4][1] = mVertex[5][1] = -size / 2;
47 mVertex[2][1] = mVertex[3][1] = mVertex[6][1] = mVertex[7][1] = size / 2;
48 mVertex[0][2] = mVertex[3][2] = mVertex[4][2] = mVertex[7][2] = -size / 2;
49 mVertex[1][2] = mVertex[2][2] = mVertex[5][2] = mVertex[6][2] = size / 2;
50}
51
52// These routines support multiple textures on a box
53void LLBox::cleanupGL()
54{
55 // No GL state, a noop.
56}
57
58void LLBox::renderface(S32 which_face)
59{
60 static F32 normals[6][3] =
61 {
62 {-1.0f, 0.0f, 0.0f},
63 { 0.0f, 1.0f, 0.0f},
64 { 1.0f, 0.0f, 0.0f},
65 { 0.0f, -1.0f, 0.0f},
66 { 0.0f, 0.0f, 1.0f},
67 { 0.0f, 0.0f, -1.0f}
68 };
69 static S32 faces[6][4] =
70 {
71 {0, 1, 2, 3},
72 {3, 2, 6, 7},
73 {7, 6, 5, 4},
74 {4, 5, 1, 0},
75 {5, 6, 2, 1},
76 {7, 4, 0, 3}
77 };
78
79 glBegin(GL_QUADS);
80 glNormal3fv(&normals[which_face][0]);
81 glTexCoord2f(1,0);
82 glVertex3fv(&mVertex[ faces[which_face][0] ][0]);
83 glTexCoord2f(1,1);
84 glVertex3fv(&mVertex[ faces[which_face][1] ][0]);
85 glTexCoord2f(0,1);
86 glVertex3fv(&mVertex[ faces[which_face][2] ][0]);
87 glTexCoord2f(0,0);
88 glVertex3fv(&mVertex[ faces[which_face][3] ][0]);
89 glEnd();
90}
91
92void LLBox::render()
93{
94 // This is a flattend representation of the box as render here
95 // .
96 // (-++) (+++) /|\t
97 // +------------+ | (texture coordinates)
98 // |2 1| |
99 // | 4 | (*) --->s
100 // | TOP |
101 // | |
102 // (-++) (--+)|3 0|(+-+) (+++) (-++)
103 // +------------+------------+------------+------------+
104 // |2 1|2 1|2 1|2 1|
105 // | 0 | 1 | 2 | 3 |
106 // | BACK | RIGHT | FRONT | LEFT |
107 // | | | | |
108 // |3 0|3 0|3 0|3 0|
109 // +------------+------------+------------+------------+
110 // (-+-) (---)|2 1|(+--) (++-) (-+-)
111 // | 5 |
112 // | BOTTOM |
113 // | |
114 // |3 0|
115 // +------------+
116 // (-+-) (++-)
117
118 renderface(5);
119 renderface(4);
120 renderface(3);
121 renderface(2);
122 renderface(1);
123 renderface(0);
124}