Example #1
0
        public override bool Init()
        {
            if (!base.Init())
            {
                return(false);
            }

            Effects.InitAll(Device);
            InputLayouts.InitAll(Device);
            RenderStates.InitAll(Device);

            _texMgr = new TextureManager();
            _texMgr.Init(Device);

            _bunnyModel = BasicModel.LoadSdkMesh(Device, _texMgr, "Models/bunny.sdkmesh", "Textures");

            _bunnyInstance = new BasicModelInstance(_bunnyModel);

            _effect = new FowardLightingEffect(Device, "FX/ForwardLight.fxo");

            var blendDesc = new BlendStateDescription {
                AlphaToCoverageEnable  = false,
                IndependentBlendEnable = false
            };

            blendDesc.RenderTargets[0].BlendEnable           = true;
            blendDesc.RenderTargets[0].SourceBlend           = BlendOption.One;
            blendDesc.RenderTargets[0].DestinationBlend      = BlendOption.One;
            blendDesc.RenderTargets[0].BlendOperation        = BlendOperation.Add;
            blendDesc.RenderTargets[0].SourceBlendAlpha      = BlendOption.One;
            blendDesc.RenderTargets[0].DestinationBlendAlpha = BlendOption.One;
            blendDesc.RenderTargets[0].BlendOperationAlpha   = BlendOperation.Add;
            blendDesc.RenderTargets[0].RenderTargetWriteMask = ColorWriteMaskFlags.All;

            _additiveBlend = BlendState.FromDescription(Device, blendDesc);


            var passDesc = _effect.Ambient.GetPassByIndex(0).Description;

            _layout = new InputLayout(Device, passDesc.Signature, InputLayoutDescriptions.PosNormalTexTan);

            AddUIElements();

            return(true);
        }
Example #2
0
        public override bool Init() {
            if (!base.Init()) return false;

            Effects.InitAll(Device);
            InputLayouts.InitAll(Device);
            RenderStates.InitAll(Device);

            _texMgr = new TextureManager();
            _texMgr.Init(Device);

            _bunnyModel = BasicModel.LoadSdkMesh(Device, _texMgr, "Models/bunny.sdkmesh", "Textures");

            _bunnyInstance = new BasicModelInstance(_bunnyModel);

            _effect = new FowardLightingEffect(Device, "FX/ForwardLight.fxo");

            var blendDesc = new BlendStateDescription {
                AlphaToCoverageEnable = false,
                IndependentBlendEnable = false
            };
            blendDesc.RenderTargets[0].BlendEnable = true;
            blendDesc.RenderTargets[0].SourceBlend = BlendOption.One;
            blendDesc.RenderTargets[0].DestinationBlend = BlendOption.One;
            blendDesc.RenderTargets[0].BlendOperation = BlendOperation.Add;
            blendDesc.RenderTargets[0].SourceBlendAlpha = BlendOption.One;
            blendDesc.RenderTargets[0].DestinationBlendAlpha = BlendOption.One;
            blendDesc.RenderTargets[0].BlendOperationAlpha = BlendOperation.Add;
            blendDesc.RenderTargets[0].RenderTargetWriteMask = ColorWriteMaskFlags.All;

            _additiveBlend = BlendState.FromDescription(Device, blendDesc);


            var passDesc = _effect.Ambient.GetPassByIndex(0).Description;
            _layout = new InputLayout(Device, passDesc.Signature, InputLayoutDescriptions.PosNormalTexTan);

            AddUIElements();

            return true;

        }