SetUniform() public method

Specify current texture as \p sampler2D uniform

This overload maps a shader texture variable to the texture of the object being drawn, which cannot be known in advance. The second argument must be CurrentTexture. The corresponding parameter in the shader must be a 2D texture (sampler2D GLSL type).

Example: uniform sampler2D current; // this is the variable in the shader shader.setUniform("current", Shader.CurrentTexture);

public SetUniform ( string name, CurrentTextureType current ) : void
name string Name of the texture in the shader
current CurrentTextureType
return void
Ejemplo n.º 1
0
        public Pixelate() : base("pixelate")
        {
            // Load the texture and initialize the sprite
            myTexture = new Texture("resources/background.jpg");
            mySprite = new Sprite(myTexture);

            // Load the shader
            myShader = new Shader(null, null, "resources/pixelate.frag");
            myShader.SetUniform("texture", Shader.CurrentTexture);
        }
Ejemplo n.º 2
0
        public Edge() : base("edge post-effect")
        {
            // Create the off-screen surface
            mySurface = new RenderTexture(800, 600);
            mySurface.Smooth = true;

            // Load the textures
            myBackgroundTexture = new Texture("resources/sfml.png");
            myBackgroundTexture.Smooth = true;
            myEntityTexture = new Texture("resources/devices.png");
            myEntityTexture.Smooth = true;

            // Initialize the background sprite
            myBackgroundSprite = new Sprite(myBackgroundTexture);
            myBackgroundSprite.Position = new Vector2f(135, 100);

            // Load the moving entities
            myEntities = new Sprite[6];
            for (int i = 0; i < myEntities.Length; ++i)
            {
                myEntities[i] = new Sprite(myEntityTexture, new IntRect(96 * i, 0, 96, 96));
            }

            // Load the shader
            myShader = new Shader(null, null, "resources/edge.frag");
            myShader.SetUniform("texture", Shader.CurrentTexture);
        }