AllegroFlasher::AllegroFlasher(const int w, const int h):
	//FPS(2*freq),
    width(w),
    height(h),
    //frames(2*freq*time),  // Total number of frames to run the test for.
	event_queue(NULL),
	timer(NULL),
    display(NULL),
    xOffset(0), yOffset(0),
	mouse_xpos(0),
	mouse_ypos(0),
    done(false),
    PatternIndex(2), CycleIndex(1), CycleCounter(0), ColorIndex(1)
{
	InitializationStatus initialisation_status = AllegroInit();
	if(initialisation_status != OKAY)
	{
		throw initialisation_status;
	}
}
Esempio n. 2
0
File: ps2.c Progetto: TRex22/setedit
//#define PROFILE
int main(int argc, char *argv[])
{
 int i,Frames=0;
 unsigned long t1=0,t2,t3,t4;
 float Time;
 double k=18.334;
 int ForceGeneric=0;
 int Surface=1,UnoMas;

 for (i=1; i<argc; i++)
    {
     UnoMas=i<argc-1;
     if (argv[i][0]=='-')
       {
        switch (argv[i][1])
          {
           case 's':
                WaitSync=0;
                break;
           case 'g':
                ForceGeneric=1;
                break;
           case 'h':
                PrintHelp();
                return 1;
           case 'i':
                ShowInfo();
                return 2;
           case 'n':
                printf("Plasma mixsurf 1\n");
                return 3;
           case 'F':
                Surface=0;
                break;
           case 'k':
                if (UnoMas)
                   k=atof(argv[++i]);
                break;
          }
       }
    }

 AllegroInit();
 CalcuInit();

 // Virtual screen
 BMPAuxScreen=create_bitmap(w,h);
 screen_buffer=BMPAuxScreen->line[0];

 RPF_MakeBlueGreen_RedBars(temp2);

 if (!ForceGeneric)
   {
    t3=rawclock();
    PLA2_InitPlasmaTables();
    t4=rawclock();
    AllegroSetMode();

    RPF_RGBBarsWithCos(temp);
    RPF_SetAllPal(temp);
    t1=rawclock();
    while (!poll_input())
      {
       for (i=0; i<1000 && !poll_input(); i++)
          {
           PLA2_Step2(screen_buffer);
           RPF_RGBBarsWithCos(temp);
           if (WaitSync)
              vsync();
           PS_FullBlitLinear(BMPAuxScreen,screen);
           Frames++;
           RPF_SetAllPal(temp);
          }
       if (i<1000) break;
       RPF_SetAllPal(temp2);
       for (i=0; i<1000 && !poll_input(); i++)
          {
           PLA2_Step2(screen_buffer);
           if (WaitSync)
              vsync();
           PS_FullBlitLinear(BMPAuxScreen,screen);
           Frames++;
          }
       if (i<1000) break;
      }
   }
 else
   {
    t3=rawclock();
    PLA2G_InitPlasmaTables(w,h,screen_buffer,k,Surface,w*2,h*2,CalcuCallBack);
    t4=rawclock();
    AllegroSetMode();
    RPF_RGBBarsWithCos(temp);
    RPF_SetAllPal(temp);
    t1=rawclock();
    while (!poll_input())
      {
       for (i=0; i<1000 && !poll_input(); i++)
          {
           MVS_4SurfSC();
           RPF_RGBBarsWithCos(temp);
           Blit();
           RPF_SetAllPal(temp);
          }
       if (i<1000) break;
       RPF_SetAllPal(temp2);
       for (i=0; i<1000 && !poll_input(); i++)
          {
           MVS_4SurfSC();
           Blit();
          }
       if (i<1000) break;
      }
   }
 t2=rawclock();
 PLA2G_DeInit();
 allegro_exit();

 Time=(t2-t1)/18.2;
 printf("Time: %f Frames: %d => %f fps.\n",Time,Frames,Frames/Time);
 Time=(t4-t3)/18.2;
 printf("Initialization time: %f.\n",Time);

 terminate();
 return 0;
}