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(); } }
private static void OnContentLoaded() { 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); IntPtr deviceContext = app.Device.ImmediateContext.NativePointer; RenderDevice device = new RenderDeviceD3D11(deviceContext); renderer = view.Renderer; renderer.Init(device); } // Attach to Application events app.Close += OnClose; app.Tick += OnTick; app.PreRender += OnPreRender; app.PostRender += OnPostRender; app.Resize += OnResize; app.MouseMove += OnMouseMove; app.MouseDown += OnMouseDown; app.MouseUp += OnMouseUp; OnResize(app.Size.Width, app.Size.Height); isRunning = true; }