示例#1
0
        public GraphicsDevice( IWindow window )
        {
            d3d = new SharpDX.Direct3D9.Direct3D ();

            IntPtr handle = ( window.Handle as System.Windows.Forms.Form ).Handle;
            this.window = window;

            d3dpp = new SharpDX.Direct3D9.PresentParameters ( 800, 600, SharpDX.Direct3D9.Format.A8R8G8B8,
                    1, SharpDX.Direct3D9.MultisampleType.None, 0, SharpDX.Direct3D9.SwapEffect.Discard,
                    handle, true, true, SharpDX.Direct3D9.Format.D24S8, SharpDX.Direct3D9.PresentFlags.None,
                    0, SharpDX.Direct3D9.PresentInterval.Immediate );

            try
            {
                d3dDevice = new SharpDX.Direct3D9.Device ( d3d, 0, SharpDX.Direct3D9.DeviceType.Hardware,
                        handle, SharpDX.Direct3D9.CreateFlags.HardwareVertexProcessing,
                        d3dpp );
            }
            catch
            {
                d3dDevice = new SharpDX.Direct3D9.Device ( d3d, 0, SharpDX.Direct3D9.DeviceType.Hardware,
                        handle, SharpDX.Direct3D9.CreateFlags.SoftwareVertexProcessing,
                        d3dpp );
            }

            Information = new GraphicsDeviceInformation ( d3d );
            BackBuffer = new BackBuffer ( this );

            ImmediateContext = new GraphicsContext ( this );
            //window.Resize += ( object sender, EventArgs e ) => { ResizeBackBuffer ( ( int ) window.ClientSize.X, ( int ) window.ClientSize.Y ); };
        }
示例#2
0
        /// <summary>	
        /// <p>Create an <see cref="SharpDX.Direct3D9.Direct3D"/> object and return an interface to it.</p>	
        /// </summary>	
        /// <param name="sDKVersion"><dd>  <p>The value of this parameter should be <see cref="SharpDX.Direct3D9.D3D9.SdkVersion"/>. See Remarks.</p> </dd></param>	
        /// <returns><p>If successful, this function returns a reference to an <strong><see cref="SharpDX.Direct3D9.Direct3D"/></strong> interface; otherwise, a <strong><c>null</c></strong> reference is returned.</p></returns>	
        /// <remarks>	
        /// <p>The Direct3D object is the first Direct3D COM object that your graphical application needs to create and the last object that your application needs to release. Functions for enumerating and retrieving capabilities of a device are accessible through the Direct3D object. This enables applications to select devices without creating them.</p><p>Create an <see cref="SharpDX.Direct3D9.Direct3D"/> object as shown here:</p><pre> LPDIRECT3D9 g_pD3D = <c>null</c>; if( <c>null</c> == (g_pD3D = Direct3DCreate9(<see cref="SharpDX.Direct3D9.D3D9.SdkVersion"/>))) return E_FAIL;	
        /// </pre><p>The <see cref="SharpDX.Direct3D9.Direct3D"/> interface supports enumeration of active display adapters and allows the creation of <strong><see cref="SharpDX.Direct3D9.Device"/></strong> objects. If the user dynamically adds adapters (either by adding devices to the desktop, or by hot-docking a laptop), those devices will not be included in the enumeration. Creating a new <see cref="SharpDX.Direct3D9.Direct3D"/> interface will expose the new devices.</p><p><see cref="SharpDX.Direct3D9.D3D9.SdkVersion"/> is passed to this function to ensure that the header files against which an application is compiled match the version of the runtime DLL's that are installed on the machine. <see cref="SharpDX.Direct3D9.D3D9.SdkVersion"/> is only changed in the runtime when a header change (or other code change) would require an application to be rebuilt. If this function fails, it indicates that the header file version does not match the runtime DLL version.</p><p>For an example, see Creating a Device (Direct3D 9).</p>	
        /// </remarks>	
        /// <include file='.\..\Documentation\CodeComments.xml' path="/comments/comment[@id='Direct3DCreate9']/*"/>	
        /// <msdn-id>bb219685</msdn-id>	
        /// <unmanaged>IDirect3D9* Direct3DCreate9([In] unsigned int SDKVersion)</unmanaged>	
        /// <unmanaged-short>Direct3DCreate9</unmanaged-short>	
        public static SharpDX.Direct3D9.Direct3D Create9(int sDKVersion) {
            unsafe {
                SharpDX.Direct3D9.Direct3D __result__;
                __result__= 
				new SharpDX.Direct3D9.Direct3D((IntPtr)Direct3DCreate9_(sDKVersion));		
                return __result__;
            }
        }
 public GraphicsDeviceInformation( SharpDX.Direct3D9.Direct3D d3d )
 {
     this.d3d = d3d;
     d3dCaps = d3d.GetDeviceCaps ( 0, SharpDX.Direct3D9.DeviceType.Hardware );
 }