2013-08-17 15:15:24 -04:00
|
|
|
using System;
|
|
|
|
using PortableGL;
|
|
|
|
using Blarg.GameFramework;
|
|
|
|
using Blarg.GameFramework.Graphics;
|
2013-08-18 14:20:42 -04:00
|
|
|
using Blarg.GameFramework.Graphics.Helpers;
|
|
|
|
using Blarg.GameFramework.Support;
|
2013-08-17 15:15:24 -04:00
|
|
|
|
|
|
|
namespace Game
|
|
|
|
{
|
|
|
|
public class GameApp : IGameApp
|
|
|
|
{
|
2013-08-18 14:20:42 -04:00
|
|
|
FlatWireframeGrid _grid;
|
|
|
|
FreeMovementCamera _camera;
|
|
|
|
|
2013-08-17 15:15:24 -04:00
|
|
|
public GameApp()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnAppGainFocus()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnAppLostFocus()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnAppPause()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnAppResume()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnLoad()
|
|
|
|
{
|
2013-08-18 14:20:42 -04:00
|
|
|
_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);
|
2013-08-17 15:15:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public void OnUnload()
|
|
|
|
{
|
2013-08-18 14:20:42 -04:00
|
|
|
Platform.GraphicsDevice.ViewContext.Camera = null;
|
2013-08-17 15:15:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public void OnLostContext()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnNewContext()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnRender(float delta)
|
|
|
|
{
|
2013-08-18 12:59:55 -04:00
|
|
|
Platform.GraphicsDevice.Clear(0.25f, 0.5f, 1.0f, 1.0f);
|
2013-08-18 14:20:42 -04:00
|
|
|
|
|
|
|
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();
|
2013-08-17 15:15:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public void OnResize(ScreenOrientation orientation, Rect size)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnUpdate(float delta)
|
|
|
|
{
|
2013-08-17 18:00:34 -04:00
|
|
|
if (Platform.Keyboard.IsPressed(Blarg.GameFramework.Input.Key.Escape))
|
2013-08-17 18:06:24 -04:00
|
|
|
Platform.Application.Quit();
|
2013-08-18 14:20:42 -04:00
|
|
|
_camera.OnUpdate(delta);
|
2013-08-17 15:15:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|