1 /*
2  * garbage_thick_corner.cxx
3  * Daniel Nelson - 9/1/0
4  *
5  * Copyright (C) 2000  Daniel Nelson
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20  *
21  * Daniel Nelson - aluminumangel.org
22  * 174 W. 18th Ave.
23  * Columbus, OH  43210
24  *
25  * Generates a display list for the corner of thick garbage.
26  */
27 
28 #include <GL/glut.h>
29 
30 #include "glext.h"
31 
32 using namespace std;
33 
34 #include "Game.h"
35 #include "Displayer.h"
36 
37 GLuint Displayer::garbage_thick_corner_list;
38 
generateGarbageThickCornerList()39 void Displayer::generateGarbageThickCornerList (   )
40 {
41   garbage_thick_corner_list = glGenLists(1);
42 
43   glEnableClientState(GL_VERTEX_ARRAY);
44   glEnableClientState(GL_NORMAL_ARRAY);
45   glEnableClientState(GL_TEXTURE_COORD_ARRAY);
46 
47   glNewList(garbage_thick_corner_list, GL_COMPILE);
48 
49     GLfloat vertices_0[3 * 12] =
50     {
51       1.0f, -1.0f, -1.0f,
52       -0.8f, -1.0f, -1.0f,
53       1.0f, 0.8f, -1.0f,
54       -0.8f, 0.8f, -1.0f,
55       1.0f, 1.0f, -0.8f,
56       -0.8f, 1.0f, -0.8f,
57       1.0f, 1.0f, 0.8f,
58       -0.8f, 1.0f, 0.8f,
59       1.0f, 0.8f, 1.0f,
60       -0.8f, 0.8f, 1.0f,
61       1.0f, -1.0f, 1.0f,
62       -0.8f, -1.0f, 1.0f
63     };
64 
65     GLfloat vertices_1[3 * 8] =
66     {
67       -0.8f, -1.0f, -1.0f,
68       -1.0f, -1.0f, -0.8f,
69       -0.8f, 0.8f, -1.0f,
70       -1.0f, 0.8f, -0.8f,
71       -0.8f, 1.0f, -0.8f,
72       -1.0f, 0.8f, 0.8f,
73       -0.8f, 1.0f, 0.8f,
74       -0.8f, 0.8f, 1.0f
75     };
76 
77     GLfloat vertices_2[3 * 6] =
78     {
79       -1.0f, 0.8f, -0.8f,
80       -1.0f, -1.0f, -0.8f,
81       -1.0f, 0.8f, 0.8f,
82       -1.0f, -1.0f, 0.8f,
83       -0.8f, 0.8f, 1.0f,
84       -0.8f, -1.0f, 1.0f
85     };
86 
87     GLfloat normals_0[3 * 12] =
88     {
89       0.0f, 0.0f, -1.0f,
90       0.0f, 0.0f, -1.0f,
91       0.0f, 0.0f, -1.0f,
92       0.0f, 0.0f, -1.0f,
93       0.0f, 1.0f, 0.0f,
94       0.0f, 1.0f, 0.0f,
95       0.0f, 1.0f, 0.0f,
96       0.0f, 1.0f, 0.0f,
97       0.0f, 0.0f, 1.0f,
98       0.0f, 0.0f, 1.0f,
99       0.0f, 0.0f, 1.0f,
100       0.0f, 0.0f, 1.0f
101     };
102 
103     GLfloat normals_1[3 * 8] =
104     {
105       0.0f, 0.0f, -1.0f,
106       -1.0f, 0.0f, 0.0f,
107       0.0f, 0.0f, -1.0f,
108       -1.0f, 0.0f, 0.0f,
109       0.0f, 1.0f, 0.0f,
110       -1.0f, 0.0f, 0.0f,
111       0.0f, 1.0f, 0.0f,
112       0.0f, 0.0f, 1.0f
113     };
114 
115     GLfloat normals_2[3 * 6] =
116     {
117       -1.0f, 0.0f, 0.0f,
118       -1.0f, 0.0f, 0.0f,
119       -1.0f, 0.0f, 0.0f,
120       -1.0f, 0.0f, 0.0f,
121       0.0f, 0.0f, 1.0f,
122       0.0f, 0.0f, 1.0f
123     };
124 
125     GLfloat tex_coords_0[3 * 12];
126     for (int n = 3 * 12; n--; )
127       tex_coords_0[n] = vertices_0[n] * DC_GARBAGE_LIGHTMAP_COORD_CONVERTER;
128 
129     GLfloat tex_coords_1[3 * 8];
130     for (int n = 3 * 8; n--; )
131       tex_coords_1[n] = vertices_1[n] * DC_GARBAGE_LIGHTMAP_COORD_CONVERTER;
132 
133     GLfloat tex_coords_2[3 * 6];
134     for (int n = 3 * 6; n--; )
135       tex_coords_2[n] = vertices_2[n] * DC_GARBAGE_LIGHTMAP_COORD_CONVERTER;
136 
137     glVertexPointer(3, GL_FLOAT, 0, vertices_0);
138     glNormalPointer(GL_FLOAT, 0, normals_0);
139     glTexCoordPointer(3, GL_FLOAT, 0, tex_coords_0);
140     glDrawArrays(GL_TRIANGLE_STRIP, 0, 12);
141 
142     glVertexPointer(3, GL_FLOAT, 0, vertices_1);
143     glNormalPointer(GL_FLOAT, 0, normals_1);
144     glTexCoordPointer(3, GL_FLOAT, 0, tex_coords_1);
145     glDrawArrays(GL_TRIANGLE_STRIP, 0, 8);
146 
147     glVertexPointer(3, GL_FLOAT, 0, vertices_2);
148     glNormalPointer(GL_FLOAT, 0, normals_2);
149     glTexCoordPointer(3, GL_FLOAT, 0, tex_coords_2);
150     glDrawArrays(GL_TRIANGLE_STRIP, 0, 6);
151 
152   glEndList();
153 
154   glDisableClientState(GL_VERTEX_ARRAY);
155   glDisableClientState(GL_NORMAL_ARRAY);
156   glDisableClientState(GL_TEXTURE_COORD_ARRAY);
157 }
158