Beispiel #1
0
        public void LoadGPU(GraphicsDevice gd)
        {
            var format = GetTexFormat();

            if (format == SurfaceFormat.Dxt5 && !FSOEnvironment.TexCompressSupport)
            {
                //todo: software decode DXT5
                FloorTexture = new Texture2D(gd, FloorWidth, FloorHeight, false, SurfaceFormat.Color);
                FloorTexture.SetData(TextureUtils.DXT5Decompress(FloorTextureData, FloorWidth, FloorHeight));
                WallTexture = new Texture2D(gd, WallWidth, WallHeight, false, SurfaceFormat.Color);
                WallTexture.SetData(TextureUtils.DXT5Decompress(WallTextureData, WallWidth, WallHeight));
                if (NightFloorTextureData != null)
                {
                    NightFloorTexture = new Texture2D(gd, FloorWidth, FloorHeight, false, SurfaceFormat.Color);
                    NightFloorTexture.SetData(TextureUtils.DXT5Decompress(NightFloorTextureData, FloorWidth, FloorHeight));
                    NightWallTexture = new Texture2D(gd, WallWidth, WallHeight, false, SurfaceFormat.Color);
                    NightWallTexture.SetData(TextureUtils.DXT5Decompress(NightWallTextureData, WallWidth, WallHeight));
                }
            }
            else
            {
                FloorTexture = new Texture2D(gd, FloorWidth, FloorHeight, false, format);
                FloorTexture.SetData(FloorTextureData);
                WallTexture = new Texture2D(gd, WallWidth, WallHeight, false, format);
                WallTexture.SetData(WallTextureData);
                if (NightFloorTextureData != null)
                {
                    NightFloorTexture = new Texture2D(gd, FloorWidth, FloorHeight, false, format);
                    NightFloorTexture.SetData(NightFloorTextureData);
                    NightWallTexture = new Texture2D(gd, WallWidth, WallHeight, false, format);
                    NightWallTexture.SetData(NightWallTextureData);
                }
            }

            if (FloorVertices.Length > 0)
            {
                FloorVGPU = new VertexBuffer(gd, typeof(DGRP3DVert), FloorVertices.Length, BufferUsage.None);
                FloorVGPU.SetData(FloorVertices);
                FloorIGPU = new IndexBuffer(gd, IndexElementSize.ThirtyTwoBits, FloorIndices.Length, BufferUsage.None);
                FloorIGPU.SetData(FloorIndices);
                FloorPrims = FloorIndices.Length / 3;
            }

            if (WallVertices.Length > 0)
            {
                WallVGPU = new VertexBuffer(gd, typeof(DGRP3DVert), WallVertices.Length, BufferUsage.None);
                WallVGPU.SetData(WallVertices);
                WallIGPU = new IndexBuffer(gd, IndexElementSize.ThirtyTwoBits, WallIndices.Length, BufferUsage.None);
                WallIGPU.SetData(WallIndices);
                WallPrims = WallIndices.Length / 3;
            }
        }