public TestRendering(IoCContainer container) { camera = new Camera2D(); RenderDelegateChainStep renderStep = new RenderDelegateChainStep("TestRendering", Render); container.Resolve<IUIRenderChain>().RegisterStep(renderStep); IInput input = container.Resolve<IInput>(); input.AddBinding(string.Empty, false, false, false, System.Windows.Forms.Keys.Up, null, (s, e) => { camera.Position += Vector3.UnitY; }); input.AddBinding(string.Empty, false, false, false, System.Windows.Forms.Keys.Down, null, (s, e) => { camera.Position -= Vector3.UnitY; }); input.AddBinding(string.Empty, false, false, false, System.Windows.Forms.Keys.Left, null, (s, e) => { camera.Position += Vector3.UnitX; }); input.AddBinding(string.Empty, false, false, false, System.Windows.Forms.Keys.Right, null, (s, e) => { camera.Position -= Vector3.UnitX; }); IDeviceContextService deviceContextService = container.Resolve<IDeviceContextService>(); DeviceContext context = deviceContextService.Context; deviceContextService.Form.ResizeEnd += new EventHandler(Form_ResizeEnd); _texture = Texture2D.FromFile(context, "Resources\\Helix.jpg", Usage.None, Pool.Managed); _elements = new TexturedElement[250]; for (int i = 0; i < _elements.Length; i++) { _elements[i] = new TexturedElement(new SharpDX.Vector2(50, 50)); _elements[i].Position = new Vector2(i * 20, i * 20); } _vertices = new Vertices<VertexPositionTexture>(context, new VertexPositionTexture() { Position = new Vector3(-0.5f, -0.5f, 0), TextureCoordinate = new Vector2(0, 0) }, new VertexPositionTexture() { Position = new Vector3(-0.5f, 0.5f, 0), TextureCoordinate = new Vector2(1, 0) }, new VertexPositionTexture() { Position = new Vector3( 0.5f, -0.5f, 0), TextureCoordinate = new Vector2(0, 1) }, new VertexPositionTexture() { Position = new Vector3( 0.5f, 0.5f, 0), TextureCoordinate = new Vector2(1, 1) }); }
public TestRendering(IoCContainer container) { camera = new Camera2D(); RenderDelegateChainStep renderStep = new RenderDelegateChainStep("TestRendering", Render); container.Resolve <IUIRenderChain>().RegisterStep(renderStep); IInput input = container.Resolve <IInput>(); input.AddBinding(string.Empty, false, false, false, System.Windows.Forms.Keys.Up, null, (s, e) => { camera.Position += Vector3.UnitY; }); input.AddBinding(string.Empty, false, false, false, System.Windows.Forms.Keys.Down, null, (s, e) => { camera.Position -= Vector3.UnitY; }); input.AddBinding(string.Empty, false, false, false, System.Windows.Forms.Keys.Left, null, (s, e) => { camera.Position += Vector3.UnitX; }); input.AddBinding(string.Empty, false, false, false, System.Windows.Forms.Keys.Right, null, (s, e) => { camera.Position -= Vector3.UnitX; }); IDeviceContextService deviceContextService = container.Resolve <IDeviceContextService>(); DeviceContext context = deviceContextService.Context; deviceContextService.Form.ResizeEnd += new EventHandler(Form_ResizeEnd); _texture = Texture2D.FromFile(context, "Resources\\Helix.jpg", Usage.None, Pool.Managed); _elements = new TexturedElement[250]; for (int i = 0; i < _elements.Length; i++) { _elements[i] = new TexturedElement(new SharpDX.Vector2(50, 50)); _elements[i].Position = new Vector2(i * 20, i * 20); } _vertices = new Vertices <VertexPositionTexture>(context, new VertexPositionTexture() { Position = new Vector3(-0.5f, -0.5f, 0), TextureCoordinate = new Vector2(0, 0) }, new VertexPositionTexture() { Position = new Vector3(-0.5f, 0.5f, 0), TextureCoordinate = new Vector2(1, 0) }, new VertexPositionTexture() { Position = new Vector3(0.5f, -0.5f, 0), TextureCoordinate = new Vector2(0, 1) }, new VertexPositionTexture() { Position = new Vector3(0.5f, 0.5f, 0), TextureCoordinate = new Vector2(1, 1) }); }