Exemple #1
0
        static void Main(string[] args)
        {
            try
            {
                // Initialization
                GLUTWrapper.Init(800, 600, "NoesisGUI Integration Sample");

                Noesis.GUI.Init();
                Noesis.GUI.SetResourceProvider("Data");

                // Global theme
                {
                    var theme = (Noesis.ResourceDictionary)Noesis.GUI.LoadXaml("NoesisStyle.xaml");
                    Noesis.GUI.SetTheme(theme);
                }

                // Data loading
                {
                    var content = (Noesis.Grid)Noesis.GUI.LoadXaml("TextBox.xaml");
                    _view     = Noesis.GUI.CreateView(content);
                    _renderer = _view.Renderer;
                    _renderer.InitGL(new Noesis.VGOptions());
                }

                // Attach to Application events
                GLUTWrapper.Close      += OnClose;
                GLUTWrapper.Tick       += OnTick;
                GLUTWrapper.PreRender  += OnPreRender;
                GLUTWrapper.PostRender += OnPostRender;
                GLUTWrapper.Resize     += OnResize;
                GLUTWrapper.MouseMove  += OnMouseMove;
                GLUTWrapper.MouseDown  += OnMouseDown;
                GLUTWrapper.MouseUp    += OnMouseUp;
                GLUTWrapper.KeyDown    += OnKeyDown;
                GLUTWrapper.KeyUp      += OnKeyUp;
                _eventsAttached         = true;

                // Main Loop
                GLUTWrapper.Run();
            }
            catch (Exception e)
            {
                LogError(e.Message);

                OnClose();
            }
        }
Exemple #2
0
        static void OnClose()
        {
            // Detach from Application events
            if (_eventsAttached)
            {
                _eventsAttached         = false;
                GLUTWrapper.Close      -= OnClose;
                GLUTWrapper.Tick       -= OnTick;
                GLUTWrapper.PreRender  -= OnPreRender;
                GLUTWrapper.PostRender -= OnPostRender;
                GLUTWrapper.Resize     -= OnResize;
                GLUTWrapper.MouseMove  -= OnMouseMove;
                GLUTWrapper.MouseDown  -= OnMouseDown;
                GLUTWrapper.MouseUp    -= OnMouseUp;
                GLUTWrapper.KeyDown    -= OnKeyDown;
                GLUTWrapper.KeyUp      -= OnKeyUp;
            }

            if (_renderer != null)
            {
                _renderer.Shutdown();
            }

            _view = null;

            try
            {
                Noesis.GUI.Shutdown();
            }
            catch (Exception e)
            {
                LogError(e.Message);
            }

            GLUTWrapper.Shutdown();
        }