Microsoft.Xna.Framework.Graphics.Shader.ApplySamplerTextureUnits C# (CSharp) Méthode

ApplySamplerTextureUnits() private méthode

private ApplySamplerTextureUnits ( int program ) : void
program int
Résultat void
        internal void ApplySamplerTextureUnits(int program)
        {
            // Assign the texture unit index to the sampler uniforms.
            foreach (var sampler in Samplers)
            {
                var loc = GL.GetUniformLocation(program, sampler.name);
                GraphicsExtensions.CheckGLError();
                if (loc != -1)
                {
                    GL.Uniform1(loc, sampler.textureSlot);
                    GraphicsExtensions.CheckGLError();
                }
            }
        }

Usage Example

Exemple #1
0
        private void Link(Shader vertexShader, Shader pixelShader)
        {
            int program = GL.CreateProgram();

            GL.AttachShader(program, vertexShader.GetShaderHandle());
            GL.AttachShader(program, pixelShader.GetShaderHandle());
            GL.LinkProgram(program);
            GL.UseProgram(program);
            vertexShader.GetVertexAttributeLocations(program);
            pixelShader.ApplySamplerTextureUnits(program);
            int @params = 0;

            GL.GetProgram(program, ProgramParameter.LinkStatus, out @params);
            if (@params == 0)
            {
                Console.WriteLine(GL.GetProgramInfoLog(program));
                throw new InvalidOperationException("Unable to link effect program");
            }
            else
            {
                ShaderProgramInfo shaderProgramInfo;
                shaderProgramInfo.program     = program;
                shaderProgramInfo.posFixupLoc = GL.GetUniformLocation(program, "posFixup");
                this._programCache.Add(vertexShader.HashKey | pixelShader.HashKey, shaderProgramInfo);
            }
        }
All Usage Examples Of Microsoft.Xna.Framework.Graphics.Shader::ApplySamplerTextureUnits