Beispiel #1
0
        private Game()
        {
            formWindow = new Window(1024, 768);
            InputManager.ManageInput(formWindow);
            clock = new Clock();
            clock.Start();
            debug = new dlgDebug();

            Ellipse e = new Ellipse();
            e.Scale = new Vector3(20, 10, 1);
            e.RotationVelocity = new Vector3(0, 0, 1);
            ObjectManager.AddPositionedObject(e);
        }
Beispiel #2
0
 public static void ManageInput(Window window)
 {
     Mouse.Manage(window);
     Keyboard.Manage(window);
 }
Beispiel #3
0
 public void Manage(Window window)
 {
     SlimDX.RawInput.Device.RegisterDevice(UsagePage.Generic, UsageId.Keyboard, SlimDX.RawInput.DeviceFlags.None);
     SlimDX.RawInput.Device.KeyboardInput += Device_KeyboardInput;
 }
Beispiel #4
0
        public static Device GetDevice(Window window)
        {
            Device d = new Device();
            d.vertexShaders = new List<VertexShader>();
            d.pixelShaders = new List<PixelShader>();
            d.window = window;
            window.Form.UserResized += d.Form_Resize;
            window.Form.KeyDown += d.Key_Down;
            d.description = new SwapChainDescription()
            {
                BufferCount = 2,
                Usage = Usage.RenderTargetOutput,
                OutputHandle = window.Form.Handle,
                IsWindowed = true,
                ModeDescription = new ModeDescription(0, 0, new Rational(60, 1), Format.R8G8B8A8_UNorm),
                SampleDescription = new SampleDescription(1, 0),
                Flags = SwapChainFlags.AllowModeSwitch,
                SwapEffect = SwapEffect.Discard
            };
            SlimDX.Direct3D11.Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, d.description, out d.device, out d.swapChain);

            using (var resource = SlimDX.Direct3D11.Resource.FromSwapChain<Texture2D>(d.swapChain, 0))
            {
                d.renderTarget = new RenderTargetView(d.device, resource);
            }

            d.context = d.device.ImmediateContext;
            d.viewport = new Viewport(0.0f, 0.0f, window.Width, window.Height);

            d.context.OutputMerger.SetTargets(d.renderTarget);
            d.context.Rasterizer.SetViewports(d.viewport);

            d.halfWidth = window.Width / 2;
            d.halfHeight = window.Height / 2;

            /*
            using (var bytecode = ShaderBytecode.CompileFromFile("Graphics/Shaders/default.fx", "VS", "vs_4_0", ShaderFlags.None, EffectFlags.None))
            {
                d.inputSignature = ShaderSignature.GetInputSignature(bytecode);
                var  vertexShader = new VertexShader(d.device, bytecode);
                d.vertexShaders.Add(vertexShader);
            }
            using (var bytecode = ShaderBytecode.CompileFromFile("Graphics/Shaders/default.fx", "PS", "ps_4_0", ShaderFlags.None, EffectFlags.None))
            {
                var pixelShader = new PixelShader(d.device, bytecode);
                d.pixelShaders.Add(pixelShader);
            }

            d.context.VertexShader.Set(d.vertexShaders.First());
            d.context.PixelShader.Set(d.pixelShaders.First());

            d.inputLayout = new InputLayout(d.device, d.inputSignature, new[] {
                new InputElement("POSITION", 0, SlimDX.DXGI.Format.R32G32B32_Float, 0),
                new InputElement("COLOR", 0, SlimDX.DXGI.Format.R8G8B8A8_UNorm, InputElement.AppendAligned, 0)
            });

            d.context.InputAssembler.InputLayout = d.inputLayout;
            d.context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
            */
            //d.context.I

            using (var factory = d.swapChain.GetParent<Factory>()) factory.SetWindowAssociation(d.window.Form.Handle, WindowAssociationFlags.IgnoreAltEnter);
            return d;
        }
Beispiel #5
0
 public void Manage(Window window)
 {
 }