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