Defines the main singleton instance that processes Tuio cursor messages and retrieves informations from the client about the tuio objects and the GUI components in the surface.
Inheritance: TuioListener
コード例 #1
0
ファイル: Surface.cs プロジェクト: Geistyp/grafiti
 /// <summary>
 /// Initializes the surface and set the client's GUI manager.
 /// </summary>
 /// <param name="guiManager">Client's GUI manager to set.</param>
 public static Surface Initialize(IGrafitiClientGUIManager guiManager)
 {
     lock (s_lock)
     {
         if (s_instance == null)
         {
             s_instance = new Surface();
             s_instance.m_clientGUIManager = guiManager;
         }
         else
             throw new Exception("Attempting to reinitialize Surface.");
     }
     return s_instance;
 }
コード例 #2
0
ファイル: Main.cs プロジェクト: nuigroup/grafiti
        static void Main(String[] argv)
        {
            float x = 0, y = 0, w = 10, h = 10, a = 0;

            int port = 3333;
            switch (argv.Length)
            {
                case 0:
                    break;

                case 1:
                    port = int.Parse(argv[0], null);
                    if (port == 0) goto default;
                    break;

                case 5:
                    x = float.Parse(argv[0], null);
                    y = float.Parse(argv[1], null);
                    w = float.Parse(argv[2], null);
                    h = float.Parse(argv[3], null);
                    a = float.Parse(argv[4], null);
                    break;

                case 6:
                    x = float.Parse(argv[1], null);
                    y = float.Parse(argv[2], null);
                    w = float.Parse(argv[3], null);
                    h = float.Parse(argv[4], null);
                    a = float.Parse(argv[5], null);
                    goto case 1;

                default:
                    Console.WriteLine("Usage: [mono] GrafitiGenericDemo [port] [x y w h a]");
                    System.Environment.Exit(0);
                    break;
            }

            // Force compilation of GR classes
            new PinchingGR();
            new BasicMultiFingerGR();
            new MultiTraceGR();
            new CircleGR();
            new LazoGR();
            new RemovingLinkGR();

            // instantiate viewer
            s_viewer = new Viewer(x, y, w, h, a);

            // instantiate Grafiti
            s_grafitiSurface = Surface.Initialize(s_viewer);

            // instantiate objects' manager
            s_demoObjectManager = new DemoObjectManager(s_viewer);

            // Tuio connections
            s_client = new TuioClient(port);
            s_client.addTuioListener(s_grafitiSurface);
            s_client.addTuioListener(s_demoObjectManager);
            s_client.addTuioListener(s_viewer);
            s_client.connect();

            // initialize glut library
            Glut.glutInit();

            // initialize viewer's graphic
            s_viewer.Init();

            // register callback functions
            Glut.glutKeyboardFunc(new Glut.KeyboardCallback(S_KeyPressed));
            Glut.glutSpecialFunc(new Glut.SpecialCallback(S_SpecialKeyPressed));
            Glut.glutDisplayFunc(new Glut.DisplayCallback(S_Display));
            Glut.glutReshapeFunc(new Glut.ReshapeCallback(S_Reshape));
            Glut.glutTimerFunc(40, new Glut.TimerCallback(S_Timer), 0);

            // main loop
            try
            {
                Glut.glutMainLoop();
            }
            catch (ThreadAbortException e)
            {
                Exit();
            }
        }