Ejemplo n.º 1
0
        /// <summary>
        /// Binds a texture to a sampler in the shader
        /// TODO: Refactor or remove this
        /// </summary>
        /// <param name="textureUnit">The texture unit to bind the texture to</param>
        /// <param name="uniform">The uniform name where the texture should be bound.</param>
        /// <param name="texture">The texture to bind.</param>
        public void BindTexture2D(TextureUnit textureUnit, TextureUniform uniform, Texture2D texture)
        {
            Enable();

            GL.ActiveTexture(textureUnit);
            texture.Bind();

            int textureVariableHandle = GL.GetUniformLocation(this.NativeShaderProgramID, uniform.ToString());

            GL.Uniform1(textureVariableHandle, (int)uniform);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Binds a texture to a sampler in the shader. The name of the sampler must match one of the values in
        /// <see cref="TextureUniform"/>.
        /// </summary>
        /// <param name="textureUnit">The texture unit to bind the texture to.</param>
        /// <param name="uniform">The uniform where the texture should be bound.</param>
        /// <param name="texture">The texture to bind.</param>
        public void BindTexture2D(TextureUnit textureUnit, TextureUniform uniform, Texture2D texture)
        {
            if (texture == null)
            {
                throw new ArgumentNullException(nameof(texture));
            }

            Enable();

            var textureVariableHandle = GL.GetUniformLocation(this.NativeShaderProgramID, uniform.ToString());

            GL.Uniform1(textureVariableHandle, (int)uniform);

            GL.ActiveTexture(textureUnit);
            texture.Bind();
        }