/// <summary> /// /// </summary> /// <param name="shader"></param> /// <param name="textures"></param> /// <param name="samplerStates"></param> private void SetShaderSamplers(Shader shader, TextureCollection textures, SamplerStateCollection samplerStates) { foreach (var sampler in shader.Samplers) { var param = _effect.Parameters[sampler.parameter]; var texture = param.Data as Texture; textures[sampler.textureSlot] = texture; //If there is a sampler state set it. if (sampler.state != null) { samplerStates[sampler.samplerSlot] = sampler.state; } } }
/// <summary> /// /// </summary> private void Setup() { if (DisplayMode == null) { throw new Exception(""); } _viewport = new Viewport(0, 0, DisplayMode.Width, DisplayMode.Height); _viewport.MaxDepth = 1.0f; PlatformSetup(); VertexTextures = new TextureCollection(this, MaxVertexTextureSlots, true); VertexSamplerStates = new SamplerStateCollection(this, MaxVertexTextureSlots, true); Textures = new TextureCollection(this, MaxTextureSlots, false); SamplerStates = new SamplerStateCollection(this, MaxTextureSlots, false); _blendStateAdditive = BlendState.Additive.Clone(); _blendStateAlphaBlend = BlendState.AlphaBlend.Clone(); _blendStateNonPremultiplied = BlendState.NonPremultiplied.Clone(); _blendStateOpaque = BlendState.Opaque.Clone(); BlendState = BlendState.Opaque; _depthStencilStateDefault = DepthStencilState.Default.Clone(); _depthStencilStateDepthRead = DepthStencilState.DepthRead.Clone(); _depthStencilStateNone = DepthStencilState.None.Clone(); DepthStencilState = DepthStencilState.Default; _rasterizerStateCullClockwise = RasterizerState.CullClockwise.Clone(); _rasterizerStateCullCounterClockwise = RasterizerState.CullCounterClockwise.Clone(); _rasterizerStateCullNone = RasterizerState.CullNone.Clone(); RasterizerState = RasterizerState.CullCounterClockwise; EffectCache = new Dictionary <int, Effect>(); }