コード例 #1
0
 public static void CheckTextureRequirements(Device device, Usage usage, Pool pool, out TextureRequirements requirements)
 {
     throw new NotImplementedException();
 }
コード例 #2
0
        /// <summary>
        /// 
        /// </summary>
        //private void CreateDepthStencil() {
        //    // Get the format of the depth stencil surface of our main render target.
        //    D3D.Surface surface = device.DepthStencilSurface;
        //    D3D.SurfaceDescription desc = surface.Description;
        //    // Create a depth buffer for our render target, it must be of
        //    // the same format as other targets !!!
        //    depthBuffer = device.CreateDepthStencilSurface(
        //        srcWidth,
        //        srcHeight,
        //        // TODO: Verify this goes through, this is ridiculous
        //        (D3D.DepthFormat)desc.Format,
        //        desc.MultiSampleType,
        //        desc.MultiSampleQuality,
        //        false);
        //}
        private void CreateNormalTexture()
        {
            // we must have those defined here
            Debug.Assert(srcWidth > 0 && srcHeight > 0);

            // determine which D3D9 pixel format we'll use
            D3D.Format d3dPixelFormat = ChooseD3DFormat();

            // at this point, Ogre checks to see if this texture format works,
            // but we go on and figure out the rest of our info first.

            // set the appropriate usage based on the usage of this texture
            D3D.Usage d3dUsage =
                ((usage & TextureUsage.RenderTarget) == TextureUsage.RenderTarget) ? D3D.Usage.RenderTarget : D3D.Usage.None;

            // how many mips to use?
            int numMips = numRequestedMipmaps + 1;

            // Check dynamic textures
            if ((usage & TextureUsage.Dynamic) != 0) {
                if (CanUseDynamicTextures(d3dUsage, ResourceType.Textures, d3dPixelFormat)) {
                    d3dUsage |= D3D.Usage.Dynamic;
                    dynamicTextures = true;
                } else {
                    dynamicTextures = false;
                }
            }
            // check if mip maps are supported on hardware
            mipmapsHardwareGenerated = false;
            if (devCaps.TextureCaps.SupportsMipMap) {
                if (((usage & TextureUsage.AutoMipMap) == TextureUsage.AutoMipMap)
                    && numRequestedMipmaps > 0)
                {
                    // use auto.gen. if available
                    mipmapsHardwareGenerated = this.CanAutoGenMipMaps(d3dUsage, ResourceType.Textures, d3dPixelFormat);
                    if (mipmapsHardwareGenerated) {
                        d3dUsage |= D3D.Usage.AutoGenerateMipMap;
                        numMips = 0;
                    }
                }
            } else {
                // no mip map support for this kind of texture
                numMipmaps = 0;
                numMips = 1;
            }

            // check texture requirements
            D3D.TextureRequirements texRequire = new D3D.TextureRequirements();
            texRequire.Width = srcWidth;
            texRequire.Height = srcHeight;
            texRequire.NumberMipLevels = numMips;
            texRequire.Format = d3dPixelFormat;
            // NOTE: Although texRequire is an out parameter, it actually does
            //       use the data passed in with that object.
            TextureLoader.CheckTextureRequirements(device, d3dUsage, Pool.Default, out texRequire);
            numMips = texRequire.NumberMipLevels;
            d3dPixelFormat = texRequire.Format;
            Debug.Assert(normTexture == null);
            Debug.Assert(texture == null);
            log.InfoFormat("Created normal texture {0}", this.Name);
            // create the texture
            normTexture = new D3D.Texture(
                    device,
                    srcWidth,
                    srcHeight,
                    numMips,
                    d3dUsage,
                    d3dPixelFormat,
                    d3dPool);

            // store base reference to the texture
            texture = normTexture;

            // set the final texture attributes
            D3D.SurfaceDescription desc = normTexture.GetLevelDescription(0);
            SetFinalAttributes(desc.Width, desc.Height, 1, D3DHelper.ConvertEnum(desc.Format));

            if (mipmapsHardwareGenerated)
                texture.AutoGenerateFilterType = GetBestFilterMethod();
        }