Previous attempt to remove some compiler warnings was
[AROS-Contrib.git] / Demo / GLExcess / scene12.cpp
blobcdfd1872aeadd44c4528448e7949b8da9daf7572
1 /*
2 GLExcess v1.0 Demo
3 Copyright (C) 2001-2003 Paolo Martella
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
16 #ifdef WIN32
17 #include <windows.h>
18 #endif
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <math.h>
23 #include <GL/gl.h>
24 #include <GL/glu.h>
25 #include <GL/glut.h>
26 #include "Texture.h"
27 #include "scene12.h"
29 static Texture* k_Text;
30 static GLuint numtexs=7;
31 static GLuint width=800;
32 static GLuint height=600;
33 static bool init=true;
34 static GLfloat k_time=0;
36 static GLfloat k_timer;
38 void k_InitGL()
40 k_Text=new Texture[numtexs];
41 glMatrixMode(GL_PROJECTION);
42 glLoadIdentity();
43 gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
44 glMatrixMode(GL_MODELVIEW);
45 glLoadIdentity();
47 k_Text[1].Load("data/glxcess.raw");
48 k_Text[2].Load("data/cl.raw");
49 k_Text[3].Load("data/glxcesss.raw");
50 k_Text[4].Load("data/crite.raw");
51 k_Text[5].Load("data/lightmask.raw");
52 k_Text[6].Load("data/cl2.raw");
53 glShadeModel(GL_FLAT);
54 glClearColor(.5f, 0.3f, 0.2f, 0.0f);
55 glClearColor(.0f, .0f, .0f, 0.0f);
56 glClearDepth(1.0f);
57 glDisable(GL_DEPTH_TEST);
58 glDisable (GL_CULL_FACE);
59 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
60 glPolygonMode(GL_FRONT, GL_FILL);
61 glFrontFace(GL_CCW);
62 glEnable(GL_TEXTURE_2D);
63 glDisable(GL_LIGHTING);
64 glEnable(GL_BLEND);
65 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
68 void k_Clean(void)
70 k_Text[1].Kill();
71 k_Text[2].Kill();
72 k_Text[3].Kill();
73 k_Text[4].Kill();
74 k_Text[5].Kill();
75 k_Text[6].Kill();
76 delete [] k_Text;
77 init=true;
80 void k_drawrect(GLfloat b,GLfloat h)
82 glBegin(GL_QUADS);
83 glTexCoord2f(0.0f,0.0f);
84 glVertex3f(-b/2,-h/2,0.0f);
85 glTexCoord2f(1.0f,0.0f);
86 glVertex3f(b/2,-h/2,0.0f);
87 glTexCoord2f(1.0f,1.0f);
88 glVertex3f(b/2,h/2,0.0f);
89 glTexCoord2f(0.0f,1.0f);
90 glVertex3f(-b/2,h/2,0.0f);
91 glEnd();
94 void k_drawrect1(GLfloat b,GLfloat h,GLfloat shifta,GLfloat shiftb)
96 glBegin(GL_QUADS);
97 glTexCoord2f(0.0f+shifta,0.0f+shiftb);
98 glVertex3f(-b/2,-h/2,0.0f);
99 glTexCoord2f(1.5f+shifta,0.0f+shiftb);
100 glVertex3f(b/2,-h/2,0.0f);
101 glTexCoord2f(1.5f+shifta,1.5f+shiftb);
102 glVertex3f(b/2,h/2,0.0f);
103 glTexCoord2f(0.0f+shifta,1.5f+shiftb);
104 glVertex3f(-b/2,h/2,0.0f);
105 glEnd();
108 bool k_DrawGLScene(GLfloat globtime)
110 if (init) {k_InitGL();init=false;}
111 k_time=10*globtime;
113 glClear(GL_COLOR_BUFFER_BIT);
114 k_timer=-1.0f+(k_time)/5000.0f;
116 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
117 k_Text[2].Use();
118 glLoadIdentity();
119 glTranslatef(0,0,-5.0f);
120 k_timer+=3;
121 glPushMatrix();
122 //glColor4f(1,1,1,.15+.05*sin(k_timer/13.0f));
123 glColor4f(1,1,1,.25+.25*sin(k_timer/13.0f));
124 glRotatef(20*sin(k_timer*2.0),1,0,0);
125 glRotatef(90*sin(k_timer),0,0,1);
126 k_drawrect1(8.5,8.5,k_timer/10.0f,.25f-k_timer/5.0f);
127 glPopMatrix();
129 //k_Text[2].Use();
130 glPushMatrix();
131 glRotatef(k_timer*10.0,0,0,1);
132 glTranslatef(0,0,2.0f*sin(k_timer/1.0f));
133 //glColor4f(1,1,1,.1+.1*cos(k_timer/9.0f));
134 glColor4f(1,1,1,.3+.3*cos(k_timer/9.0f));
135 k_drawrect1(10,10,.5f-k_timer/7.5f,.75f+k_timer/2.5f);
136 glPopMatrix();
138 glPushMatrix();
139 //k_Text[6].Use();
140 glBlendFunc(GL_ZERO,GL_ONE_MINUS_SRC_COLOR);
141 //glColor4f(.75,.75,.75,.5);
142 glColor4f(1,1,1,1);
143 glTranslatef(0,0,2.0f*sin(k_timer/1.0f));
144 glRotatef(k_timer*20.0,0,0,1);
145 glTranslatef(0,0,1+2.0f*sin(k_timer/2.0f)*sin(k_timer/1.0f));
146 k_drawrect1(10,10,.35f-k_timer/10.0f,.1f+k_timer/25.0f);
147 glPopMatrix();
148 k_timer-=3;
149 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
150 k_Text[1].Use();
151 /////////////////////////////////////////////////////////////////////////////////
152 /////////////////////////////////////////////////////////////////////////////////
153 /////////////////////////////////////////////////////////////////////////////////
154 /////////////////////////////////////////////////////////////////////////////////
155 /////////////////////////////////////////////////////////////////////////////////
156 /////////////////////////////////////////////////////////////////////////////////
157 glLoadIdentity();
158 if (k_timer<2.501f) glTranslatef(0,0,-7.0f+3.0f*sin(k_timer*3.1415f*.5f/2.5f));
159 else glTranslatef(0,0,-4.0f);
161 if(k_timer<2.5f)
163 glPushMatrix();
164 if (k_timer<=1.0f)
166 k_Text[3].Use();
167 glColor4f(k_timer,k_timer,k_timer,1);
168 glBlendFunc(GL_ZERO,GL_ONE_MINUS_SRC_COLOR);
169 k_drawrect(4.2,1.7);
170 k_Text[1].Use();
171 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
172 glColor4f(1,1,1,k_timer);
173 k_drawrect(3.5,1);
175 else
176 if (k_timer<1.1f)
178 k_Text[3].Use();
179 glColor4f(1.0f-10.0f*(k_timer-1.0f),1.0f-10.0f*(k_timer-1.0f),1.0f-10.0f*(k_timer-1.0f),1);
180 glBlendFunc(GL_ZERO,GL_ONE_MINUS_SRC_COLOR);
181 k_drawrect(4.2,1.7);
182 k_Text[1].Use();
183 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
184 glColor4f(1,1,1,20.0f*(k_timer-1.0f));
185 glTranslatef(0,0,15000.0f*(k_timer-1.0f)*(k_timer-1.0f)*(k_timer-1.0f)*(k_timer-1.0f));
186 k_drawrect(3.5,1);
188 else
190 GLfloat j_tras=(1.0f+sin((-k_timer+1.1f)*.5*3.1415f/1.4f));
191 glTranslatef(0,0,1.5*j_tras);
192 glColor4f(1,1,1,j_tras);
193 k_drawrect(3.5,1);
195 glPopMatrix();
198 if (k_timer>=1.0f)
200 if (k_timer<1.1f)
202 glColor4f(1,1,1,1.0f-10.0f*(k_timer-1.0f));
203 k_drawrect(3.5,1);
205 else
207 glPushMatrix();
208 if (k_timer<2.5f)
210 GLfloat j_tras=-sin((-k_timer+1.1f)*.5*3.1415f/1.4f);
211 k_Text[1].Use();
212 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
213 glColor4f(1,1,1,j_tras);
214 k_drawrect(3.5,1);
216 else
218 k_Text[3].Use();
219 glColor4f(2.0f*(k_timer-2.5f),2.0f*(k_timer-2.5f),2.0f*(k_timer-2.5f),1);
220 glBlendFunc(GL_ZERO,GL_ONE_MINUS_SRC_COLOR);
221 k_drawrect(4.2,1.7);
222 k_Text[1].Use();
223 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
224 glColor4f(1,1,1,1);
225 k_drawrect(3.5,1);
227 glPopMatrix();
231 if (k_timer<0.0f)
233 glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_ALPHA);
234 glDisable(GL_TEXTURE_2D);
235 glColor4f(1,1,1,-k_timer);
236 glLoadIdentity();
237 glTranslatef(0,0,-1.0f);
238 k_drawrect(1.2,1.2);
239 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
240 glEnable(GL_TEXTURE_2D);
244 k_Text[5].Use();
245 glLoadIdentity();
246 glTranslatef(0,0,-1.0);
247 // if (k_timer<2.501f) glTranslatef(0,0,-7.0f+3.0f*sin(k_timer*3.1415f*.5f/2.5f));
248 // else glTranslatef(0,0,-4.0f);
250 glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
251 glColor4f(1,1,1,1);
252 k_drawrect(1.85,1.25);
253 //k_drawrect(4.8,2.1);
255 glBlendFunc(GL_SRC_ALPHA, GL_ONE);
256 if (k_timer>2.5f)
259 glLoadIdentity();
260 glTranslatef(.03,-.25,-1.0f);
261 k_Text[4].Use();
262 if (k_timer-2.5f<.75f) glColor4f(1,1,1,k_timer-2.5f);
263 else glColor4f(1,1,1,.75f);
264 glScalef(1,-1,1);
265 k_drawrect(1,.03125);
268 if (k_timer>4.0f)
270 glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_ALPHA);
271 glDisable(GL_TEXTURE_2D);
272 glColor4f(1,1,1,(k_timer-4.0f)/3.25f);
273 glLoadIdentity();
274 glTranslatef(0,0,-1.0f);
275 k_drawrect(1.2,1.2);
276 glBlendFunc(GL_SRC_ALPHA,GL_ONE);
277 glEnable(GL_TEXTURE_2D);
279 if (k_timer>7.25f)
281 //*************** FINISH
282 //k_Clean();
283 return false;
285 glutSwapBuffers();
286 return true;