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; } if (_renderer != null) { _renderer.Shutdown(); } _view = null; try { Noesis.GUI.Shutdown(); } catch (Exception e) { LogError(e.Message); } GLUTWrapper.Shutdown(); }
static void Main(string[] args) { try { // Initialization GLUTWrapper.Init(1280, 720, "NoesisGUI Integration Sample"); Log.LogCallback += (level, channel, message) => { if (channel == "") { // [TRACE] [DEBUG] [INFO] [WARNING] [ERROR] string[] prefixes = new string[] { "T", "D", "I", "W", "E" }; string prefix = (int)level < prefixes.Length ? prefixes[(int)level] : " "; Console.WriteLine("[NOESIS/" + prefix + "] " + message); } }; GUI.Init(); // Setup embedded resource providers EmbeddedXaml[] xamls = new EmbeddedXaml[] { new EmbeddedXaml { filename = "Reflections.xaml", resource = "Reflections" } }; GUI.SetXamlProvider(new EmbeddedXamlProvider(xamls, Properties.Resources.ResourceManager)); // Data loading { var content = (Noesis.Grid)Noesis.GUI.LoadXaml("Reflections.xaml"); _view = Noesis.GUI.CreateView(content); RenderDevice device = new RenderDeviceGL(); _renderer = _view.Renderer; _renderer.Init(device); } // 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; _eventsAttached = true; // Main Loop GLUTWrapper.Run(); } catch (Exception e) { LogError(e.Message); OnClose(); } }