Exemple #1
0
//
//  Initialize
//
void Ex04opengl::initializeGL()
{
   if (init) return;
   init = true;

   //  Load shaders
   Shader(1,"",":/ex04a.frag");
   Shader(2,":/ex04b.vert",":/ex04b.frag");
   Shader(3,":/ex04c.vert",":/ex04c.frag");
   Shader(4,":/ex04d.vert",":/ex04d.frag");
   Shader(5,":/ex04e.vert",":/ex04e.frag");

   // Cube
   Cube* cube = new Cube();
   cube->texture(":/crate.png");
   objects.push_back(cube);

   // Teapot
   Teapot* pot = new Teapot(8);
   pot->scale(0.5);
   pot->texture(":/pi.png");
   objects.push_back(pot);

   // Cruiser
   WaveOBJ* cruiser=0;
   try
   {
      cruiser = new WaveOBJ("cruiser.obj",":/");
   }
   catch (QString err)
   {
      Fatal("Error loading object\n"+err);
   }
   if (cruiser)
   {
      cruiser->color(1,1,0);
      objects.push_back(cruiser);
   }

   //  Set initial object
   obj = objects[0];

   //  Start 100 fps timer connected to updateGL
   move = true;
   timer.setInterval(10);
   connect(&timer,SIGNAL(timeout()),this,SLOT(updateGL()));
   timer.start();
   time.start();
}