simple free-flying camera boring-ness

This commit is contained in:
Gered 2013-08-18 14:20:42 -04:00
parent 19193ffd2f
commit 44a871f4e0

View file

@ -2,11 +2,16 @@ using System;
using PortableGL; using PortableGL;
using Blarg.GameFramework; using Blarg.GameFramework;
using Blarg.GameFramework.Graphics; using Blarg.GameFramework.Graphics;
using Blarg.GameFramework.Graphics.Helpers;
using Blarg.GameFramework.Support;
namespace Game namespace Game
{ {
public class GameApp : IGameApp public class GameApp : IGameApp
{ {
FlatWireframeGrid _grid;
FreeMovementCamera _camera;
public GameApp() public GameApp()
{ {
} }
@ -29,10 +34,16 @@ namespace Game
public void OnLoad() public void OnLoad()
{ {
_camera = new FreeMovementCamera(Platform.GraphicsDevice.ViewContext);
_camera.Position = new Vector3(0.0f, 5.0f, 0.0f);
Platform.GraphicsDevice.ViewContext.Camera = _camera;
_grid = new FlatWireframeGrid(Platform.GraphicsDevice, 32, 32);
} }
public void OnUnload() public void OnUnload()
{ {
Platform.GraphicsDevice.ViewContext.Camera = null;
} }
public void OnLostContext() public void OnLostContext()
@ -46,6 +57,13 @@ namespace Game
public void OnRender(float delta) public void OnRender(float delta)
{ {
Platform.GraphicsDevice.Clear(0.25f, 0.5f, 1.0f, 1.0f); Platform.GraphicsDevice.Clear(0.25f, 0.5f, 1.0f, 1.0f);
var shader = Platform.GraphicsDevice.SimpleColorShader;
Platform.GraphicsDevice.BindShader(shader);
shader.SetModelViewMatrix(Platform.GraphicsDevice.ViewContext.ModelViewMatrix);
shader.SetProjectionMatrix(Platform.GraphicsDevice.ViewContext.ProjectionMatrix);
_grid.Render();
Platform.GraphicsDevice.UnbindShader();
} }
public void OnResize(ScreenOrientation orientation, Rect size) public void OnResize(ScreenOrientation orientation, Rect size)
@ -56,6 +74,7 @@ namespace Game
{ {
if (Platform.Keyboard.IsPressed(Blarg.GameFramework.Input.Key.Escape)) if (Platform.Keyboard.IsPressed(Blarg.GameFramework.Input.Key.Escape))
Platform.Application.Quit(); Platform.Application.Quit();
_camera.OnUpdate(delta);
} }
public void Dispose() public void Dispose()