コード例 #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;
        }
コード例 #2
0
        public bool InitMdx()
        {
            Dev = new Device(MdxRender.DeviceInfo.default_adapter, DeviceType.Hardware,
                             MdxRender.DeviceInfo.renderWin, MdxRender.DeviceInfo.flags, MdxRender.DeviceInfo.pp);

            MdxRender.SM    = new ShaderManager();
            MdxRender.MM    = new ModelManager();
            MdxRender.Input = new InputManager();
            SelectTool.InitializeHandleModel();
            SelectionBox.Initialize();
            ProjectManager.MapSpawns.InitDebug();
            ShaderBase.InitializeDebug();
            mapViewButton = new RenderButton();
            //mapViewButton.Width = MdxRender.DeviceInfo.renderWin.Width;
            //mapViewButton.Height = MdxRender.DeviceInfo.renderWin.Height;
            mapViewButton.Initialize(35, 35, 15, 40);

            //set up lights that don't work
            SetupLights();

            whiteMaterial         = new Material();
            whiteMaterial.Ambient = Color.White;
            whiteMaterial.Diffuse = Color.White;
            //whiteMaterial.Emissive = Color.White;

            //Set up texture filtering to get rid of blocky uglies
            MdxRender.Dev.SamplerState[0].MagFilter = TextureFilter.Linear;
            MdxRender.Dev.SamplerState[0].MinFilter = TextureFilter.Linear;
            MdxRender.Dev.SamplerState[0].MipFilter = TextureFilter.Linear;
            MdxRender.Dev.SamplerState[1].MagFilter = TextureFilter.Linear;
            MdxRender.Dev.SamplerState[1].MinFilter = TextureFilter.Linear;
            MdxRender.Dev.SamplerState[1].MipFilter = TextureFilter.Linear;
            MdxRender.Dev.SamplerState[2].MagFilter = TextureFilter.Linear;
            MdxRender.Dev.SamplerState[2].MinFilter = TextureFilter.Linear;
            MdxRender.Dev.SamplerState[2].MipFilter = TextureFilter.Linear;
            MdxRender.Dev.SamplerState[3].MagFilter = TextureFilter.Linear;
            MdxRender.Dev.SamplerState[3].MinFilter = TextureFilter.Linear;
            MdxRender.Dev.SamplerState[3].MipFilter = TextureFilter.Linear;
            MdxRender.Dev.SamplerState[4].MagFilter = TextureFilter.Linear;
            MdxRender.Dev.SamplerState[4].MinFilter = TextureFilter.Linear;
            MdxRender.Dev.SamplerState[4].MipFilter = TextureFilter.Linear;

            MdxRender.Dev.RenderState.AlphaFunction = Compare.GreaterEqual;
            MdxRender.Dev.SetRenderState(RenderStates.ReferenceAlpha, 0x80);
            //UpdateGammaCorrection();

            //disable vsync, might get some tearing
            MdxRender.Dev.PresentationParameters.PresentationInterval = PresentInterval.Immediate;

            MdxRender.lightmapDebugger          = new GrenLightmapDebug();
            MdxRender.Dev.RenderState.PointSize = 10.0f;

            MdxRender.Dev.RenderState.CullMode      = Cull.CounterClockwise;
            MdxRender.Dev.RenderState.ZBufferEnable = true;
            MdxRender.Dev.DeviceResizing           += new System.ComponentModel.CancelEventHandler(device_DeviceResizing);
            MdxRender.Dev.DeviceReset += new EventHandler(device_DeviceReset);

            //Device.IsUsingEventHandlers = false;

            // Initialize the font
            m_fontFPS  = new D3D.Font(Dev, new Font("Arial", 12, FontStyle.Bold));
            consoleFPS = new D3D.Font(Dev, new Font("Arial", 10, FontStyle.Bold));

            // Initialize the camera placement and orientation
            Camera = new Camera();
            Camera.SetLookAt(new Vector3(-18, 0, 0), new Vector3());

            PreviewManager.Debug_LoadTestMesh();
            m_ready = true;

            return(false);
        }