Example #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            texture = new Texture2D(GraphicsDevice, WIDTH, HEIGHT);
            camera  = new Camera(new Vector3(5, 5, 6), new Vector3(0, 0, 0));

            Color[] colors = new Color[WIDTH * HEIGHT];

            for (int x = 0; x < WIDTH; x++)
            {
                for (int y = 0; y < HEIGHT; y++)
                {
                    colors[x + y * WIDTH] = new Color(0, 0, 0);
                }
            }

            texture.SetData(colors);

            ImageGenerator.CompileKernel();

            Mouse.SetPosition(WIDTH / 2, HEIGHT / 2);
            //IsMouseVisible = false;

            base.Initialize();
        }
Example #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.CornflowerBlue);

            camera.Position = newCamPos;

            Color[] colors = ImageGenerator.CalcGPU(WIDTH, HEIGHT, camera, null);

            texture.SetData(colors);


            spriteBatch.Begin();
            spriteBatch.Draw(texture, new Rectangle(0, 0, WIDTH, HEIGHT), Color.White);
            spriteBatch.End();

            /*effect.Parameters["campos"].SetValue(camera.Position);
             * effect.Parameters["near"].SetValue(camera.Near);
             * effect.Parameters["left"].SetValue(camera.Left);
             * effect.Parameters["up"].SetValue(camera.Up);
             * effect.Parameters["forward"].SetValue(camera.Forward);
             * effect.Parameters["width"].SetValue(WIDTH);
             * effect.Parameters["height"].SetValue(HEIGHT);
             * //effect.Parameters["interations"].SetValue(50);
             *
             * spriteBatch.Begin(effect: effect);
             * spriteBatch.Draw(texture, new Rectangle(0, 0, WIDTH, HEIGHT), Color.White);
             * spriteBatch.End();
             * // TODO: Add your drawing code here
             */
            base.Draw(gameTime);
        }