|
AnoPlib - Animlets are not Particles library
|
#include <GL/glut.h>#include <stdio.h>#include <string.h>#include <algorithm>#include <AnoP.h>#include <AnoPhelpers.h>#include <math.h>#include <iostream>#include <vector>#include <AnoPemergency1.h>#include <AnoPflashlight1.h>#include <AnoPstarfield1.h>#include <AnoPtentacle1.h>#include <AnoPwavelogo1.h>#include <AnoPwavepropagation1.h>Go to the source code of this file.
Functions | |
| void | createMenu (void) |
| void | display (void) |
| void | init () |
| int | main (int argc, char **argv) |
| void | menu (int value) |
Variables | |
| vector< AnoP::AnoPsystemBase * > | anop |
| string | anopText [] |
| int | currentTime |
| int | frame = 0 |
| char | s [11] |
| int | shown = 0 |
| int | timebase = 0 |
| int | win |
| void createMenu | ( | void | ) |
Definition at line 149 of file AnoPtest.cpp.
References menu().
Referenced by main().
{
glutCreateMenu(menu);
glutAddMenuEntry("Wireless#1", 1);
glutAddMenuEntry("Wave Logo#1", 2);
glutAddMenuEntry("Starfield#1", 3);
glutAddMenuEntry("Emergency#1", 4);
glutAddMenuEntry("Signal#1", 5);
glutAddMenuEntry("Tentacle#1", 6);
glutAddMenuEntry("Quit", 0);
glutAttachMenu(GLUT_RIGHT_BUTTON);
}
| void display | ( | void | ) |
Definition at line 113 of file AnoPtest.cpp.
References anop, currentTime, frame, s, shown, and timebase.
Referenced by main().
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
anop[shown]->renderAll(0, 0);
frame++;
currentTime=glutGet(GLUT_ELAPSED_TIME);
if (currentTime - timebase > 1000) {
sprintf(s,"FPS:%4.2f", frame*1000.0/(currentTime-timebase));
timebase = currentTime;
frame = 0;
}
glutSetWindowTitle( s );
glutSwapBuffers();
}
| void init | ( | ) |
Definition at line 130 of file AnoPtest.cpp.
Referenced by main().
{
/* Enable a single OpenGL light. */
glDisable(GL_LIGHT0);
glDisable(GL_LIGHTING);
/* Use depth buffering for hidden surface elimination. */
glEnable(GL_DEPTH_TEST);
glEnable(GL_ALPHA_TEST);
/* Setup the view of the cube. */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslated(-1,-1,0);
glScaled(1./20, 1./20, 1.);
glTranslated(0,15,0);
}
| int main | ( | int | argc, |
| char ** | argv | ||
| ) |
Definition at line 166 of file AnoPtest.cpp.
References AnoP::AnoPsystem< T >::addAnimlet(), anop, anopText, AnoPhelpers::close(), createMenu(), display(), init(), starfield1Struct::pos, wireless1Struct::pos, emergency1Struct::pos, flashSignal1Struct::pos, waveStruct::pos, s, starfield1Struct::speed, waveStruct::step, wireless1Struct::step, emergency1Struct::step, flashSignal1Struct::step, and win.
{
AnoPhelpers::init();
// wireless effect
AnoPwavepropagation1 *awp = new AnoPwavepropagation1(5);
for(int i=0; i<5; ++i) {
wireless1Struct s;
s.pos[0] = (double) rand() / (double) (RAND_MAX-1) * 400.;
s.pos[1] = (double) rand() / (double) (RAND_MAX-1) * 400.;
s.step = (double) rand() / (double) (RAND_MAX-1) * 500.;
awp->addAnimlet(s);
}
anop.push_back(awp);
// wave effect
AnoPwavelogo1 *awl = new AnoPwavelogo1(1);
for(unsigned int y=0; y<10; ++y) {
for(unsigned int x=0; x<anopText[y].length(); ++x) {
if(anopText[y][x]!=' ') {
waveStruct s;
s.step = ((x+y)*10)%360;
s.pos[0] = x;
s.pos[1] = 10-y;
awl->addAnimlet(s);
}
}
}
anop.push_back(awl);
// starfield effect
AnoPstarfield1 *asf = new AnoPstarfield1(1000);
for(int i=0; i<1000; ++i) {
starfield1Struct s;
s.pos[0] = (double) rand() / (double) (RAND_MAX-1) * 40.;
s.pos[1] = (double) rand() / (double) (RAND_MAX-1) * 10.;
s.speed = (double) rand() / (double) (RAND_MAX-1) * .1;
asf->addAnimlet(s);
}
anop.push_back(asf);
// emergency effect
AnoPemergency1 *ae = new AnoPemergency1(10);
for(int i=0; i<10; ++i) {
emergency1Struct s;
s.pos[0] = (double) rand() / (double) (RAND_MAX-1) * 400.;
s.pos[1] = (double) rand() / (double) (RAND_MAX-1) * 400.;
s.step = (double) rand() / (double) (RAND_MAX-1) * 360.;
ae->addAnimlet(s);
}
anop.push_back(ae);
// red signal effect
AnoPflashlight1 *afl = new AnoPflashlight1(40);
for(int i=0; i<40; ++i) {
flashSignal1Struct s;
s.pos[0] = 10 * double(i);
s.pos[1] = 10 * double(i);
s.step = i * 10;
afl->addAnimlet(s);
}
anop.push_back(afl);
// tentacle
AnoPtentacle1 *at = new AnoPtentacle1(40);
for(int i=0; i<40; ++i) {
at->addAnimlet(i);
}
anop.push_back(at);
// run
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
win = glutCreateWindow("AnoPlib examples");
glutDisplayFunc(display);
glutIdleFunc(display);
createMenu();
glClearColor(0.0,0.0,0.0,0.0);
init();
glutMainLoop();
AnoPhelpers::close();
return 0;
}
| void menu | ( | int | value | ) |
Definition at line 101 of file AnoPtest.cpp.
Referenced by createMenu().
| vector<AnoP::AnoPsystemBase*> anop |
Definition at line 86 of file AnoPtest.cpp.
| string anopText[] |
{
" xxxx xx xx xxxx xxxxx ",
" xxxxxx xx xx xxxxxx xxxxxx ",
" xx xx xxx xx xx xx xx xx ",
" xx xx xxx xx xx xx xx xx ",
" xxxxxx xxxxxx xx xx xxxxxx ",
" xxxxxx xxxxxx xx xx xxxxx ",
" xx xx xx xxx xx xx xx ",
" xx xx xx xxx xx xx xx ",
" xx xx xx xx xxxxxx xx ",
" xx xx xx xx xxxx xx "
}
Definition at line 72 of file AnoPtest.cpp.
Referenced by main().
| int currentTime |
Definition at line 92 of file AnoPtest.cpp.
Referenced by display().
| int frame = 0 |
Definition at line 92 of file AnoPtest.cpp.
Referenced by display().
| char s[11] |
Definition at line 95 of file AnoPtest.cpp.
Referenced by display(), AnoPhelpers::drawOutlineCircle2(), main(), AnoPstarfield1::render(), AnoPwavepropagation1::render(), AnoPtentacle1::render(), AnoPwavelogo1::render(), AnoPflashlight1::render(), and AnoPemergency1::render().
| int shown = 0 |
Definition at line 89 of file AnoPtest.cpp.
| int timebase = 0 |
Definition at line 92 of file AnoPtest.cpp.
Referenced by display().
| int win |
Definition at line 69 of file AnoPtest.cpp.