3 * Daniel Nelson - 10/27/0
5 * Copyright (C) 2000 Daniel Nelson
6 * Copyright (C) 2004 Andrew Sayman
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * Daniel Nelson - aluminumangel.org
26 * Loads the textures that are used in the various signs within the game. These
27 * signs are held in RAM and only made into textures when needed.
37 # include <strstrea.h>
42 #include "TextureLoader.h"
44 #include "Displayer.h"
45 #include "MessageManager.h"
47 GLuint
Displayer::message_1x1_list
;
48 GLuint
Displayer::message_2x1_list
;
49 GLuint
Displayer::message_4x1_list
;
50 GLuint
Displayer::message_16x1_list
;
51 GLuint
Displayer::message_texture
;
53 GLubyte
*Displayer::message_texture_data
[DC_NUMBER_MESSAGE_TEX
];
55 GLsizei
Displayer::message_width
[DC_NUMBER_MESSAGE_TEX
]
56 = { 256, 128, 128, 128, 256, 256, 256, 256, 256, 256 };
58 GLsizei
Displayer::message_height
[DC_NUMBER_MESSAGE_TEX
]
59 = { 128, 128, 128, 128, 128, 64, 64, 256, 256, 256 };
61 GLfloat
Displayer::message_alpha
[DC_MESSAGE_PULSE_PERIOD
];
63 int Displayer::message_shape
[DC_NUMBER_MESSAGE_TEX
]
64 = { MS_2x1
, MS_1x1
, MS_1x1
, MS_1x1
, MS_2x1
,
65 MS_4x1
, MS_4x1
, MS_1x1
, MS_1x1
, MS_1x1
};
67 void Displayer::generateMessages ( )
69 // load count down messages
70 message_texture_data
[MS_COUNT_DOWN_1
]
71 = TextureLoader::loadAlphaTGA(GC_COUNT_DOWN_1_TEX_FILE_NAME
,
72 message_height
[MS_COUNT_DOWN_1
], message_width
[MS_COUNT_DOWN_1
]);
73 message_texture_data
[MS_COUNT_DOWN_2
]
74 = TextureLoader::loadAlphaTGA(GC_COUNT_DOWN_2_TEX_FILE_NAME
,
75 message_height
[MS_COUNT_DOWN_2
], message_width
[MS_COUNT_DOWN_2
]);
76 message_texture_data
[MS_COUNT_DOWN_3
]
77 = TextureLoader::loadAlphaTGA(GC_COUNT_DOWN_3_TEX_FILE_NAME
,
78 message_height
[MS_COUNT_DOWN_3
], message_width
[MS_COUNT_DOWN_3
]);
79 message_texture_data
[MS_COUNT_DOWN_GO
]
80 = TextureLoader::loadAlphaTGA(GC_COUNT_DOWN_GO_TEX_FILE_NAME
,
81 message_height
[MS_COUNT_DOWN_GO
], message_width
[MS_COUNT_DOWN_GO
]);
82 message_texture_data
[MS_ANYKEY
]
83 = TextureLoader::loadAlphaTGA(GC_ANYKEY_TEX_FILE_NAME
,
84 message_height
[MS_ANYKEY
], message_width
[MS_ANYKEY
]);
85 message_texture_data
[MS_WAITING
]
86 = TextureLoader::loadAlphaTGA(GC_WAITING_TEX_FILE_NAME
,
87 message_height
[MS_WAITING
], message_width
[MS_WAITING
]);
88 message_texture_data
[MS_PAUSED
]
89 = TextureLoader::loadAlphaTGA(GC_PAUSED_TEX_FILE_NAME
,
90 message_height
[MS_PAUSED
], message_width
[MS_PAUSED
]);
91 message_texture_data
[MS_WINNER
]
92 = TextureLoader::loadAlphaTGA(GC_WINNER_TEX_FILE_NAME
,
93 message_height
[MS_WINNER
], message_width
[MS_WINNER
]);
94 message_texture_data
[MS_LOSER
]
95 = TextureLoader::loadAlphaTGA(GC_LOSER_TEX_FILE_NAME
,
96 message_height
[MS_LOSER
], message_width
[MS_LOSER
]);
97 message_texture_data
[MS_GAME_OVER
]
98 = TextureLoader::loadAlphaTGA(GC_GAME_OVER_TEX_FILE_NAME
,
99 message_height
[MS_GAME_OVER
], message_width
[MS_GAME_OVER
]);
101 // generic message lists
103 message_1x1_list
= glGenLists(1);
105 glNewList(message_1x1_list
, GL_COMPILE
);
106 glBegin(GL_TRIANGLE_STRIP
);
108 glTexCoord2f(0.0f
, 1.0f
);
109 glVertex3f(-1.0f
, -1.0f
, 0.0f
);
110 glTexCoord2f(1.0f
, 1.0f
);
111 glVertex3f(1.0f
, -1.0f
, 0.0f
);
112 glTexCoord2f(0.0f
, 0.0f
);
113 glVertex3f(-1.0f
, 1.0f
, 0.0f
);
114 glTexCoord2f(1.0f
, 0.0f
);
115 glVertex3f(1.0f
, 1.0f
, 0.0f
);
120 message_2x1_list
= glGenLists(1);
122 glNewList(message_2x1_list
, GL_COMPILE
);
123 glBegin(GL_TRIANGLE_STRIP
);
125 glTexCoord2f(0.0f
, 1.0f
);
126 glVertex3f(-1.0f
, -0.5f
, 0.0f
);
127 glTexCoord2f(1.0f
, 1.0f
);
128 glVertex3f(1.0f
, -0.5f
, 0.0f
);
129 glTexCoord2f(0.0f
, 0.0f
);
130 glVertex3f(-1.0f
, 0.5f
, 0.0f
);
131 glTexCoord2f(1.0f
, 0.0f
);
132 glVertex3f(1.0f
, 0.5f
, 0.0f
);
137 message_4x1_list
= glGenLists(1);
139 glNewList(message_4x1_list
, GL_COMPILE
);
140 glBegin(GL_TRIANGLE_STRIP
);
142 glTexCoord2f(0.0f
, 1.0f
);
143 glVertex3f(-1.0f
, -0.25f
, 0.0f
);
144 glTexCoord2f(1.0f
, 1.0f
);
145 glVertex3f(1.0f
, -0.25f
, 0.0f
);
146 glTexCoord2f(0.0f
, 0.0f
);
147 glVertex3f(-1.0f
, 0.25f
, 0.0f
);
148 glTexCoord2f(1.0f
, 0.0f
);
149 glVertex3f(1.0f
, 0.25f
, 0.0f
);
154 message_16x1_list
= glGenLists(1);
156 glNewList(message_16x1_list
, GL_COMPILE
);
157 glBegin(GL_TRIANGLE_STRIP
);
159 glTexCoord2f(0.0f
, 1.0f
);
160 glVertex3f(-1.0f
, -0.125f
, 0.0f
);
161 glTexCoord2f(1.0f
, 1.0f
);
162 glVertex3f(1.0f
, -0.125, 0.0f
);
163 glTexCoord2f(0.0f
, 0.0f
);
164 glVertex3f(-1.0f
, 0.125, 0.0f
);
165 glTexCoord2f(1.0f
, 0.0f
);
166 glVertex3f(1.0f
, 0.125, 0.0f
);
171 // pulsing alpha values
172 for (int n
= DC_MESSAGE_PULSE_PERIOD
; n
--; ) {
173 float s
= cos(n
* (2.0f
* PI
/ (float) DC_MESSAGE_PULSE_PERIOD
));
174 message_alpha
[n
] = 0.75f
+ 0.6f
* s
* s
;