예제 #1
0
 protected virtual void Dispose(bool managed)
 {
     if (!m_Disposed)
     {
         if (managed)
         {
             m_Renderer2D.Dispose();
         }
         m_Disposed = true;
     }
 }
예제 #2
0
        public CharlieWindow(int width, int height, Action <Window, Renderer2D> onDraw)
        {
            _onDrawAction = onDraw;

            Panel           = new Panel();
            Panel.Width     = width;
            Panel.Height    = height;
            Panel.Dock      = DockStyle.Fill;
            Panel.BackColor = System.Drawing.Color.Black;
            Panel.Location  = new System.Drawing.Point(0, 0);
            Panel.Click    += (object o, EventArgs e) => { Panel.Parent.Select(); };

            var screenDimensions = Screen.FromControl(Panel).Bounds;

            WindowConfig config = new WindowConfig(screenDimensions.Width, screenDimensions.Height, "", WindowFlags.Borderless | WindowFlags.PositionOrigin);

            NativeWindow = new Window(config);
            NativeWindow.SetClearColor(0.1f, 0.2f, 0.3f, 1.0f);

            Timer timer = new Timer();

            timer.Interval = 1000 / 120;

            _renderer = new Renderer2D();
            _renderer.Initalize(Matrix4.Orthographic(screenDimensions.Width, 0, 0, screenDimensions.Height, 1, -1));

            Font font = new Font("Assets/WendyOne-Regular.ttf", 38);

            timer.Tick += (object o, EventArgs e) => {
                NativeWindow.PollEvents();
                NativeWindow.Clear();
                _renderer.Begin();
                _onDrawAction(NativeWindow, _renderer);
                _renderer.End();
                _renderer.Present();
                NativeWindow.SwapBuffers();
            };

            Panel.Disposed += (object o, EventArgs e) => { _renderer.Dispose(); };

            timer.Start();

            Win32.SetWindowPos(NativeWindow.GetHWND(), IntPtr.Zero, 0, 0, 0, 0, Win32.SWP_NOSIZE);
            Win32.SetParent(NativeWindow.GetHWND(), Panel.Handle);
            Win32.SetWindowLong(NativeWindow.GetHWND(), Win32.GWL_STYLE, (uint)Win32.WS_CHILD);
        }
예제 #3
0
        // Disposer
        public void Dispose()
        {
            // Not already disposed?
            if (!isdisposed)
            {
                // Let the plugins know
                General.Plugins.OnMapCloseBegin();

                // Stop processing
                General.MainWindow.StopProcessing();

                // Change to no mode
                General.Editing.ChangeMode((EditMode)null);

                // Unbind any methods
                General.Actions.UnbindMethods(this);

                // Dispose
                if (grid != null)
                {
                    grid.Dispose();
                }
                if (launcher != null)
                {
                    launcher.Dispose();
                }
                if (copypaste != null)
                {
                    copypaste.Dispose();
                }
                if (undoredo != null)
                {
                    undoredo.Dispose();
                }
                General.WriteLogLine("Unloading data resources...");
                if (data != null)
                {
                    data.Dispose();
                }
                General.WriteLogLine("Unloading map data...");
                if (map != null)
                {
                    map.Dispose();
                }
                General.WriteLogLine("Stopping graphics device...");
                if (renderer2d != null)
                {
                    renderer2d.Dispose();
                }
                if (renderer3d != null)
                {
                    renderer3d.Dispose();
                }
                if (graphics != null)
                {
                    graphics.Dispose();
                }
                visualcamera = null;
                grid         = null;
                launcher     = null;
                copypaste    = null;
                undoredo     = null;
                data         = null;
                //tempwad = null;
                map        = null;
                renderer2d = null;
                renderer3d = null;
                graphics   = null;

                // We may spend some time to clean things up here
                GC.Collect();

                // Let the plugins know
                General.Plugins.OnMapCloseEnd();

                // Done
                isdisposed = true;
            }
        }
예제 #4
0
 protected override void OnDeactivated(Registry registry)
 {
     Renderer2D.Dispose();
 }