コード例 #1
0
ファイル: AGT_CanvasControl.cs プロジェクト: wshanshan/DDD
        private void InitializeGameFramework()
        {
            parm = new DeviceParams();

            DeviceCaps _device_caps = AGT_GameFramework.GetDeviceCapabilities().DeviceCaps;

            parm.ClrFlags = ClearFlags.Target | ClearFlags.ZBuffer;
            parm.ZDepth = 1.0f;
            parm.Stencil = 0;
            parm.TargetControl = this;

            parm.OnResize = new DeviceResizeHandler(OnResize);

            parm.PresentationParameters = new PresentParameters();
            parm.PresentationParameters.Windowed = true;
            parm.PresentationParameters.SwapEffect = SwapEffect.Discard;

            if (parm.PresentationParameters.Windowed)
            {
                parm.PresentationParameters.PresentationInterval = PresentInterval.Default;
                parm.PresentationParameters.EnableAutoDepthStencil = true;
                parm.PresentationParameters.AutoDepthStencilFormat = DepthFormat.D16;
            }
            else
            {
                parm.PresentationParameters.PresentationInterval = PresentInterval.Immediate;
                parm.PresentationParameters.EnableAutoDepthStencil = false;
                parm.PresentationParameters.BackBufferCount = 1;
                parm.PresentationParameters.BackBufferHeight = Microsoft.DirectX.Direct3D.Manager.Adapters.Default.CurrentDisplayMode.Height;
                parm.PresentationParameters.BackBufferWidth = Microsoft.DirectX.Direct3D.Manager.Adapters.Default.CurrentDisplayMode.Width;
                parm.PresentationParameters.BackBufferFormat = Microsoft.DirectX.Direct3D.Manager.Adapters.Default.CurrentDisplayMode.Format;
            }

            if (_device_caps.SupportsHardwareTransformAndLight)
            {
                parm.Flags = CreateFlags.HardwareVertexProcessing;
                if (_device_caps.SupportsPureDevice)
                {
                    parm.Flags |= CreateFlags.PureDevice;
                    parm.Flags |= CreateFlags.MultiThreaded;
                }
            }
            else
            {
                parm.Flags = CreateFlags.SoftwareVertexProcessing;
                parm.Flags |= CreateFlags.MultiThreaded;
            }

            gf = new AGT_GameFramework(parm);
        }
コード例 #2
0
        public AGT_GameFramework(DeviceParams parameters)
        {
            if (parameters == DeviceParams.Empty)
            {
                throw new ArgumentException("Empty Device Parameters");
            }
            if (parameters.PresentationParameters == null)
            {
                throw new ArgumentException("Missing PresentationParameters, in DeviceParams");
            }
            if (parameters.TargetControl == null)
            {
                throw new ArgumentException("Missing TargetControl, in DeviceParams");
            }

            _AppIdleHandler = new EventHandler(this.Application_Idle);

            AGT_Scene.QueryPerformanceFrequency(ref _ticks_per_second);
            _DeviceParams_ = parameters;
            BindFormEvents();

            _VIDEO_DEVICE_ = new Microsoft.DirectX.Direct3D.Device(
                Microsoft.DirectX.Direct3D.Manager.Adapters.Default.Adapter,
                Microsoft.DirectX.Direct3D.DeviceType.Hardware,
                parameters.TargetControl,
                parameters.Flags,
                parameters.PresentationParameters);

            _SystemImages = new AGT_SystemImages(_VIDEO_DEVICE_);
            Cursor        = _SystemImages.Cursor_Select;

            _device_lost   = new EventHandler(_DEVICE__DeviceLost);
            _device_reset  = new EventHandler(_DEVICE__DeviceReset);
            _device_resize = new System.ComponentModel.CancelEventHandler(_DEVICE__DeviceResizing);

            _VIDEO_DEVICE_.DeviceLost     += _device_lost;
            _VIDEO_DEVICE_.DeviceReset    += _device_reset;
            _VIDEO_DEVICE_.DeviceResizing += _device_resize;
        }
コード例 #3
0
ファイル: AGT_GameFramework.cs プロジェクト: wshanshan/DDD
        public AGT_GameFramework(DeviceParams parameters) {

            if (parameters == DeviceParams.Empty)
            {
                throw new ArgumentException("Empty Device Parameters");
            }
            if (parameters.PresentationParameters == null)
            {
                throw new ArgumentException("Missing PresentationParameters, in DeviceParams");
            }
            if (parameters.TargetControl == null)
            {
                throw new ArgumentException("Missing TargetControl, in DeviceParams");
            }

            _AppIdleHandler = new EventHandler(this.Application_Idle);
            
            AGT_Scene.QueryPerformanceFrequency(ref _ticks_per_second);
            _DeviceParams_ = parameters;
            BindFormEvents();

            _VIDEO_DEVICE_ = new Microsoft.DirectX.Direct3D.Device(
                Microsoft.DirectX.Direct3D.Manager.Adapters.Default.Adapter,
                Microsoft.DirectX.Direct3D.DeviceType.Hardware,
                parameters.TargetControl,
                parameters.Flags,
                parameters.PresentationParameters);

            _SystemImages = new AGT_SystemImages(_VIDEO_DEVICE_);
            Cursor = _SystemImages.Cursor_Select;

            _device_lost = new EventHandler(_DEVICE__DeviceLost);
            _device_reset = new EventHandler(_DEVICE__DeviceReset);
            _device_resize = new System.ComponentModel.CancelEventHandler(_DEVICE__DeviceResizing);

            _VIDEO_DEVICE_.DeviceLost += _device_lost;
            _VIDEO_DEVICE_.DeviceReset += _device_reset;
            _VIDEO_DEVICE_.DeviceResizing += _device_resize;

        }