Java Code Examples for com.badlogic.gdx.graphics.g2d.Batch#setShader()

The following examples show how to use com.badlogic.gdx.graphics.g2d.Batch#setShader() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GradientImage.java    From talos with Apache License 2.0 6 votes vote down vote up
@Override
public void draw(Batch batch, float parentAlpha) {
    ShaderProgram prevShader = batch.getShader();
    batch.setShader(shaderProgram);

    shaderProgram.setUniformi(U_POINT_COUNT, points.size);

    for(int i = 0; i < points.size; i++){
        ColorPoint point = points.get(i);

        stringBuilder.clear();
        stringBuilder.append(U_ARR_NAME).append(i).append(U_PARAM_COLOR);
        shaderProgram.setUniformf(stringBuilder.toString(), point.color.r, point.color.g, point.color.b, 1f);

        stringBuilder.clear();
        stringBuilder.append(U_ARR_NAME).append(i).append(U_PARAM_ALPHA);
        shaderProgram.setUniformf(stringBuilder.toString(), point.pos);
    }

    // do the rendering
    batch.draw(white, getX(), getY(), getWidth(), getHeight());

    batch.setShader(prevShader);
}
 
Example 2
Source File: NoiseImage.java    From talos with Apache License 2.0 5 votes vote down vote up
public void drawWithShader(Batch batch, float parentAlpha) {
    ShaderProgram prevShader = batch.getShader();
    batch.setShader(shaderProgram);

    shaderProgram.setUniformf("frequency", frequency);

    // do the rendering
    batch.draw(white, getX(), getY(), getWidth(), getHeight());

    batch.setShader(prevShader);
}
 
Example 3
Source File: ShaderImage.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
@Override
public void draw (Batch batch, float parentAlpha) {
	ShaderProgram originalShader = batch.getShader();
	batch.setShader(shader);
	setShaderUniforms(shader);

	super.draw(batch, parentAlpha);

	batch.setShader(originalShader);
}
 
Example 4
Source File: GridSubImage.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
public void draw (Batch batch, Image parent) {
	ShaderProgram originalShader = batch.getShader();
	batch.setShader(gridShader);
	gridShader.setUniformf("u_width", parent.getWidth());
	gridShader.setUniformf("u_height", parent.getHeight());
	gridShader.setUniformf("u_gridSize", gridSize);
	batch.draw(whiteTexture, parent.getX() + parent.getImageX(), parent.getY() + parent.getImageY(),
			parent.getImageWidth() * parent.getScaleX(), parent.getImageHeight() * parent.getScaleY());
	batch.setShader(originalShader);
}