Inheritance: DepthBuffer
Beispiel #1
0
        public override DepthBuffer CreateDepthBufferFor( RenderTarget renderTarget )
        {
            var pBack = (Surface[])renderTarget[ "DDBACKBUFFER" ];

		    if( pBack[0] == null )
			    return null;

            var srfDesc = pBack[ 0 ].Description;

		    //Find an appropiarte format for this depth buffer that best matches the RenderTarget's
		    var dsfmt = GetDepthStencilFormatFor( srfDesc.Format );

		    //Create the depthstencil surface
		    var activeDevice = ActiveD3D9Device;

            var depthBufferSurface = Surface.CreateDepthStencil( activeDevice, srfDesc.Width, srfDesc.Height, dsfmt,
                                                                 srfDesc.MultisampleType, srfDesc.MultisampleQuality,
                                                                 true );

		    var newDepthBuffer = new D3D9DepthBuffer( PoolId.Default, this,
												    activeDevice, depthBufferSurface,
												    dsfmt, srfDesc.Width, srfDesc.Height,
												    srfDesc.MultisampleType, srfDesc.MultisampleQuality, false );

		    return newDepthBuffer;
        }
Beispiel #2
0
        public DepthBuffer AddManualDepthBuffer(Device depthSurfaceDevice, Surface depthSurface)
        {
            //If this depth buffer was already added, return that one

            foreach (var itor in depthBufferPool[PoolId.Default].Cast<D3D9DepthBuffer>())
            {
                if( itor.DepthBufferSurface == depthSurface )
                    return itor;
            }

            //Nope, get the info about this depth buffer and create a new container fot it
            var dsDesc = depthSurface.Description;
        
            var newDepthBuffer = new D3D9DepthBuffer( PoolId.Default, this,
                                                depthSurfaceDevice, depthSurface,
                                                dsDesc.Format, dsDesc.Width, dsDesc.Height,
                                                dsDesc.MultisampleType, dsDesc.MultisampleQuality, true );

            //Add the 'main' depth buffer to the pool
            depthBufferPool[newDepthBuffer.PoolId].Add(newDepthBuffer);

            return newDepthBuffer;
        }