Ejemplo n.º 1
0
        private static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                Initialize();

                GorgonApplication.Run(_mainForm, Idle);
            }
            catch (Exception ex)
            {
                GorgonExample.HandleException(ex);
            }
            finally
            {
                GorgonExample.UnloadResources();

                // Always clean up when you're done.
                // Since Gorgon uses Direct 3D 11.4, we must be careful to dispose of any objects that implement IDisposable.
                // Failure to do so can lead to warnings from the Direct 3D runtime when running in DEBUG mode.
                _depthStencil?.Dispose();
                _texture?.Dispose();
                _geometryShader?.Dispose();
                _pixelShader?.Dispose();
                _vertexShader?.Dispose();
                _bufferless?.Dispose();
                _swap?.Dispose();
                _graphics?.Dispose();
            }
        }
Ejemplo n.º 2
0
        /// <summary>Raises the <see cref="E:System.Windows.Forms.Form.Load" /> event.</summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data. </param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try
            {
                Show();

                Cursor.Current = Cursors.WaitCursor;

                Initialize();

                _originalSize = new DX.Vector2(GroupControl1.ClientSize.Width, GroupControl2.ClientSize.Height);

                GorgonApplication.IdleMethod = Idle;
            }
            catch (Exception ex)
            {
                GorgonExample.HandleException(ex);
                GorgonApplication.Quit();
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Ejemplo n.º 3
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            try
            {
                GorgonApplication.Run(Initialize(), Idle);
            }
            catch (Exception ex)
            {
                GorgonExample.HandleException(ex);
            }
            finally
            {
                GorgonExample.UnloadResources();

                _helpFont?.Dispose();
                _shadowTexture?.Dispose();
                _gaussBlur?.Dispose();
                _spriteTexture?.Dispose();
                _backgroundTexture?.Dispose();
                _renderer?.Dispose();
                _blurTexture?.Dispose();
                _blurTarget?.Dispose();
                _layer1Texture?.Dispose();
                _layer1Target?.Dispose();
                _screen?.Dispose();
                _graphics?.Dispose();
            }
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            Boot booter = null;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            try
            {
                InitApplicationUserDirectory();
                InitializeLogging(args);

                booter = new Boot();
                booter.BootStrap();

                GorgonApplication.Run(booter);
            }
            catch (Exception ex)
            {
                ex.Catch(_ => GorgonDialogs.ErrorBox(null, Resources.GOREDIT_ERR_GENERAL_ERROR, Resources.GOREDIT_ERR_ERROR, ex), Log);
            }
            finally
            {
                Log?.LogEnd();
                booter?.Dispose();

                EditorCommonResources.UnloadResources();
            }
        }
Ejemplo n.º 5
0
        /// <summary>Raises the <see cref="E:System.Windows.Forms.Form.Load" /> event.</summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data. </param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            _gifAnim = new GifAnimator(SynchronizationContext.Current);
            _gallery = new ImageGallery(Font, DeviceDpi, _gifAnim);

            try
            {
                Cursor.Current = Cursors.WaitCursor;

                // Load our image data.
                _gallery.LoadImages(GorgonApplication.StartupPath.FullName);


                // Begin our animation.
                _gifAnim.Animate(() =>
                {
                    using (System.Drawing.Graphics graphics = CreateGraphics())
                    {
                        _gallery.RefreshGif(graphics);
                    }
                });
            }
            catch (Exception ex)
            {
                GorgonExample.HandleException(ex);
                GorgonApplication.Quit();
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Handles the KeyUp event of the Window control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="KeyEventArgs"/> instance containing the event data.</param>
        private static void Window_KeyUp(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.Escape:
                GorgonApplication.Quit();
                return;

            case Keys.F1:
                _showHelp = !_showHelp;
                return;
            }

            if (e.KeyCode != Keys.C)
            {
                return;
            }

            switch (_cloakController.Direction)
            {
            case CloakDirection.Cloak:
            case CloakDirection.CloakPulse:
                _cloakController.Uncloak();
                break;

            case CloakDirection.Uncloak:
            case CloakDirection.UncloakStopPulse:
            case CloakDirection.None:
                _cloakController.Cloak();
                break;
            }
        }
Ejemplo n.º 7
0
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                GorgonApplication.Run(Initialize(), Idle);
            }
            catch (Exception ex)
            {
                GorgonExample.HandleException(ex);
            }
            finally
            {
                GorgonExample.UnloadResources();

                foreach (GorgonTexture2D texture in _textures)
                {
                    texture?.Dispose();
                }

                _renderer?.Dispose();
                _depthBuffer?.Dispose();
                _screen?.Dispose();
                _graphics?.Dispose();
                _assemblyCache?.Dispose();
            }
        }
Ejemplo n.º 8
0
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                GorgonApplication.Run(Initialize(), Idle);

                if (_mp3Player != null)
                {
                    _mp3Player.Stop();
                }
            }
            catch (Exception ex)
            {
                GorgonExample.HandleException(ex);
            }
            finally
            {
                GorgonExample.UnloadResources();

                _mp3Player.Dispose();
                _renderer?.Dispose();
                _trooper?.Dispose();
                _metal?.Dispose();
                _targetView?.Dispose();
                _target?.Dispose();
                _screen?.Dispose();
                _graphics?.Dispose();
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Handles the KeyUp event of the Window control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="KeyEventArgs"/> instance containing the event data.</param>
        private static void Window_KeyUp(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.Escape:
                GorgonApplication.Quit();
                break;

            case Keys.Right:
                ++_currentImage;

                if (_currentImage >= _images.Length)
                {
                    _currentImage = 0;
                }
                break;

            case Keys.Left:
                --_currentImage;

                if (_currentImage < 0)
                {
                    _currentImage = _images.Length - 1;
                }
                break;
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Function to load the images for use with the example.
        /// </summary>
        /// <param name="codec">The codec for the images.</param>
        /// <returns><b>true</b> if files were loaded successfully, <b>false</b> if not.</returns>
        private static bool LoadImageFiles(IGorgonImageCodec codec)
        {
            DirectoryInfo dirInfo = GorgonExample.GetResourcePath(@"\Textures\PostProcess");

            FileInfo[] files = dirInfo.GetFiles("*.dds", SearchOption.TopDirectoryOnly);

            if (files.Length == 0)
            {
                GorgonDialogs.ErrorBox(null, $"No DDS images found in {dirInfo.FullName}.");
                GorgonApplication.Quit();
                return(false);
            }

            _images = new GorgonTexture2DView[files.Length];

            // Load all the DDS files from the resource area.
            for (int i = 0; i < files.Length; ++i)
            {
                _images[i] = GorgonTexture2DView.FromFile(_graphics,
                                                          files[i].FullName,
                                                          codec,
                                                          new GorgonTexture2DLoadOptions
                {
                    Binding = TextureBinding.ShaderResource,
                    Usage   = ResourceUsage.Immutable,
                    Name    = Path.GetFileNameWithoutExtension(files[i].Name)
                });
            }

            return(true);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Form.Load" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try
            {
                GorgonExample.PlugInLocationDirectory = new DirectoryInfo(Settings.Default.PlugInLocation);
                GorgonExample.ResourceBaseDirectory   = new DirectoryInfo(Settings.Default.ResourceLocation);

                // Create our virtual file system.
                _fileSystem = new GorgonFileSystem(Program.Log);
                _writer     = new GorgonFileSystemWriter(_fileSystem, Program.WriteDirectory.FullName);

                LoadText();

                labelFileSystem.Text    = $"{GorgonExample.GetResourcePath(@"FolderSystem\").FullName.Ellipses(100, true)} mounted as '/'.";
                labelWriteLocation.Text = $"{Program.WriteDirectory.FullName.Ellipses(100, true)} mounted as '/'";
            }
            catch (Exception ex)
            {
                GorgonExample.HandleException(ex);
                GorgonApplication.Quit();
            }
            finally
            {
                CommandEnable(!string.Equals(_originalText, _changedText, StringComparison.CurrentCulture));
                UpdateInfo();
            }
        }
Ejemplo n.º 12
0
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                GorgonApplication.Run(Initialize(), Idle);
            }
            catch (Exception ex)
            {
                GorgonExample.HandleException(ex);
            }
            finally
            {
                GorgonExample.UnloadResources();

                _lightEffect?.Dispose();
                _renderer?.Dispose();
                _finalTexture?.Dispose();
                _finalTarget?.Dispose();
                _backgroundLogoTexture?.Dispose();
                _screen?.Dispose();
                _graphics?.Dispose();
            }
        }
Ejemplo n.º 13
0
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                GorgonApplication.Run(Initialize(), Idle);
            }
            catch (Exception ex)
            {
                GorgonExample.HandleException(ex);
            }
            finally
            {
                GorgonExample.UnloadResources();

                _gaussBlur?.Dispose();
                _oldFilm?.Dispose();
                _displacement?.Dispose();
                _finalView?.Dispose();
                _finalTarget?.Dispose();
                _postView2?.Dispose();
                _postTarget2?.Dispose();
                _postView1?.Dispose();
                _postTarget1?.Dispose();
                _background?.Dispose();
                _renderer?.Dispose();
                _screen?.Dispose();
                _graphics?.Dispose();
            }
        }
Ejemplo n.º 14
0
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            try
            {
                // Now begin running the application idle loop.
                GorgonApplication.Run(Initialize(), Idle);
            }
            catch (Exception ex)
            {
                GorgonExample.HandleException(ex);
            }
            finally
            {
                // Always clean up when you're done.
                // Since Gorgon uses Direct 3D 11.x, which allocate objects that use native memory and COM objects, we must be careful to dispose of any objects that implement
                // IDisposable. Failure to do so can lead to warnings from the Direct 3D runtime when running in DEBUG mode.
                GorgonExample.UnloadResources();

                _constantBuffer?.Dispose();
                _vertexBuffer.VertexBuffer?.Dispose();
                _inputLayout?.Dispose();
                _vertexShader?.Dispose();
                _pixelShader?.Dispose();
                _swap?.Dispose();
                _graphics?.Dispose();
            }
        }
Ejemplo n.º 15
0
        private static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                _form = new FormMain
                {
                    ClientSize = new Size(640, 480)
                };

                // Get the initial time.
                _lastTime = GorgonTiming.MillisecondsSinceStart;

                // Run the application with an idle loop.
                //
                // The form will still control the life time of the application (i.e. the close button will end the application).
                // However, you may specify only the idle method and use that to control the application life time, similar to
                // standard windows application in C++.
                // Other overloads allow using only the form and assigning the idle method at another time (if at all), or setting
                // up an application context object to manage the life time of the application (with or without an idle loop
                // method).
                GorgonApplication.Run(_form, Idle);
            }
            catch (Exception ex)
            {
                ex.Catch(_ => GorgonDialogs.ErrorBox(null, _), GorgonApplication.Log);
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Form.Load"></see> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"></see> that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            GorgonExample.ShowStatistics = false;
            Cursor.Current = Cursors.WaitCursor;

            try
            {
                Show();
                Application.DoEvents();

                // Initialize Gorgon
                // Set it up so that we won't be rendering in the background, but allow the screensaver to activate.
                IReadOnlyList <IGorgonVideoAdapterInfo> adapters = GorgonGraphics.EnumerateAdapters(log: GorgonApplication.Log);
                if (adapters.Count == 0)
                {
                    throw new GorgonException(GorgonResult.CannotCreate,
                                              "No suitable video adapter found in the system.\nGorgon requires a minimum of a Direct3D 11.4 capable video device.");
                }

                _graphics = new GorgonGraphics(adapters[0]);

                // Set the video mode.
                ClientSize = new Size(640, 400);
                _screen    = new GorgonSwapChain(_graphics,
                                                 this,
                                                 new GorgonSwapChainInfo("FunWithShapes SwapChain")
                {
                    Width  = ClientSize.Width,
                    Height = ClientSize.Height,
                    Format = BufferFormat.R8G8B8A8_UNorm
                });
                _screen.AfterSwapChainResized += Screen_AfterSwapChainResized;
                _graphics.SetRenderTarget(_screen.RenderTargetView);
                _halfSize = new DX.Size2F(_screen.Width / 2.0f, _screen.Height / 2.0f);

                // Create our 2D renderer so we can draw stuff.
                _renderer = new Gorgon2D(_graphics);

                LabelPleaseWait.Visible = false;

                GorgonExample.LoadResources(_graphics);

                // Draw the image.
                DrawAPrettyPicture();
            }
            catch (Exception ex)
            {
                GorgonExample.HandleException(ex);
                GorgonApplication.Quit();
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Form.Load" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try
            {
                // Set our default cursor.
                _currentCursor = Resources.hand_icon;

                // Create our input factory.
                _rawInput = new GorgonRawInput(this);

                // Ensure that we have the necessary input devices.
                // This enumeration method could be used to retrieve only a single specific mouse out of many.
                if (_rawInput.EnumerateMice().Count == 0)
                {
                    GorgonDialogs.ErrorBox(this, "There were no mice detected on this computer.  The application requires a mouse.");
                    GorgonApplication.Quit();
                }

                // This enumeration method could be used to retrieve only a single specific keyboard out of many.
                if (_rawInput.EnumerateKeyboards().Count == 0)
                {
                    GorgonDialogs.ErrorBox(this, "There were no keyboards detected on this computer.  The application requires a keyboard.");
                    GorgonApplication.Quit();
                }

                // Get our input devices.
                CreateMouse();
                CreateKeyboard();

                // When the display area changes size, update the spray effect
                // and limit the mouse.
                panelDisplay.Resize += PanelDisplay_Resize;

                // Set up our spray object.
                _spray  = new Spray(panelDisplay.ClientSize);
                _cursor = new MouseCursor(panelDisplay)
                {
                    Hotspot = new Point(-16, -3)
                };

                // Set up our idle method.
                GorgonApplication.IdleMethod = Idle;
            }
            catch (Exception ex)
            {
                // We do this here instead of just calling the dialog because this
                // function will send the exception to the Gorgon log file.
                ex.Catch(_ => GorgonDialogs.ErrorBox(this, _), GorgonApplication.Log);
                GorgonApplication.Quit();
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Form.Load" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try
            {
                // Picture box.
                _picture = new PictureBox
                {
                    Name = "pictureImage"
                };

                // Text display.
                _textDisplay = new TextBox
                {
                    Name = "textDisplay"
                };
                _textFont         = new Font("Consolas", 10.0f, FontStyle.Regular, GraphicsUnit.Point);
                _textDisplay.Font = _textFont;

                _instructions = new Label
                {
                    Name      = "labelInstructions",
                    Text      = "Double click on a file node in the tree to display it.",
                    AutoSize  = false,
                    TextAlign = ContentAlignment.MiddleCenter,
                    Dock      = DockStyle.Fill,
                    Font      = Font
                };

                // Add the instructions.
                splitFileSystem.Panel2.Controls.Add(_instructions);

                // Get the zip file provider.
                LoadZipFileSystemProvider();

                // Mount the physical file system directory.
                _fileSystem.Mount(Program.GetResourcePath(@"VFSRoot\"));

                // Mount the zip file into a sub directory.
                _fileSystem.Mount(Program.GetResourcePath("VFSRoot.zip"), "/ZipFile");

                // Fill the root of the tree.
                FillTree(null);
            }
            catch (Exception ex)
            {
                ex.Catch(_ => GorgonDialogs.ErrorBox(this, _), Program.Log);
                GorgonApplication.Quit();
            }
        }
Ejemplo n.º 19
0
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            try
            {
                GorgonApplication.Run(new Form());
            }
            catch (Exception ex)
            {
                GorgonExample.HandleException(ex);
            }
        }
Ejemplo n.º 20
0
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                GorgonApplication.Run(new Form());
            }
            catch (Exception ex)
            {
                ex.Catch(_ => GorgonDialogs.ErrorBox(null, _), GorgonApplication.Log);
            }
        }
Ejemplo n.º 21
0
        public static async Task Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                Application.DoEvents();

                // This is necessary to get winforms to play nice with our background thread prior to running the application.
                WindowsFormsSynchronizationContext.AutoInstall = false;
                SynchronizationContext.SetSynchronizationContext(new WindowsFormsSynchronizationContext());

                FormMain window = GorgonExample.Initialize(new DX.Size2(Settings.Default.Resolution.Width, Settings.Default.Resolution.Height), "Space Scene",
                                                           async(sender, _) => await InitializeAsync(sender as FormMain));

                GorgonApplication.Run(window);
            }
            catch (Exception ex)
            {
                GorgonExample.HandleException(ex);
            }
            finally
            {
                // Always perform your clean up.
                if (_keyboard != null)
                {
                    _keyboard.KeyUp -= Keyboard_KeyUp;
                }

                _helpFont?.Dispose();
                _fontFactory?.Dispose();

                GorgonExample.UnloadResources();

                if (_keyboard != null)
                {
                    _input?.UnregisterDevice(_keyboard);
                }
                _input?.Dispose();
                _sceneRenderer?.Dispose();
                _resources?.Dispose();
                _renderer?.Dispose();
                _mainRtv?.Dispose();
                _screen?.Dispose();
                _graphics?.Dispose();
                _assemblyCache?.Dispose();
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Windows the key down.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="KeyEventArgs" /> instance containing the event data.</param>
        private static void Window_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.Escape:
                GorgonApplication.Quit();
                return;

            case Keys.Z:
                _lightEffect.Lights[0].Position =
                    !e.Shift
                            ? new DX.Vector3(_lightEffect.Lights[0].Position.X, _lightEffect.Lights[0].Position.Y, _lightEffect.Lights[0].Position.Z + 1.0f)
                            : new DX.Vector3(_lightEffect.Lights[0].Position.X, _lightEffect.Lights[0].Position.Y, _lightEffect.Lights[0].Position.Z - 1.0f);
                break;
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Handles the KeyUp event of the Window control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="KeyEventArgs"/> instance containing the event data.</param>
        private static void Window_KeyUp(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.F1:
                _showHelp = !_showHelp;
                break;

            case Keys.S:
                GorgonExample.ShowStatistics = !GorgonExample.ShowStatistics;
                break;

            case Keys.Escape:
                GorgonApplication.Quit();
                break;
            }
        }
Ejemplo n.º 24
0
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            try
            {
                Initialize();

                GorgonApplication.Run(_window, Idle);
            }
            catch (Exception ex)
            {
                GorgonExample.HandleException(ex);
            }
            finally
            {
                GorgonExample.UnloadResources();

                _2DRenderer.Dispose();
                _fontFactory.Dispose();

                _input?.Dispose();

                if (_renderer != null)
                {
                    foreach (Mesh mesh in _renderer.Meshes)
                    {
                        mesh.Dispose();
                    }

                    _renderer.Dispose();
                }

                _icoSphere?.Dispose();
                _clouds?.Dispose();
                _sphere?.Dispose();
                _cube?.Dispose();
                _plane?.Dispose();
                _triangle?.Dispose();

                _swapChain?.Dispose();
                _graphics?.Dispose();
            }
        }
Ejemplo n.º 25
0
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                GorgonApplication.Run(new Form());
            }
            catch (Exception ex)
            {
                GorgonExample.HandleException(ex);
            }
            finally
            {
                GorgonExample.UnloadResources();
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Form.Load" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try
            {
                GorgonExample.PlugInLocationDirectory = new DirectoryInfo(Settings.Default.PlugInLocation);

                // Create the assembly cache.
                _assemblies = new GorgonMefPlugInCache(GorgonApplication.Log);
                _assemblies.LoadPlugInAssemblies(GorgonExample.GetPlugInPath().FullName, "Gorgon.Input.XInput.dll");

                // Create the plug services.
                IGorgonPlugInService pluginService = new GorgonMefPlugInService(_assemblies);

                // Create the gaming device driver factory.
                var factory = new GorgonGamingDeviceDriverFactory(pluginService, GorgonApplication.Log);

                // Create our factory.
                _driver = factory.LoadDriver("Gorgon.Input.XInput.GorgonXInputDriver");

                _stickPosition = new PointF[3];
                _sprayStates   = new SprayCan[3];

                // Get our list of active controllers.
                UpdateActiveControllers();

                // Get the graphics interface for our panel.
                _surface = new DrawingSurface(panelDisplay);

                // Set up our idle loop.
                GorgonApplication.IdleMethod += Idle;

                // Launch a background task to check for connected devices.
                Task.Run(CheckForConnectedDevices);
            }
            catch (Exception ex)
            {
                // We do this here instead of just calling the dialog because this
                // function will send the exception to the Gorgon log file.
                GorgonExample.HandleException(ex);
                GorgonApplication.Quit();
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.KeyDown" /> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.KeyEventArgs" /> that contains the event data.</param>
        protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);

            if (e.KeyCode == Keys.Escape)
            {
                GorgonApplication.Quit();
            }

            if (e.KeyCode == Keys.F1)
            {
                _showHelp = !_showHelp;
            }

            if (e.KeyCode == Keys.S)
            {
                _showStats = !_showStats;
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Form.Load" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            Cursor.Current = Cursors.WaitCursor;

            try
            {
                // Find out which devices we have installed in the system.
                IReadOnlyList <IGorgonVideoAdapterInfo> deviceList = GorgonGraphics.EnumerateAdapters();

                if (deviceList.Count == 0)
                {
                    GorgonDialogs.ErrorBox(this, "There are no suitable video adapters available in the system. This example is unable to continue and will now exit.");
                    GorgonApplication.Quit();
                    return;
                }

                _graphics = new GorgonGraphics(deviceList[0]);
                _renderer = new GraphicsRenderer(_graphics);
                _renderer.SetPanel(PanelDisplay);

                // Load the compute shader.
#if DEBUG
                _sobelShader = GorgonShaderFactory.Compile <GorgonComputeShader>(_graphics, Resources.ComputeShader, "SobelCS", true);
#else
                _sobelShader = GorgonShaderFactory.Compile <GorgonComputeShader>(_graphics, Resources.ComputeShader, "SobelCS");
#endif
                _sobel = new Sobel(_graphics, _sobelShader);

                GorgonApplication.IdleMethod = Idle;
            }
            catch (Exception ex)
            {
                GorgonExample.HandleException(ex);
                GorgonApplication.Quit();
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Ejemplo n.º 29
0
        static void Main()
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                Initialize();

                GorgonApplication.Run(_window, Idle);
            }
            catch (Exception ex)
            {
                GorgonExample.HandleException(ex);
            }
            finally
            {
                CleanUp();
            }
        }
Ejemplo n.º 30
0
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            try
            {
                Initialize();
                GorgonApplication.Run(_mainForm, Idle);
            }
            catch (Exception ex)
            {
                GorgonExample.HandleException(ex);
            }
            finally
            {
                GorgonExample.UnloadResources();

                _2D.Dispose();

                // Always call dispose so we can free the native memory allocated for the backing graphics API.
                _sphere?.Dispose();

                if (_planes != null)
                {
                    foreach (Plane plane in _planes)
                    {
                        plane?.Dispose();
                    }
                }

                _texture?.Dispose();
                _wvpBuffer?.Dispose();
                _materialBuffer?.Dispose();
                _vertexShader?.Dispose();
                _pixelShader?.Dispose();
                _inputLayout?.Dispose();
                _swap?.Dispose();
                _graphics?.Dispose();
            }
        }