1 /*
2 * clock.cxx
3 * Daniel Nelson - 11/2/0
4 *
5 * Copyright (C) 2000 Daniel Nelson
6 * Copyright (C) 2004 Andrew Sayman
7 *
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.
12 *
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.
17 *
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.
21 *
22 * Daniel Nelson - aluminumangel.org
23 * 174 W. 18th Ave.
24 * Columbus, OH 43210
25 *
26 * Generates the textures for the clock.
27 */
28
29 #include <GL/glut.h>
30
31 #include "glext.h"
32
33 using namespace std;
34
35 #include "TextureLoader.h"
36 #include "Game.h"
37 #include "Displayer.h"
38
39 GLuint Displayer::clock_digit_textures[11];
40
41 const char *clock_digit_texture_files[11]
42 = { GC_DATA_DIRECTORY("clock_0.tga"),
43 GC_DATA_DIRECTORY("clock_1.tga"),
44 GC_DATA_DIRECTORY("clock_2.tga"),
45 GC_DATA_DIRECTORY("clock_3.tga"),
46 GC_DATA_DIRECTORY("clock_4.tga"),
47 GC_DATA_DIRECTORY("clock_5.tga"),
48 GC_DATA_DIRECTORY("clock_6.tga"),
49 GC_DATA_DIRECTORY("clock_7.tga"),
50 GC_DATA_DIRECTORY("clock_8.tga"),
51 GC_DATA_DIRECTORY("clock_9.tga"),
52 GC_DATA_DIRECTORY("clock_extra.tga") };
53
generateClock()54 void Displayer::generateClock ( )
55 {
56 GLubyte *texture;
57
58 glGenTextures(11, clock_digit_textures);
59
60 for (int n = 11; n--; ) {
61
62 glBindTexture(GL_TEXTURE_2D, clock_digit_textures[n]);
63
64 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
65 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
66 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
67 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
68
69 texture = TextureLoader::loadAlphaTGA(clock_digit_texture_files[n],
70 DC_CLOCK_TEX_LENGTH, DC_CLOCK_TEX_LENGTH);
71
72 glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, DC_CLOCK_TEX_LENGTH,
73 DC_CLOCK_TEX_LENGTH, GL_FALSE, GL_ALPHA, GL_UNSIGNED_BYTE, texture);
74
75 if (texture != null) {
76 delete [] texture;
77 texture = null;
78 }
79 }
80 }
81