Exemplo n.º 1
0
int main (int argc, char *argv[])
{
  G2DTestSystemDriver System (argc, argv);
  Sys = &System;
  iObjectRegistry* object_reg = System.object_reg;

  if (!csInitializer::SetupEventHandler (object_reg, G2DEventHandler))
  {
    csReport (object_reg, CS_REPORTER_SEVERITY_ERROR,
    	"crystalspace.application.g2dtest",
        "Unable to init app!");
    return false;
  }

  // Check for commandline help.
  if (csCommandLineHelper::CheckHelp (object_reg))
  {
    csCommandLineHelper::Help (object_reg);
    exit (0);
  }

  csRef<iPluginManager> plugin_mgr (
  	csQueryRegistry<iPluginManager> (object_reg));
  csRef<iCommandLineParser> cmdline (
  	csQueryRegistry<iCommandLineParser> (object_reg));

  System.myG3D = csQueryRegistry<iGraphics3D> (object_reg);
  // Now load the renderer plugin
  if (!System.myG3D)
  {
    csString canvas = cmdline->GetOption ("video");
    if (!canvas || !*canvas)
      canvas = "crystalspace.graphics3d.opengl";
    else if (strncmp ("crystalspace.", canvas, 13))
    {
      canvas = "crystalspace.graphics3d." + canvas;
    }
    System.myG3D = csLoadPlugin<iGraphics3D> (plugin_mgr, canvas);
    if (!object_reg->Register (System.myG3D, "iGraphics3D"))
    {
      csReport (object_reg, CS_REPORTER_SEVERITY_ERROR,
    	  "crystalspace.application.g2dtest",
	  "Unable to register renderer!");
      return -1;
    }
  }

  if (!System.myG3D)
  {
    csReport (object_reg, CS_REPORTER_SEVERITY_ERROR,
    	"crystalspace.application.g2dtest",
	"Unable to load canvas driver!");
    return -1;
  }
  System.myG2D = System.myG3D->GetDriver2D ();
    
  System.SystemOpen = csevSystemOpen (object_reg);
  System.KeyboardDown = csevKeyboardDown (object_reg);
  System.Frame = csevFrame (object_reg);
  System.CanvasResize = csevCanvasResize (object_reg, System.myG2D);

  System.framePrinter.AttachNew (new FramePrinter (object_reg));

  if (!csInitializer::OpenApplication (object_reg))
  {
    csReport (object_reg, CS_REPORTER_SEVERITY_ERROR,
    	"crystalspace.application.g2dtest",
        "Unable to open drivers!");
    return -1;
  }
  
  System.cursorPlugin = csQueryRegistry<iCursor> (object_reg);
  if (System.cursorPlugin)
  {
    csRef<iConfigManager> cfg (csQueryRegistry<iConfigManager> (object_reg));
    if (System.cursorPlugin->Setup (System.myG3D))
    {
      System.cursorPlugin->ParseConfigFile ((iConfigManager*)cfg);
    }
    else
      System.cursorPlugin = 0;
  }

  iNativeWindow* nw = System.myG2D->GetNativeWindow ();
  if (nw) nw->SetTitle (APP_TITLE);

  csDefaultRunLoop(object_reg);

  System.myG2D = 0;
  System.myG3D->Close();
  System.myG3D = 0;
  plugin_mgr = 0;
  cmdline = 0;

  return 0;
}
Exemplo n.º 2
0
void csWaterDemo::Start ()
{
  csDefaultRunLoop (object_reg);
}