Exemplo n.º 1
0
        private void SetupGorgon()
        {
            Gorgon.Initialize(true, false);
            Gorgon.SetMode(this);
            //Gorgon.AllowBackgroundRendering = true;
            //Gorgon.Screen.BackgroundColor = Color.FromArgb(50, 50, 50);

            //Gorgon.CurrentClippingViewport = new Viewport(0, 20, Gorgon.Screen.Width, Gorgon.Screen.Height - 20);
            //PreciseTimer preciseTimer = new PreciseTimer();
            //Gorgon.MinimumFrameTime = PreciseTimer.FpsToMilliseconds(66);
            Gorgon.Idle += new FrameEventHandler(Gorgon_Idle);
            Gorgon.FrameStatsVisible = true;
            Gorgon.DeviceReset      += MainWindowResizeEnd;

            bouncesprite = new Sprite("flyingball", GorgonLibrary.Graphics.Image.FromFile(mediadir + @"flyingball.png"));
            //bouncesprite.SetScale(3, 3);

            baseTarget       = new RenderImage("baseTarget", 32, 32, ImageBufferFormats.BufferRGB888A8);
            baseTargetSprite = new Sprite("baseTargetSprite", baseTarget);

            screenTarget = new RenderImage("screenTarget", Gorgon.CurrentClippingViewport.Width, Gorgon.CurrentClippingViewport.Height, ImageBufferFormats.BufferRGB888A8);

            bounceysprites = new BounceySprite[10];
            for (int i = 0; i < 10; i++)
            {
                bounceysprites[i] = new BounceySprite(bouncesprite, new Vector2D(random.Next(0, Gorgon.CurrentClippingViewport.Width), random.Next(0, Gorgon.CurrentClippingViewport.Height)),
                                                      new Vector2D((float)random.Next(-100000, 100000) / 100000, (float)random.Next(-100000, 100000) / 100000)
                                                      , this);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes the display control.
        /// </summary>
        public void InitDisplay()
        {
            if (!DesignMode)
            {
                // Initialize the library.
                Gorgon.Initialize();

                // Display the logo and frame stats.
                Gorgon.LogoVisible              = false;
                Gorgon.FrameStatsVisible        = false;
                Gorgon.AllowBackgroundRendering = true;

                // Set the video mode to match the form client area.
                Gorgon.SetMode(this);

                // Assign rendering event handler.
                Gorgon.Idle += new FrameEventHandler(Screen_OnFrameBegin);

                // Set the clear color to something ugly.
                Gorgon.Screen.BackgroundColor = Color.FromArgb(0, 0, 0);

                //Init Configuration and resource manager.
                MainForm.InitializeResourceManager();

                /*
                 * _particleImage = GorgonLibrary.Graphics.Image.FromFile("star1.png");
                 * _particleSprite = new Sprite("particlesprite", _particleImage);
                 * _particleSprite.Axis = new Vector2(_particleSprite.Width/2, _particleSprite.Height/2);*/
                _particleSprite = ResourceManager.GetSprite("star1");
                var settings = ParticleConfigurator.ParticleSettings;
                _particleSystem                         = new ParticleSystem(_particleSprite, new Vector2(0, 0));
                settings.ColorRange                     = new SS14.Shared.Utility.Range <Color>(Color.Blue, Color.Black);
                settings.EmitterPosition                = new PointF(Gorgon.Screen.Width / 2, Gorgon.Screen.Height / 2);
                settings.EmissionRadiusRange            = new PointF(10, 170);
                settings.EmitRate                       = 40;
                settings.Velocity                       = new Vector2(0, -20);
                settings.Acceleration                   = new Vector2(0, -30);
                settings.RadialAcceleration             = 10;
                settings.TangentialAccelerationVariance = 0.2f;
                settings.TangentialVelocityVariance     = 1;
                settings.RadialVelocityVariance         = 1;
                //_particleSystem.TangentialAcceleration = 5;
                settings.Lifetime             = 3;
                _particleSystem.Emit          = true;
                settings.SpinVelocityVariance = 2;

                // Begin execution.
                Gorgon.Go();
            }
        }
Exemplo n.º 3
0
        private void SetupGorgon()
        {
            Gorgon.Initialize(true, false);
            Gorgon.SetMode(this);
            //Gorgon.AllowBackgroundRendering = true;
            //Gorgon.Screen.BackgroundColor = Color.FromArgb(50, 50, 50);

            //Gorgon.CurrentClippingViewport = new Viewport(0, 20, Gorgon.Screen.Width, Gorgon.Screen.Height - 20);
            //PreciseTimer preciseTimer = new PreciseTimer();
            //Gorgon.MinimumFrameTime = PreciseTimer.FpsToMilliseconds(66);
            Gorgon.Idle += new FrameEventHandler(Gorgon_Idle);
            Gorgon.FrameStatsVisible = true;

            bouncesprite = new Sprite("bouncey", GorgonLibrary.Graphics.Image.FromFile(mediadir + @"\textures\0_Items.png"), new Vector2D(0, 0), new Vector2D(22, 20));
            bouncesprite.SetScale(3, 3);
            decalsprite = new Sprite("decal", GorgonLibrary.Graphics.Image.FromFile(mediadir + @"\textures\0_Decals.png"), new Vector2D(56, 0), new Vector2D(103, 29));
            decalsprite.SetScale(1, 1);
            decalShader = FXShader.FromFile(mediadir + @"\shaders\decalshader.fx", ShaderCompileOptions.Debug);
            decalShader.Parameters["tex1"].SetValue(decalsprite.Image);

            baseTarget       = new RenderImage("baseTarget", 32, 32, ImageBufferFormats.BufferRGB888A8);
            baseTargetSprite = new Sprite("baseTargetSprite", baseTarget);

            bounceysprites = new BounceySprite[10];
            for (int i = 0; i < 10; i++)
            {
                bounceysprites[i] = new BounceySprite(bouncesprite, new Vector2D(random.Next(0, Gorgon.Screen.Width), random.Next(0, Gorgon.Screen.Height)),
                                                      new Vector2D((float)random.Next(-100000, 100000) / 100000, (float)random.Next(-100000, 100000) / 100000),
                                                      decalsprite, new Vector2D(random.Next(-10, 15), random.Next(-10, 15)), decalShader, this);
            }


            //Calculate decal texcoord offsets

            /*Vector2D decalBToffset = new Vector2D(10,5);
             * float BTXDTL_x = decalBToffset.X / bouncesprite.Image.Width;
             * float BTXDTL_y = decalBToffset.Y / bouncesprite.Image.Height;
             * float BTXDBR_x = (decalBToffset.X + decalsprite.Width)/bouncesprite.Image.Width;
             * float BTXDBR_y = (decalBToffset.Y + decalsprite.Height)/bouncesprite.Image.Height;
             * float CFx = (float)decalsprite.Image.Width/(float)bouncesprite.Image.Width;
             * float CFy = (float)decalsprite.Image.Height / (float)bouncesprite.Image.Height;
             * float DOtc_xtl = (float)decalsprite.ImageOffset.X / (float)decalsprite.Image.Width;
             * float DOtc_ytl = (float)decalsprite.ImageOffset.Y / (float)decalsprite.Image.Height;
             *
             * Vector4D decalParms1 = new Vector4D(BTXDTL_x, BTXDTL_y, BTXDBR_x, BTXDBR_y);
             * Vector4D decalParms2 = new Vector4D(CFx, CFy, DOtc_xtl, DOtc_ytl);*/
        }
Exemplo n.º 4
0
        private void SetupGorgon()
        {
            uint displayWidth  = _configurationManager.GetDisplayWidth();
            uint displayHeight = _configurationManager.GetDisplayHeight();
            bool fullscreen    = _configurationManager.GetFullscreen();
            var  refresh       = (int)_configurationManager.GetDisplayRefresh();

            Size = new Size((int)displayWidth, (int)displayHeight);

            //TODO. Find first compatible videomode and set it if no configuration is present. Else the client might crash due to invalid videomodes on the first start.

            Gorgon.Initialize(true, false);
            //Gorgon.SetMode(this);
            Gorgon.SetMode(this, (int)displayWidth, (int)displayHeight, BackBufferFormats.BufferRGB888, !fullscreen,
                           false, false, refresh);
            Gorgon.AllowBackgroundRendering = true;
            Gorgon.Screen.BackgroundColor   = Color.FromArgb(50, 50, 50);
            Gorgon.CurrentClippingViewport  = new Viewport(0, 0, Gorgon.Screen.Width, Gorgon.Screen.Height);
            Gorgon.DeviceReset += MainWindowResizeEnd;
            //Gorgon.MinimumFrameTime = PreciseTimer.FpsToMilliseconds(66);
            Gorgon.Idle += GorgonIdle;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Handles the Load event of the MainForm control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void MainForm_Load(object sender, EventArgs e)
        {
            try
            {
                // Initialize the library.
                Gorgon.Initialize();

                // Display the logo and frame stats.
                Gorgon.LogoVisible       = false;
                Gorgon.FrameStatsVisible = false;

                // Set the video mode to match the form client area.
                Gorgon.SetMode(this);

                // Assign rendering event handler.
                Gorgon.Idle += new FrameEventHandler(Screen_OnFrameBegin);

                // Set the clear color to something ugly.
                Gorgon.Screen.BackgroundColor = Color.FromArgb(250, 245, 220);

                LoadFont();

                txtspr = new TextSprite("txtspr", "Test", font, Color.Black);

                txtspr.SetPosition(1.0f, 1.0f);
                TextStatus();

                RunMeasureLineTests();
                // Begin execution.
                Gorgon.Go();
            }
            catch (Exception ex)
            {
                UI.ErrorBox(this, "An unhandled error occured during execution, the program will now close.", ex.Message + "\n\n" + ex.StackTrace);
                Application.Exit();
            }
        }
Exemplo n.º 6
0
        private void ApplyVideoMode()
        {
            Form owner = Gorgon.Screen.OwnerForm;

            Gorgon.Stop();

            Gorgon.SetMode(owner, (int)ConfigurationManager.GetDisplayWidth(),
                           (int)ConfigurationManager.GetDisplayHeight(), BackBufferFormats.BufferRGB888,
                           !ConfigurationManager.GetFullscreen(), false, false,
                           (int)ConfigurationManager.GetDisplayRefresh(),
                           (ConfigurationManager.GetVsync() ? VSyncIntervals.IntervalOne : VSyncIntervals.IntervalNone));

            if (!ConfigurationManager.GetFullscreen())
            {
                //Gee thanks gorgon for changing this stuff only when switching TO fullscreen.
                owner.FormBorderStyle = FormBorderStyle.Sizable;
                owner.WindowState     = FormWindowState.Normal;
                owner.ControlBox      = true;
                owner.MaximizeBox     = true;
                owner.MinimizeBox     = true;
            }

            Gorgon.Go();
        }
Exemplo n.º 7
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            try
            {
                List <DirectoryInfo> dataSets = new List <DirectoryInfo>();
                try
                {
                    //Check to see if there's data in program directory that's not copied to general application data folder
                    DirectoryInfo di     = new DirectoryInfo(Path.Combine(Application.StartupPath, "Data"));
                    DirectoryInfo target = new DirectoryInfo(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Beyond Beyaan"));
                    if (!target.Exists)
                    {
                        target.Create();
                    }
                    foreach (var directory in di.GetDirectories())
                    {
                        CopyOrUpdateDirectory(directory, new DirectoryInfo(Path.Combine(target.FullName, directory.Name)));
                    }
                    //Get list of available datasets from general application data folder
                    foreach (var directory in target.GetDirectories())
                    {
                        //Sanity check to ensure that it's a valid dataset
                        dataSets.Add(directory);
                    }
                }
                catch (Exception exception)
                {
                    MessageBox.Show(string.Format("Failed to copy directories.  Error: {0}", exception.Message));
                    Close();
                    return;
                }
                if (dataSets.Count == 0)
                {
                    MessageBox.Show(Resources.BeyondBeyaan_OnLoad_There_are_no_available_datasets_to_choose_from___Ensure_that_the_program_is_installed_correctly_);
                    Close();
                    return;
                }

                dataSets.Sort((a, b) => String.Compare(a.Name, b.Name, StringComparison.CurrentCultureIgnoreCase));

                Gorgon.Initialize(true, false);

                VideoMode     videoMode;
                DirectoryInfo dataset;
                bool          fullScreen;
                bool          showTutorial;

                using (Configuration configuration = new Configuration())
                {
                    configuration.FillResolutionList();
                    configuration.FillDatasetList(dataSets);
                    configuration.ShowDialog(this);
                    if (configuration.DialogResult != DialogResult.OK)
                    {
                        Close();
                        return;
                    }
                    videoMode    = configuration.VideoMode;
                    fullScreen   = configuration.FullScreen;
                    dataset      = dataSets[configuration.DataSetIndex];
                    showTutorial = configuration.ShowTutorial;
                }

                Gorgon.SetMode(this, videoMode.Width, videoMode.Height, BackBufferFormats.BufferRGB888, !fullScreen);

                Gorgon.Idle      += new FrameEventHandler(Gorgon_Idle);
                Gorgon.FastResize = false;

                //Gorgon.FrameStatsVisible = true;

                input = Input.LoadInputPlugIn(Environment.CurrentDirectory + @"\GorgonInput.DLL", "Gorgon.RawInput");
                input.Bind(this);

                keyboard           = input.Keyboard;
                keyboard.Enabled   = true;
                keyboard.Exclusive = false;
                keyboard.KeyDown  += keyboard_KeyDown;

                string   reason;
                FileInfo fileInfo = new FileInfo(Path.Combine(dataset.FullName, "configuration.xml"));
                if (!GameConfiguration.Initialize(fileInfo, out reason))
                {
                    MessageBox.Show(string.Format("Error loading configuration, reason: {0}", reason));
                    Close();
                    return;
                }

                gameMain = new GameMain();

                if (!gameMain.Initalize(Gorgon.Screen.Width, Gorgon.Screen.Height, dataset, showTutorial, this, out reason))
                {
                    MessageBox.Show(string.Format("Error loading game resources, error message: {0}", reason));
                    Close();
                    return;
                }

                Gorgon.Go();
            }
            catch (Exception exception)
            {
                HandleException(exception);
            }
        }