示例#1
0
        /// <summary>
        /// Initializes the device.
        /// </summary>
        public static void Initialize(Control renderTarget, Pool.Pool pool)
        {
            tagPool = pool;
            if (d3dInitialized)
            {
                MdxRender.Device.Dispose();
            }

            RenderCore.renderTarget = renderTarget;
            int adapter = Manager.Adapters.Default.Adapter;

            caps = Manager.GetDeviceCaps(adapter, DeviceType);

            pp.PresentationInterval   = PresentInterval.Default;
            pp.Windowed               = true;// !MdxRender.FullScreen;
            pp.SwapEffect             = SwapEffect.Discard;
            pp.EnableAutoDepthStencil = true;
            pp.AutoDepthStencilFormat = GetDepthFormat(adapter);
            //pp.MultiSample = GetMultiSampleType(adapter);
            //pp.MultiSampleQuality = 0;

            CreateFlags flags;

            flags = CreateFlags.SoftwareVertexProcessing;
            if (caps.DeviceCaps.SupportsHardwareTransformAndLight)
            {
                flags = CreateFlags.HardwareVertexProcessing;
            }

            // Disable built in events.

            Device.IsUsingEventHandlers = false;
            MdxRender.Device            = new Device(adapter, DeviceType, renderTarget, flags, pp);
            SetupDevice();

            //MdxRender.Device.DeviceResizing += new System.ComponentModel.CancelEventHandler(device_DeviceResizing);
            //MdxRender.Device.DeviceReset += new EventHandler(device_DeviceReset);

            camera = new Camera.Camera();
            MdxRender.FrameTimer = new FPSCounter(50);
            SelectTool.InitializeHandleModel();
            Billboard.LoadResources(0.5f, 0.5f);
            fontFPS   = new DXFont(MdxRender.Device, new Font("Arial", 12, FontStyle.Bold));
            DebugFont = new Microsoft.DirectX.Direct3D.Font(MdxRender.Device, new Font("Arial", 12, FontStyle.Bold));
            console   = new DebugConsole.DebugConsole(MdxRender.Device);

            d3dInitialized = true;
        }