Пример #1
0
        private void DrawGameObjects()
        {
            // Only draw within camera frustum
            // Frustum Culling
            foreach (SimpleModel go in _gameObjects)
            {
                if (FrustumContains(go))
                {
                    go.Draw(MainCamera);
                }
            }

            _debug.Draw(MainCamera);

            DrawUI();
        }
Пример #2
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black); //Using black to illustrate colors better

            if (!FourKToggle)
            {
                GraphicsDevice.SetRenderTarget(null);
            }
            else
            {
                GraphicsDevice.SetRenderTarget(FourK_RT);

                //Below lines needed to avoid backfaces being rendered in front of object during spritebatch draw
                GraphicsDevice.DepthStencilState = DepthStencilState.Default;
                GraphicsDevice.BlendState        = BlendState.Opaque;
            }


            //Model Rendering
            foreach (CustomEffectModel model in gameObjects)
            {
                if (mainCamera.Frustum.Contains(model.AABB) != ContainmentType.Disjoint)
                {
                    model.Draw(mainCamera);
                }
            }

            debug.Draw(mainCamera);


            GraphicsDevice.SetRenderTarget(null);

            //4K spritebatch
            if (FourKToggle)
            {
                spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque);
                spriteBatch.Draw(FourK_RT, GraphicsDevice.Viewport.Bounds, Color.White);
                spriteBatch.DrawString(debugFont, "Drawing @ 4K", new Vector2(10, 10), Color.White);
                spriteBatch.End();
            }

            GameUtilities.SetGraphicsDeviceFor3D();

            base.Draw(gameTime);
        }
Пример #3
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            foreach (var gameObject in gameObjects)
            {
                if (FrustumContains((gameObject as SimpleModel).AABB))
                {
                    gameObject.Draw(mainCamera);
                }
            }

            debug.Draw(mainCamera);

            spriteBatch.Begin();
            spriteBatch.End();

            GameUtilities.SetGraphicsDeviceFor3D();

            base.Draw(gameTime);
        }
Пример #4
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.HotPink);

            debug.Draw(mainCamera);

            time.Reset();

            foreach (SimpleModel item in gameObjects)
            {
                if (FrustumContains(item))
                {
                    if (!IsOccluded(item))
                    {
                        item.Draw(mainCamera);
                        objectsDrawn++;
                    }
                }
            }
            spriteBatch.Begin();

            spriteBatch.DrawString(
                sfont,
                "Objects Drawn: " + objectsDrawn + " Occlusion Time: " + totalTime,
                new Vector2(10, 10),
                Color.White);

            spriteBatch.End();

            objectsDrawn = 0;
            totalTime    = 0;

            GameUtilities.SetGraphicsDeviceFor3D();

            base.Draw(gameTime);
        }