Repository navigation
Expand file tree
/
Copy pathLogoScene.cpp
More file actions
389 lines (300 loc) · 13.9 KB
/
Copy pathLogoScene.cpp
File metadata and controls
389 lines (300 loc) · 13.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
#include "LogoScene.h"
#define MAX_CUBES 200
struct simpleCube {
float pos[2]; // cube x, y position (scaled between -0.5 and 0.5)
float color[3]; // cube color (blue/gray tint
float rotation[3]; // the normalized rotation for the cube
float size; // the size of the cube between 0 and 1
float angle;
};
unsigned int logopic = -1;
unsigned int names = -1;
corona::Image *logoImg = NULL;
static float logoalpha = 0.0;
static float speed = 0.002;
static float angle = 0.0;
float texCoords[][4] = {{0.0, 1.0,0.0}, {0.0, 0.0,0.0}, {1.0, 0.0,0.0}, {1.0, 1.0,0.0}};
bool chgDir = false;
simpleCube *cubes = NULL;
float cubeXPos = -70.0;
PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT = NULL;
PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT = NULL;
PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT = NULL;
PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT = NULL;
PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT = NULL;
PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT = NULL;
PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT = NULL;
PFNGLGENFRAMEBUFFERSEXTPROC glGenRenderbuffersEXT = NULL;
GLuint fb, rb, texid; // framebuffer object, renderbuffer object, and texture id
bool InitLogoScene()
{
logoImg = corona::OpenImage("data/accfilm.jpg");
if(!logoImg)
return false;
glGenTextures(1, &logopic);
glBindTexture(GL_TEXTURE_2D, logopic);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexEnvf(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_COMBINE);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, logoImg->getWidth(), logoImg->getHeight(), GL_RGB, GL_UNSIGNED_BYTE, logoImg->getPixels());
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
delete logoImg;
cubes = new simpleCube[MAX_CUBES];
if(!cubes)
return false;
//initialize all the cubes
for(int n = 0; n < MAX_CUBES; n++)
{
cubes[n].size = (float)rand()/RAND_MAX; // give the cube an arbitrary size
cubes[n].rotation[0] = (float)rand()/RAND_MAX;
cubes[n].rotation[1] = (float)rand()/RAND_MAX;
cubes[n].rotation[2] = (float)rand()/RAND_MAX;
float len = sqrt((cubes[n].rotation[0]*cubes[n].rotation[0])+(cubes[n].rotation[1]*cubes[n].rotation[1])+(cubes[n].rotation[2]*cubes[n].rotation[2]));
cubes[n].rotation[0] /= len; // normalize the vector
cubes[n].rotation[1] /= len;
cubes[n].rotation[2] /= len;
cubes[n].color[0] = 0.89;
cubes[n].color[1] = 0.89;
cubes[n].color[2] = 1.0;
cubes[n].pos[0] = ((rand()%100)+1)-50.0;
cubes[n].pos[1] = (float)rand()/RAND_MAX;
cubes[n].pos[2] = 0.0;
cubes[n].angle = ((float)rand()/RAND_MAX)+45.0;
}
// frame buffer stuff
// get function pointers to the framebuffer functions
glFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) wglGetProcAddress("glFramebufferTexture2DEXT");
glBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) wglGetProcAddress("glBindRenderbufferEXT");
glRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) wglGetProcAddress("glRenderbufferStorageEXT");
glFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) wglGetProcAddress("glFramebufferRenderbufferEXT");
glBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) wglGetProcAddress("glBindFramebufferEXT");
glCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) wglGetProcAddress("glCheckFramebufferStatusEXT");
glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) wglGetProcAddress("glGenFramebuffersEXT");
glGenRenderbuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) wglGetProcAddress("glGenRenderbuffersEXT");
if(!(glFramebufferTexture2DEXT && glBindRenderbufferEXT && glRenderbufferStorageEXT && glFramebufferRenderbufferEXT && glBindFramebufferEXT &&
glCheckFramebufferStatusEXT && glGenFramebuffersEXT && glGenRenderbuffersEXT))
{
return false;
}
glGenFramebuffersEXT(1, &fb);
glGenRenderbuffersEXT(1, &rb);
glGenTextures(1, &texid);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
glBindTexture(GL_TEXTURE_2D, texid);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1024, 128, 0, GL_RGBA, GL_INT, NULL);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texid, 0);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, 1024, 128);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, rb);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); // unbind the framebuffer after setting everything up
GLenum status;
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
switch(status)
{
case GL_FRAMEBUFFER_COMPLETE_EXT: cout << "Framebuffer setup complete" << endl;
break;
case GL_FRAMEBUFFER_UNSUPPORTED_EXT: cout << "Frambuffer format unsupported" << endl;
break;
default:
break;
}
return true;
}
void RenderCubes()
{
for(int n = 0; n < MAX_CUBES; n++)
{
glPushMatrix();
glTranslatef(cubes[n].pos[0], cubes[n].pos[1], cubes[n].pos[2]);
glRotatef(cubes[n].angle, cubes[n].rotation[0], cubes[n].rotation[1], cubes[n].rotation[2]);
glEnable(GL_LIGHTING);
glColor3fv(cubes[n].color);
glBegin(GL_QUADS); // Start Drawing Quads
// Front Face
glNormal3f( 0.0f, 0.0f, 1.0f); // Normal Facing Forward
glVertex3f(-cubes[n].size, -cubes[n].size, cubes[n].size); // Bottom Left Of The Texture and Quad
glVertex3f( cubes[n].size, -cubes[n].size, cubes[n].size); // Bottom Right Of The Texture and Quad
glVertex3f( cubes[n].size, cubes[n].size, cubes[n].size); // Top Right Of The Texture and Quad
glVertex3f(-cubes[n].size, cubes[n].size, cubes[n].size); // Top Left Of The Texture and Quad
// Back Face
glNormal3f( 0.0f, 0.0f,-1.0f); // Normal Facing Away
glVertex3f(-cubes[n].size, -cubes[n].size, -cubes[n].size); // Bottom Right Of The Texture and Quad
glVertex3f(-cubes[n].size, cubes[n].size, -cubes[n].size); // Top Right Of The Texture and Quad
glVertex3f( cubes[n].size, cubes[n].size, -cubes[n].size); // Top Left Of The Texture and Quad
glVertex3f( cubes[n].size, -cubes[n].size, -cubes[n].size); // Bottom Left Of The Texture and Quad
// Top Face
glNormal3f( 0.0f, 1.0f, 0.0f); // Normal Facing Up
glVertex3f(-cubes[n].size, cubes[n].size, -cubes[n].size); // Top Left Of The Texture and Quad
glVertex3f(-cubes[n].size, cubes[n].size, cubes[n].size); // Bottom Left Of The Texture and Quad
glVertex3f(cubes[n].size, cubes[n].size, cubes[n].size); // Bottom Right Of The Texture and Quad
glVertex3f(cubes[n].size, cubes[n].size, -cubes[n].size); // Top Right Of The Texture and Quad
// Bottom Face
glNormal3f( 0.0f,-1.0f, 0.0f); // Normal Facing Down
glVertex3f(-cubes[n].size, -cubes[n].size, -cubes[n].size); // Top Right Of The Texture and Quad
glVertex3f( cubes[n].size, -cubes[n].size, -cubes[n].size); // Top Left Of The Texture and Quad
glVertex3f( cubes[n].size, -cubes[n].size, cubes[n].size); // Bottom Left Of The Texture and Quad
glVertex3f(-cubes[n].size, -cubes[n].size, cubes[n].size); // Bottom Right Of The Texture and Quad
// Right face
glNormal3f( 1.0f, 0.0f, 0.0f); // Normal Facing Right
glVertex3f( cubes[n].size, -cubes[n].size, -cubes[n].size); // Bottom Right Of The Texture and Quad
glVertex3f( cubes[n].size, cubes[n].size, -cubes[n].size); // Top Right Of The Texture and Quad
glVertex3f( cubes[n].size, cubes[n].size, cubes[n].size); // Top Left Of The Texture and Quad
glVertex3f( cubes[n].size, -cubes[n].size, cubes[n].size); // Bottom Left Of The Texture and Quad
// Left Face
glNormal3f(-1.0f, 0.0f, 0.0f); // Normal Facing Left
glVertex3f(-cubes[n].size, -cubes[n].size, -cubes[n].size); // Bottom Left Of The Texture and Quad
glVertex3f(-cubes[n].size, -cubes[n].size, cubes[n].size); // Bottom Right Of The Texture and Quad
glVertex3f(-cubes[n].size, cubes[n].size, cubes[n].size); // Top Right Of The Texture and Quad
glVertex3f(-cubes[n].size, cubes[n].size, -cubes[n].size); // Top Left Of The Texture and Quad
glEnd();
glDisable(GL_LIGHTING);
//Draw the box outlines
glPushAttrib(GL_HINT_BIT);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glLineWidth(0.2);
glEnable(GL_LINE_SMOOTH);
glColor3f(0.3, 0.3, 0.3);
glBegin(GL_LINES); // Start Drawing Quads
// Front Face
glVertex3f(-cubes[n].size, -cubes[n].size, cubes[n].size); // Bottom Left Of The Texture and Quad
glVertex3f( cubes[n].size, -cubes[n].size, cubes[n].size); // Bottom Right Of The Texture and Quad
glVertex3f( cubes[n].size, cubes[n].size, cubes[n].size); // Top Right Of The Texture and Quad
glVertex3f(-cubes[n].size, cubes[n].size, cubes[n].size); // Top Left Of The Texture and Quad
// Back Face
glVertex3f(-cubes[n].size, -cubes[n].size, -cubes[n].size); // Bottom Right Of The Texture and Quad
glVertex3f(-cubes[n].size, cubes[n].size, -cubes[n].size); // Top Right Of The Texture and Quad
glVertex3f( cubes[n].size, cubes[n].size, -cubes[n].size); // Top Left Of The Texture and Quad
glVertex3f( cubes[n].size, -cubes[n].size, -cubes[n].size); // Bottom Left Of The Texture and Quad
// Top Face
glVertex3f(-cubes[n].size, cubes[n].size, -cubes[n].size); // Top Left Of The Texture and Quad
glVertex3f(-cubes[n].size, cubes[n].size, cubes[n].size); // Bottom Left Of The Texture and Quad
glVertex3f(cubes[n].size, cubes[n].size, cubes[n].size); // Bottom Right Of The Texture and Quad
glVertex3f(cubes[n].size, cubes[n].size, -cubes[n].size); // Top Right Of The Texture and Quad
// Bottom Face
glVertex3f(-cubes[n].size, -cubes[n].size, -cubes[n].size); // Top Right Of The Texture and Quad
glVertex3f( cubes[n].size, -cubes[n].size, -cubes[n].size); // Top Left Of The Texture and Quad
glVertex3f( cubes[n].size, -cubes[n].size, cubes[n].size); // Bottom Left Of The Texture and Quad
glVertex3f(-cubes[n].size, -cubes[n].size, cubes[n].size); // Bottom Right Of The Texture and Quad
// Right face
glVertex3f( cubes[n].size, -cubes[n].size, -cubes[n].size); // Bottom Right Of The Texture and Quad
glVertex3f( cubes[n].size, cubes[n].size, -cubes[n].size); // Top Right Of The Texture and Quad
glVertex3f( cubes[n].size, cubes[n].size, cubes[n].size); // Top Left Of The Texture and Quad
glVertex3f( cubes[n].size, -cubes[n].size, cubes[n].size); // Bottom Left Of The Texture and Quad
// Left Face
glVertex3f(-cubes[n].size, -cubes[n].size, -cubes[n].size); // Bottom Left Of The Texture and Quad
glVertex3f(-cubes[n].size, -cubes[n].size, cubes[n].size); // Bottom Right Of The Texture and Quad
glVertex3f(-cubes[n].size, cubes[n].size, cubes[n].size); // Top Right Of The Texture and Quad
glVertex3f(-cubes[n].size, cubes[n].size, -cubes[n].size); // Top Left Of The Texture and Quad
glEnd();
glPopMatrix();
glPopAttrib();
glDisable(GL_LINE_SMOOTH);
cubes[n].angle += 0.1;
if(cubes[n].angle > 360.0)
cubes[n].angle = 0.0;
}
}
int DrawLogoScene(float t)
{
float seconds = fabs((t-tStart))*1000.0;
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0, 0.0, 10.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
if((seconds >= 167000.001)) //&& (seconds < 230000.001))
{
texCoords[0][0] += speed;
texCoords[1][0] += speed;
texCoords[2][0] += speed;
texCoords[3][0] += speed;
if((seconds > 169000.001))
{
glEnable(GL_BLEND);
glEnable(GL_TEXTURE);
glEnable(GL_TEXTURE_2D);
beginOrtho(800, 600);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture(GL_TEXTURE_2D, logopic);
glPushMatrix();
glTranslatef(0.0,0.0,0.0);
glBegin(GL_TRIANGLE_FAN);
glColor4f(0.5,0.5,0.5,logoalpha);
glTexCoord3fv(texCoords[0]); glVertex3f(0.0,210.0,0.0);
glTexCoord3fv(texCoords[1]); glVertex3f(0.0,330.0,0.0);
glTexCoord3fv(texCoords[2]); glVertex3f(805.0,330.0,0.0);
glTexCoord3fv(texCoords[3]); glVertex3f(805.0,210.0,0.0);
glEnd();
glPopMatrix();
if((seconds >= 169000.0001) && (seconds < 175000.0001))
{
logoalpha += (t*1000)/5000.00;
}
endOrtho();
glDisable(GL_BLEND);
glDisable(GL_TEXTURE);
glDisable(GL_TEXTURE_2D);
}
if(seconds >= 171000.0001)
{
glPushAttrib(GL_VIEWPORT_BIT);
glViewport(0, 0, 800, 228); // change the viewport to the size of the texture
// enable the frame buffer object
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslatef(cubeXPos, -6.0, -18.0);
RenderCubes(); // render the cubes
glPopMatrix();
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); // disable the frame buffer object so the texture can be enabled
glBindTexture(GL_TEXTURE_2D, texid); // bind the texture that the frame buffer rendered
glPopAttrib();
glClearColor(0.0,0.0,0.0,0.0);
beginOrtho(800, 600); // begin orthographic projecetion
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE);
glEnable(GL_TEXTURE_2D);
glPushMatrix(); // render the texture
glTranslatef(0.0, 0.0, 0.8);
glBegin(GL_TRIANGLE_FAN);
glColor4f(1.0, 1.0, 1.0, 1.0);
glTexCoord2d(0.0, 1.0); glVertex3f(0.0,210.0,0.0);
glTexCoord2d(0.0, 0.0); glVertex3f(0.0,330.0,0.0);
glTexCoord2d(1.0, 0.0); glVertex3f(1290.0,330.0,0.0);
glTexCoord2d(1.0, 1.0); glVertex3f(1290.0,210.0,0.0);
glEnd();
glPopMatrix();
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
glEnable(GL_DEPTH_TEST);
endOrtho(); // end orthographic projecetion
cubeXPos += (t*1000)/1100.00;
angle += (360.0*(t*1000))/(10000);
}
}
return 1;
}
/*
GREETINGS LIST
---------------
mups
Truck
Damones
Byterapers
MFX
Kewelers
Paradox
FLT
TRSI
Farbrausch
Perkele
Anansmurska
Sceners from around the world!!
Fuckings to Lamers
*/