示例#1
0
        public EarthlitNightScene(IEye eye)
        {
            this.eye = eye;
            device = eye.Device;
            swapChain = device.PrimarySwapChain;

            stars = new Stars(device, StarCount);

            var meshFactory = new MeshFactory(device, Handedness.Right, Winding.Clockwise);
            var earthMesh = meshFactory.CreateSphere(false, 1.0f, 36);
            earthVertexBuffer = earthMesh.Vertices.Buffer;
            earthIndexBuffer = earthMesh.Indices.Buffer;

            var formatInfo = eye.Adapters[0].GetSupportedFormats(FormatSupport.RenderTarget | FormatSupport.Texture2D | FormatSupport.TextureCube)
                .First(x => x.ColorBits == 24 && x.AlphaBits == 8 && x.ColorFormatType == FormatElementType.UNORM);
            starsProxyTexture = device.Create.Texture2D(new Texture2DDescription
            {
                BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
                Usage = Usage.Default,
                Width = SkyboxSize,
                Height = SkyboxSize,
                ArraySize = 1,
                MipLevels = 1,
                FormatID = formatInfo.ID
            });

            skyboxTexture = device.Create.Texture2D(new Texture2DDescription
            {
                BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
                Usage = Usage.Default,
                Width = SkyboxSize,
                Height = SkyboxSize,
                ArraySize = 6,
                MipLevels = TextureHelper.MipLevels(SkyboxSize, SkyboxSize, 1),
                FormatID = formatInfo.ID,
                MiscFlags = MiscFlags.TextureCube | MiscFlags.GenerateMips
            });

            var textureLoader = new TextureLoader(device);

            earthTexture = textureLoader.Load("../Textures/BasicTest.png");
        }