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.
38 #include "TextureLoader.h"
40 #include "Displayer.h"
41 #include "MessageManager.h"
43 GLuint
Displayer::message_1x1_list
;
44 GLuint
Displayer::message_2x1_list
;
45 GLuint
Displayer::message_4x1_list
;
46 GLuint
Displayer::message_16x1_list
;
47 GLuint
Displayer::message_texture
;
49 GLubyte
*Displayer::message_texture_data
[DC_NUMBER_MESSAGE_TEX
];
51 GLsizei
Displayer::message_width
[DC_NUMBER_MESSAGE_TEX
]
52 = { 256, 128, 128, 128, 256, 256, 256, 256, 256, 256 };
54 GLsizei
Displayer::message_height
[DC_NUMBER_MESSAGE_TEX
]
55 = { 128, 128, 128, 128, 128, 64, 64, 256, 256, 256 };
57 GLfloat
Displayer::message_alpha
[DC_MESSAGE_PULSE_PERIOD
];
59 int Displayer::message_shape
[DC_NUMBER_MESSAGE_TEX
]
60 = { MS_2x1
, MS_1x1
, MS_1x1
, MS_1x1
, MS_2x1
,
61 MS_4x1
, MS_4x1
, MS_1x1
, MS_1x1
, MS_1x1
};
63 void Displayer::generateMessages ( )
65 // load count down messages
66 message_texture_data
[MS_COUNT_DOWN_1
]
67 = TextureLoader::loadAlphaTGA(GC_COUNT_DOWN_1_TEX_FILE_NAME
,
68 message_height
[MS_COUNT_DOWN_1
], message_width
[MS_COUNT_DOWN_1
]);
69 message_texture_data
[MS_COUNT_DOWN_2
]
70 = TextureLoader::loadAlphaTGA(GC_COUNT_DOWN_2_TEX_FILE_NAME
,
71 message_height
[MS_COUNT_DOWN_2
], message_width
[MS_COUNT_DOWN_2
]);
72 message_texture_data
[MS_COUNT_DOWN_3
]
73 = TextureLoader::loadAlphaTGA(GC_COUNT_DOWN_3_TEX_FILE_NAME
,
74 message_height
[MS_COUNT_DOWN_3
], message_width
[MS_COUNT_DOWN_3
]);
75 message_texture_data
[MS_COUNT_DOWN_GO
]
76 = TextureLoader::loadAlphaTGA(GC_COUNT_DOWN_GO_TEX_FILE_NAME
,
77 message_height
[MS_COUNT_DOWN_GO
], message_width
[MS_COUNT_DOWN_GO
]);
78 message_texture_data
[MS_ANYKEY
]
79 = TextureLoader::loadAlphaTGA(GC_ANYKEY_TEX_FILE_NAME
,
80 message_height
[MS_ANYKEY
], message_width
[MS_ANYKEY
]);
81 message_texture_data
[MS_WAITING
]
82 = TextureLoader::loadAlphaTGA(GC_WAITING_TEX_FILE_NAME
,
83 message_height
[MS_WAITING
], message_width
[MS_WAITING
]);
84 message_texture_data
[MS_PAUSED
]
85 = TextureLoader::loadAlphaTGA(GC_PAUSED_TEX_FILE_NAME
,
86 message_height
[MS_PAUSED
], message_width
[MS_PAUSED
]);
87 message_texture_data
[MS_WINNER
]
88 = TextureLoader::loadAlphaTGA(GC_WINNER_TEX_FILE_NAME
,
89 message_height
[MS_WINNER
], message_width
[MS_WINNER
]);
90 message_texture_data
[MS_LOSER
]
91 = TextureLoader::loadAlphaTGA(GC_LOSER_TEX_FILE_NAME
,
92 message_height
[MS_LOSER
], message_width
[MS_LOSER
]);
93 message_texture_data
[MS_GAME_OVER
]
94 = TextureLoader::loadAlphaTGA(GC_GAME_OVER_TEX_FILE_NAME
,
95 message_height
[MS_GAME_OVER
], message_width
[MS_GAME_OVER
]);
97 // generic message lists
99 message_1x1_list
= glGenLists(1);
101 glNewList(message_1x1_list
, GL_COMPILE
);
102 glBegin(GL_TRIANGLE_STRIP
);
104 glTexCoord2f(0.0f
, 1.0f
);
105 glVertex3f(-1.0f
, -1.0f
, 0.0f
);
106 glTexCoord2f(1.0f
, 1.0f
);
107 glVertex3f(1.0f
, -1.0f
, 0.0f
);
108 glTexCoord2f(0.0f
, 0.0f
);
109 glVertex3f(-1.0f
, 1.0f
, 0.0f
);
110 glTexCoord2f(1.0f
, 0.0f
);
111 glVertex3f(1.0f
, 1.0f
, 0.0f
);
116 message_2x1_list
= glGenLists(1);
118 glNewList(message_2x1_list
, GL_COMPILE
);
119 glBegin(GL_TRIANGLE_STRIP
);
121 glTexCoord2f(0.0f
, 1.0f
);
122 glVertex3f(-1.0f
, -0.5f
, 0.0f
);
123 glTexCoord2f(1.0f
, 1.0f
);
124 glVertex3f(1.0f
, -0.5f
, 0.0f
);
125 glTexCoord2f(0.0f
, 0.0f
);
126 glVertex3f(-1.0f
, 0.5f
, 0.0f
);
127 glTexCoord2f(1.0f
, 0.0f
);
128 glVertex3f(1.0f
, 0.5f
, 0.0f
);
133 message_4x1_list
= glGenLists(1);
135 glNewList(message_4x1_list
, GL_COMPILE
);
136 glBegin(GL_TRIANGLE_STRIP
);
138 glTexCoord2f(0.0f
, 1.0f
);
139 glVertex3f(-1.0f
, -0.25f
, 0.0f
);
140 glTexCoord2f(1.0f
, 1.0f
);
141 glVertex3f(1.0f
, -0.25f
, 0.0f
);
142 glTexCoord2f(0.0f
, 0.0f
);
143 glVertex3f(-1.0f
, 0.25f
, 0.0f
);
144 glTexCoord2f(1.0f
, 0.0f
);
145 glVertex3f(1.0f
, 0.25f
, 0.0f
);
150 message_16x1_list
= glGenLists(1);
152 glNewList(message_16x1_list
, GL_COMPILE
);
153 glBegin(GL_TRIANGLE_STRIP
);
155 glTexCoord2f(0.0f
, 1.0f
);
156 glVertex3f(-1.0f
, -0.125f
, 0.0f
);
157 glTexCoord2f(1.0f
, 1.0f
);
158 glVertex3f(1.0f
, -0.125, 0.0f
);
159 glTexCoord2f(0.0f
, 0.0f
);
160 glVertex3f(-1.0f
, 0.125, 0.0f
);
161 glTexCoord2f(1.0f
, 0.0f
);
162 glVertex3f(1.0f
, 0.125, 0.0f
);
167 // pulsing alpha values
168 for (int n
= DC_MESSAGE_PULSE_PERIOD
; n
--; ) {
169 float s
= cos(n
* (2.0f
* PI
/ (float) DC_MESSAGE_PULSE_PERIOD
));
170 message_alpha
[n
] = 0.75f
+ 0.6f
* s
* s
;