Ejemplo n.º 1
0
        public void Main(string[] args)
        {
            using (AgateSetup setup = new AgateSetup(args))
            {
                setup.AskUser = true;
                setup.Initialize(true, false, false);
                if (setup.WasCanceled)
                {
                    return;
                }

                frm = new PixelBufferForm();
                frm.Show();

                DisplayWindow wind = new DisplayWindow(CreateWindowParams.FromControl(frm.panel1));

                image  = new Surface("9ball.png");
                buffer = image.ReadPixels(PixelFormat.RGBA8888);

                Mouse.MouseDown += new InputEventHandler(Mouse_MouseDown);
                Mouse.MouseMove += new InputEventHandler(Mouse_MouseMove);

                while (wind.IsClosed == false)
                {
                    Display.BeginFrame();
                    Display.Clear();

                    image.Draw(imageLocation);

                    Display.EndFrame();
                    Core.KeepAlive();
                }
            }
        }
Ejemplo n.º 2
0
        private void InitDisplay()
        {
            // This will create a display "window" that renders to the graphics
            // control on this form
            DisplayWindow wind = new DisplayWindow(CreateWindowParams.FromControl(pctGraphics));

            // load an image
            string fileName = @"jellybean.png";


            mSurface = new Surface(fileName);
        }
Ejemplo n.º 3
0
        private bool InitDisplay()
        {
            // This will create a display "window" that renders to the graphics
            // control on this form
            // It doesn't matter if this goes out of scope, because a reference
            // will be maintained by the Display object.
            wind = new DisplayWindow(CreateWindowParams.FromControl(pctGraphics));

            //srcSurf = new Surface();

            SetSprite(new Sprite("attacke.png", 96, 96));

            Display.PackAllSurfaces();

            return(true);
        }
Ejemplo n.º 4
0
        public Form1()
        {
            InitializeComponent();

            Keyboard.KeyDown += new InputEventHandler(Keyboard_KeyDown);
            Keyboard.KeyUp   += new InputEventHandler(Keyboard_KeyUp);

            Mouse.MouseWheel       += new InputEventHandler(Mouse_MouseWheel);
            Mouse.MouseMove        += new InputEventHandler(Mouse_MouseMove);
            Mouse.MouseDown        += new InputEventHandler(Mouse_MouseDown);
            Mouse.MouseUp          += new InputEventHandler(Mouse_MouseUp);
            Mouse.MouseDoubleClick += new InputEventHandler(Mouse_MouseDoubleClickEvent);

            new DisplayWindow(CreateWindowParams.FromControl(agateRenderTarget1));

            Application.Idle += new EventHandler(Application_Idle);
        }
Ejemplo n.º 5
0
        public void Main(string[] args)
        {
            using (AgateSetup setup = new AgateSetup(args))
            {
                setup.AskUser = true;
                setup.Initialize(true, false, false);
                if (setup.WasCanceled)
                {
                    return;
                }

                LightingTestForm frm = new LightingTestForm();
                frm.Show();

                DisplayWindow wnd = new DisplayWindow(CreateWindowParams.FromControl(frm.agateRenderTarget1));

                Surface image = new Surface("jellybean.png");
                Surface ball  = new Surface("ball.png");
                Point   ballPt;
                double  time = 0;

                image.SetScale(2.0, 2.0);
                ball.DisplayAlignment = OriginAlignment.Center;

                LightManager lights = new LightManager();
                lights.Enabled = true;
                lights.AddPointLight(new Vector3(0, 0, -1), Color.White);
                lights.AddPointLight(new Vector3(0, 0, -1), Color.Yellow);

                Display.VSync = false;

                //lights[0].Ambient = Color.White;
                lights[1].AttenuationConstant  = 0.01f;
                lights[1].AttenuationQuadratic = 5e-7f;

                Mouse.MouseMove += delegate(InputEventArgs e)
                {
                    lights[1].Position =
                        new Vector3(e.MousePosition.X, e.MousePosition.Y, -1);
                };

                while (frm.Visible == true)
                {
                    if (frm.chkMoveLight.Checked)
                    {
                        time += Display.DeltaTime / 1000.0;
                    }


                    ballPt = new Point((int)(120 + 110 * Math.Cos(time)),
                                       (int)(120 + 110 * Math.Sin(time)));

                    lights[0].Position = new Vector3(ballPt.X, ballPt.Y, -1);
                    lights[0].Ambient  = Color.FromArgb(frm.btnAmbient.BackColor.ToArgb());
                    lights[0].Diffuse  = Color.FromArgb(frm.btnDiffuse.BackColor.ToArgb());

                    image.RotationAngleDegrees = (double)frm.nudAngle.Value;

                    Display.BeginFrame();
                    Display.Clear(Color.DarkRed);

                    lights.Enabled = frm.enableLightingCheck.Checked;
                    lights.DoLighting();

                    if (frm.chkSurfaceGradient.Checked)
                    {
                        Gradient g = new Gradient(Color.Red, Color.Blue, Color.Cyan, Color.Green);

                        image.ColorGradient = g;
                    }
                    else
                    {
                        image.Color = Color.White;
                    }

                    image.TesselateFactor = (int)frm.nudTess.Value;

                    image.Draw(50, 50);

                    image.Draw(50 + image.DisplayWidth, 50);
                    image.Draw(50, 50 + image.DisplayHeight);

                    ball.Draw(ballPt);

                    Display.EndFrame();
                    Core.KeepAlive();

                    frm.lblFPS.Text = "FPS: " + Display.FramesPerSecond.ToString("0.00");
                }
            }
        }