Ejemplo n.º 1
0
        internal Renderer(LoopWindow Window)
        {
            var Levels = new[]
            {
                FeatureLevel.Level_11_0,
                FeatureLevel.Level_10_1,
                FeatureLevel.Level_10_0,
                FeatureLevel.Level_9_3,
                FeatureLevel.Level_9_2,
                FeatureLevel.Level_9_1,
            };

            Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.BgraSupport | (Program.DebugMode ? DeviceCreationFlags.Debug : DeviceCreationFlags.None), Levels, new SwapChainDescription
            {
                BufferCount     = 1,
                Flags           = SwapChainFlags.AllowModeSwitch,
                IsWindowed      = true,
                ModeDescription = new ModeDescription
                {
                    Format = FormatRGB
                },
                OutputHandle      = Window.Handle,
                SampleDescription = new SampleDescription(1, 0),
                SwapEffect        = SwapEffect.Discard,
                Usage             = Usage.RenderTargetOutput
            }, out Device, out SwapChain);


            var Bounds = System.Windows.Forms.Screen.PrimaryScreen.Bounds;

            using (var Factory = SwapChain.GetParent <Factory>())
            {
                foreach (var Output in Factory.Adapters.First().Outputs)
                {
                    foreach (var PossibleResolution in Output.GetDisplayModeList(FormatRGB, 0))
                    {
                        if (PossibleResolution.Width == Bounds.Width && PossibleResolution.Height == Bounds.Height)
                        {
                            Resolution = PossibleResolution;
                        }
                    }
                }
            }

            Window.Borderless(Resolution.Width, Resolution.Height);
            ResizeBuffers();

            Depth.InitStencilRasterState(Device);
            LoadWithAA(1);

            Device.ImmediateContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;

            if (Program.DebugMode)
            {
                Debug = new DeviceDebug(Device);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Show dialog for IF or LOOP to modify the sub-program.
 /// </summary>
 /// <param name="program">The program being modified, including IF ELSE END_IF and LOOP END_LOOP Instructions.</param>
 /// <param name="owner">The owner Window.</param>
 /// <returns>The modified HLProgram.</returns>
 public static HLProgram ShowDialog(HLProgram program, Window owner)
 {
     if (program[0].opcode == Instruction.IF)
     {
         IfWindow dlg = new IfWindow();
         dlg.Owner      = owner;
         dlg.SubProgram = program;
         dlg.ShowDialog();
         return(dlg.SubProgram);
     }
     else if (program[0].opcode == Instruction.LOOP)
     {
         LoopWindow dlg = new LoopWindow();
         dlg.Owner      = owner;
         dlg.SubProgram = program;
         dlg.ShowDialog();
         return(dlg.SubProgram);
     }
     return(null);
 }