Пример #1
0
        public override void Init(D3DDevice device)
        {
            base.Init(device);

            texture = D3D.Texture2D.FromFile(device.Device, @"C:\Users\adrianj\Documents\Visual Studio 2010\Projects\Direct3D-Testing\ImageTiler_Test\bin\Debug\Images\test_google.bmp");
            D3D.ShaderResourceView textureResourceView = new D3D.ShaderResourceView(device.Device, texture);
            D3D.EffectResourceVariable textureResource = effect.GetVariableByName("Texture_0").AsResource();
            device.Device.PixelShader.SetShaderResource(textureResourceView, 0);
            textureResource.SetResource(textureResourceView);
            texture.Dispose();
            textureResourceView.Dispose();

            zoomEffect = effect.GetVariableByName("TextureZoomLevel").AsScalar();
        }
Пример #2
0
 protected virtual void InitDevice()
 {
     if (D3DDevice == null)
         D3DDevice = new D3DDevice();
     D3DDevice.Init(HostControl);
     HostControl.SizeChanged += (o, e) => { this.UpdateSize(); };
 }
Пример #3
0
        public virtual void Init(D3DDevice device)
        {
            SlimDX.D3DCompiler.ShaderFlags shaderflags = SlimDX.D3DCompiler.ShaderFlags.EnableStrictness;
            SlimDX.D3DCompiler.EffectFlags effectFlags = SlimDX.D3DCompiler.EffectFlags.None;
            effect = D3D.Effect.FromFile(device.Device, ShaderFilename, "fx_4_0", shaderflags, effectFlags, null, null, null);

            passes = new List<D3D.EffectPass>();
            for (int i = 0; i < MaxTechniques; i++)
            {
                D3D.EffectTechnique technique = effect.GetTechniqueByIndex(i);
                if (technique == null || !technique.IsValid) break;
                for (int p = 0; p < MaxPasses; p++)
                {
                    D3D.EffectPass pass = technique.GetPassByIndex(p);
                    if (pass == null || !pass.IsValid) break;
                    passes.Add(pass);
                }
            }

            World = effect.GetVariableByName("World").AsMatrix();
            View = effect.GetVariableByName("View").AsMatrix();
            Proj = effect.GetVariableByName("Proj").AsMatrix();
            InvProj = effect.GetVariableByName("InvProj").AsMatrix();
            CameraPos = effect.GetVariableByName("CameraPos").AsVector();
        }
Пример #4
0
 public override void BindToPass(D3DDevice device, Effect effect, int passIndex)
 {
     this.Init();
     this.Reset();
     this.Tessellate();
     base.BindToPass(device, effect, passIndex);
 }