Пример #1
0
		private void myDrawingSurface_Draw( object sender, DrawEventArgs e )
		{
			// Render scene
			//sample.Go();
			// Let's go for another turn!
			e.InvalidateSurface();
		}
Пример #2
0
        private void DrawScene(Scene scene, DrawEventArgs e)
        {
            if (_isSoftwareRendered) return;

            ProcessKeyboardInput(scene);
            scene.Draw();
            // invalidate to get a callback next frame
            e.InvalidateSurface();
        }
        private void myDrawingSurface_Draw(object sender, DrawEventArgs e)
        {
            this.appReference.MainViewModel.Manager.Tick();

            // Render scene
            scene.Draw();

            // Let's go for another turn!
            e.InvalidateSurface();
        }
Пример #4
0
        private void SurfaceOnDraw(object sender, DrawEventArgs args)
        {
            var graphicsDevice = GraphicsDeviceManager.Current.GraphicsDevice;

            graphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, 1.0f, 0);
            graphicsDevice.RasterizerState = RasterizerState.CullNone;
            graphicsDevice.BlendState = BlendState.AlphaBlend;

            graphicsDevice.DepthStencilState = DepthStencilState.Default;

            if (this.ApplicationViewModel.Image != null)
            {
                this.ApplicationViewModel.Image.Draw(GraphicsDeviceManager.Current.GraphicsDevice, aspectRatio);
            }

            args.InvalidateSurface();
        }
Пример #5
0
        private void OnDraw(object sender, DrawEventArgs e)
        {
            GraphicsDevice graphicsDevice = GraphicsDeviceManager.Current.GraphicsDevice;

            Color cornflowerBlue = new Color(0x64, 0x95, 0xED, 0xFF);

            graphicsDevice.Clear(cornflowerBlue);

            // Calculate the camera matrices.
            float time = (float)e.TotalTime.TotalSeconds;

            Matrix world = Matrix.CreateRotationX(time * 0.3f) *
                           Matrix.CreateRotationY(time);

            Matrix view = Matrix.CreateLookAt(new Vector3(4000, 0, 0),
                                              Vector3.Zero,
                                              Vector3.Up);

            Matrix projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4,
                                                                    graphicsDevice.Viewport.AspectRatio,
                                                                    10, 10000);

            // Configure effect parameters.
            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (EnvironmentMapEffect effect in mesh.Effects)
                {
                    effect.EnableDefaultLighting();

                    effect.EnvironmentMapAmount   = currentEnvMap;
                    effect.EnvironmentMapSpecular = specularColor * currentSpecular;
                    effect.FresnelFactor          = currentFresnel;
                }
            }

            // Draw the model.
            model.Draw(world, view, projection);

            // Force a redraw so this control will continuously animate.
            e.InvalidateSurface();
        }
Пример #6
0
        private void Surface_Draw(object sender, DrawEventArgs e)
        {
            if (surfaceLoaded)
            {
                gameTime.ElapsedGameTime = e.DeltaTime;
                gameTime.TotalGameTime   = e.TotalTime;

                Update(gameTime);
                Components.Update(gameTime);

                if (!suppressDraw && BeginDraw())
                {
                    Draw(gameTime);
                    Components.Draw(gameTime);
                    EndDraw();
                }
                suppressDraw = false;

                e.InvalidateSurface();
            }
        }
Пример #7
0
        private void OnDraw(object sender, DrawEventArgs e)
        {
            float time = (float)e.TotalTime.TotalSeconds;

            // Update the animation properties on the tank object. In a real game
            // you would probably take this data from user inputs or the physics
            // system, rather than just making everything rotate like this!

            tank.WheelRotation  = time * 5;
            tank.SteerRotation  = (float)Math.Sin(time * 0.75f) * 0.5f;
            tank.TurretRotation = (float)Math.Sin(time * 0.333f) * 1.25f;
            tank.CannonRotation = (float)Math.Sin(time * 0.25f) * 0.333f - 0.333f;
            tank.HatchRotation  = MathHelper.Clamp((float)Math.Sin(time * 2) * 2, -1, 0);

            GraphicsDevice graphicsDevice = GraphicsDeviceManager.Current.GraphicsDevice;

            Color darkGray = new Color(0xA9, 0xA9, 0xA9, 0xFF);

            graphicsDevice.Clear(darkGray);

            // Calculate the camera matrices.
            Matrix rotation = Matrix.CreateRotationY(time * 0.1f);

            Matrix view = Matrix.CreateLookAt(new Vector3(1000, 500, 0),
                                              new Vector3(0, 150, 0),
                                              Vector3.Up);

            Matrix projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4,
                                                                    graphicsDevice.Viewport.AspectRatio,
                                                                    10,
                                                                    10000);

            // Draw the tank model.
            tank.Draw(rotation, view, projection);

            // Force a redraw so this control will continuously animate.
            e.InvalidateSurface();
        }
        private void OnDraw(object sender, DrawEventArgs e)
        {
            try
            {
                if (!_exception)
                {
                    _game.Tick(e.DeltaTime, e.TotalTime);
                    e.InvalidateSurface();
                }
            }
            catch (Exception ex)
            {
                if (!_exception)
                {
                    _exception = true;

                    Dispatcher.BeginInvoke(() =>
                    {
                        throw new EngineException(ex);
                    });
                }
            }
        }
Пример #9
0
        private void OnDraw(object sender, DrawEventArgs e)
        {
            try
            {
                if (!_exception)
                {
                    _game.Tick(e.DeltaTime, e.TotalTime);
                    e.InvalidateSurface();
                }
            }
            catch (Exception ex)
            {
                if (!_exception)
                {
                    _exception = true;

                    Dispatcher.BeginInvoke(() =>
                    {
                        throw new EngineException(ex);
                    });
                }
            }
        }
Пример #10
0
        void drawingSurface_Draw(object sender, DrawEventArgs e)
        {
            if (!startingUp && GraphicsDevice.ScissorRectangle.Width > 1)
            {
                if (applyChanges)
                {
                    SetSize();
                    applyChanges = false;
                }

                if (!_initialized)
                {
                    Initialize();
                    _initialized = true;
                }

                if (_currentState == States.Done) return;

                TimeSpan delta = e.DeltaTime;
                delta += leftoverTime;
                if (resetElapsedTime)
                {
                    delta = TimeSpan.Zero;
                    resetElapsedTime = false;
                }

                drawGameTime.ElapsedGameTime = delta;
                drawGameTime.TotalGameTime += delta;
                if (IsFixedTimeStep)
                {
                    var dt = this.TargetElapsedTime;
                    while (delta > dt)
                    {
                        updateGameTime.ElapsedGameTime = dt;
                        updateGameTime.TotalGameTime += dt;
                        Update(updateGameTime);
                        delta -= dt;
                    }
                    leftoverTime = delta;
                }
                else
                {
                    updateGameTime.ElapsedGameTime = delta;
                    updateGameTime.TotalGameTime += delta;
                    if (updateGameTime.ElapsedGameTime > TimeSpan.Zero) Update(updateGameTime);
                }


                bool ret = BeginDraw();
                if (ret == true)
                {
                    Draw(drawGameTime);
                    EndDraw();
                }
            }
            e.InvalidateSurface();
        }
Пример #11
0
        private void myDrawingSurface_Draw(object sender, DrawEventArgs e)
        {
            //show render info
            sysInfo.Dispatcher.BeginInvoke(() => { sysInfo.Text = string.Format("FPS:{0} Duratioin:{1}", (int)(1000 / e.DeltaTime.TotalMilliseconds), e.TotalTime); });

            //Render scene
            scene.Draw();

            e.InvalidateSurface();
        }
        private void updateAndRender(object sender, DrawEventArgs e)
        {
            if (!shown)
            {
                shown = true;
                OS.time = new Time(0);
                application.GraphicsDevice = GraphicsDeviceManager.Current.GraphicsDevice;
                application.Shown();
            }

            OS.time.ManualUpdate(e.DeltaTime.Milliseconds / 1000f);
            application.Update(OS.time);
            application.Render(OS.time);
            e.InvalidateSurface();
        }
Пример #13
0
        private void myDrawingSurface_Draw(object sender, DrawEventArgs e)
        {
            game.state.Update(e);
            game.state.Draw(e);

            ThreadPool.QueueUserWorkItem(o =>
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    lScore.Content = Player.Score;
                }));
            });

            ThreadPool.QueueUserWorkItem(o =>
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    label1.Content = Player.LivesLeft;
                }));
            });

            if (Player.LivesLeft == 0)
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    this.Content = new GameOver();
                }));
            }
            e.InvalidateSurface();
        }
Пример #14
0
        private void DrawingSurface_Draw(object sender, DrawEventArgs e)
        {
            GraphicsDeviceManager.Current.GraphicsDevice.Textures[0] = null;

            for (int x = 0; x < 640 - 1; x++)
            {
                for (int y = 0; y < 320 - 1; y++)
                {
                    screenData[x + y * 640] = (UInt32)((0x50 << 24)
                        | (cpu.ScreenData[y, x, 0] & 0xFF) << 8);
                }
            }

            texture.SetData(screenData);

            spriteBatch.Begin();

            spriteBatch.Draw(texture, new Vector2(0, 0), new Color(255, 255, 255));

            spriteBatch.End();

            e.InvalidateSurface();
        }
Пример #15
0
      void DrawingSurfaceDraw(object sender, DrawEventArgs e)
      {
         try
         {
            var scaledDeltaSeconds = e.DeltaTime.TotalSeconds * rotationSpeed;
            totalElapsedTime += TimeSpan.FromSeconds(scaledDeltaSeconds);

            GraphicsDeviceManager.Current.GraphicsDevice.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, TransparentColor, 1.0f, 0);

            Sun.Draw(GraphicsDeviceManager.Current.GraphicsDevice, totalElapsedTime, camera);
            Earth.LightPosition = Sun.Position;
            Earth.Draw(GraphicsDeviceManager.Current.GraphicsDevice, totalElapsedTime, camera);

            e.InvalidateSurface();
         }
         catch (Exception)
         {
            MessageBox.Show(@"Could not initialize the 3D rendering. Please ensure 3D rendering is allowed.

1. Right click on your Silverlight plugin.
2. Go to the permissions tab.
3. Find the domain that hosts the XAP file.
4. Mark the XAP-Domain and click Allow.");
         }
      }