List of usage examples for com.badlogic.gdx.graphics.g2d Batch setShader
public void setShader(ShaderProgram shader);
From source file:com.andgate.ikou.utility.graphics.ShaderFont.java
License:Open Source License
@Override public TextBounds draw(Batch batch, CharSequence str, float x, float y) { batch.setShader(shader); TextBounds bounds = super.draw(batch, str, x, y); batch.setShader(null);// w w w .ja v a 2s . co m return bounds; }
From source file:com.andgate.ikou.utility.Scene2d.ShaderLabel.java
License:Open Source License
@Override public void draw(Batch batch, float parentAlpha) { batch.setShader(shader); super.draw(batch, parentAlpha); batch.setShader(null);/*from w w w . jav a2 s . c o m*/ }
From source file:com.jlabarca.kflame.FondoLayer.java
License:Apache License
@Override public void draw(Batch batch, float parentAlpha) { batch.setShader(null); backGroundSprite.draw(batch, parentAlpha); //backGroundSprite.setColor(((GameScene)(Director.instance().getScene())).fpsLayer.goalColor); //backGroundSprite1.draw(batch, parentAlpha); // backGroundSprite2.draw(batch, parentAlpha); // backGroundSprite3.draw(batch, parentAlpha); }
From source file:com.kotcrab.vis.ui.widget.color.internal.GridSubImage.java
License:Apache License
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);//from w ww .jav a 2s.c o m }
From source file:com.kotcrab.vis.ui.widget.color.internal.ShaderImage.java
License:Apache License
@Override public void draw(Batch batch, float parentAlpha) { ShaderProgram originalShader = batch.getShader(); batch.setShader(shader); setShaderUniforms(shader);/*from w ww . j ava 2s . c o m*/ super.draw(batch, parentAlpha); batch.setShader(originalShader); }
From source file:com.quadbits.gdxhelper.actors.ParticleEffectActor.java
License:Apache License
@Override public void draw(Batch batch, float parentAlpha) { super.draw(batch, parentAlpha); if (effect != null) { effect.setPosition(getX(), getY()); if (isVisible() && !effect.isComplete() && isWithinScreenBounds()) { if (preDrawShader != null) { batch.setShader(preDrawShader); }/*from w ww . ja v a2 s . co m*/ effect.draw(batch); if (preDrawShader != postDrawShader) { batch.setShader(postDrawShader); } } } }
From source file:com.quadbits.gdxhelper.actors.ScreenDimActor.java
License:Apache License
@Override public void draw(Batch batch, float parentAlpha) { super.draw(batch, parentAlpha); dimSprite.setPosition(0, 0);/*from w w w .jav a 2s . c o m*/ float width = Gdx.graphics.getWidth(); float height = Gdx.graphics.getHeight(); if (dimSprite.getWidth() != width || dimSprite.getHeight() != height) { dimSprite.setSize(width, height); } dimSprite.setColor(getColor()); dimSprite.setAlpha(parentAlpha * alpha); // Use default shader batch.setShader(null); dimSprite.draw(batch); // Restore shader if (postDrawShader != null) { batch.setShader(postDrawShader); } }
From source file:com.quadbits.gdxhelper.actors.SkyActor.java
License:Apache License
@Override public void draw(Batch batch, float parentAlpha) { super.draw(batch, parentAlpha); DayPalette primaryPalette = palettes.get(primaryPaletteIndex); DayPalette secondaryPalette = (secondaryPaletteIndex < 0) ? null : palettes.get(secondaryPaletteIndex); // ------------------------------------------------------------------------ // Calculate bottom color // ------------------------------------------------------------------------ switch (timeManager.getPeriod()) { case TWILIGHT_PRE_SUNRISE: colorBottom.set(primaryPalette.getPreDawnLightColor()); dstColor.set(primaryPalette.getSunRiseLightColor()); if (secondaryPalette != null) { colorBottom.lerp(secondaryPalette.getPreDawnLightColor(), paletteAlpha); dstColor.lerp(secondaryPalette.getSunRiseLightColor(), paletteAlpha); }// w w w .j ava 2 s . c o m break; case TWILIGHT_POST_SUNRISE: colorBottom.set(primaryPalette.getSunRiseLightColor()); dstColor.set(primaryPalette.getPostDawnLightColor()); if (secondaryPalette != null) { colorBottom.lerp(secondaryPalette.getSunRiseLightColor(), paletteAlpha); dstColor.lerp(secondaryPalette.getPostDawnLightColor(), paletteAlpha); } break; case PRE_MIDDAY: colorBottom.set(primaryPalette.getPostDawnLightColor()); dstColor.set(primaryPalette.getMiddayLightColor()); if (secondaryPalette != null) { colorBottom.lerp(secondaryPalette.getPostDawnLightColor(), paletteAlpha); dstColor.lerp(secondaryPalette.getMiddayLightColor(), paletteAlpha); } break; case POST_MIDDAY: colorBottom.set(primaryPalette.getMiddayLightColor()); dstColor.set(primaryPalette.getPreDuskLightColor()); if (secondaryPalette != null) { colorBottom.lerp(secondaryPalette.getMiddayLightColor(), paletteAlpha); dstColor.lerp(secondaryPalette.getPreDuskLightColor(), paletteAlpha); } break; case TWILIGHT_PRE_SUNSET: colorBottom.set(primaryPalette.getPreDuskLightColor()); dstColor.set(primaryPalette.getSunSetLightColor()); if (secondaryPalette != null) { colorBottom.lerp(secondaryPalette.getPreDuskLightColor(), paletteAlpha); dstColor.lerp(secondaryPalette.getSunSetLightColor(), paletteAlpha); } break; case TWILIGHT_POST_SUNSET: colorBottom.set(primaryPalette.getSunSetLightColor()); dstColor.set(primaryPalette.getPostDuskLightColor()); if (secondaryPalette != null) { colorBottom.lerp(secondaryPalette.getSunSetLightColor(), paletteAlpha); dstColor.lerp(secondaryPalette.getPostDuskLightColor(), paletteAlpha); } break; case PRE_MIDNIGHT: colorBottom.set(primaryPalette.getPostDuskLightColor()); dstColor.set(primaryPalette.getMidnightLightColor()); if (secondaryPalette != null) { colorBottom.lerp(secondaryPalette.getPostDuskLightColor(), paletteAlpha); dstColor.lerp(secondaryPalette.getMidnightLightColor(), paletteAlpha); } break; default: colorBottom.set(primaryPalette.getMidnightLightColor()); dstColor.set(primaryPalette.getPreDawnLightColor()); if (secondaryPalette != null) { colorBottom.lerp(secondaryPalette.getMidnightLightColor(), paletteAlpha); dstColor.lerp(secondaryPalette.getPreDawnLightColor(), paletteAlpha); } break; } colorBottom.lerp(dstColor, timeManager.getTPeriod()); // ------------------------------------------------------------------------ // Calculate top color // ------------------------------------------------------------------------ switch (timeManager.getPeriod()) { case TWILIGHT_PRE_SUNRISE: colorTop.set(primaryPalette.getPreDawnDarkColor()); dstColor.set(primaryPalette.getSunRiseDarkColor()); if (secondaryPalette != null) { colorTop.lerp(secondaryPalette.getPreDawnDarkColor(), paletteAlpha); dstColor.lerp(secondaryPalette.getSunRiseDarkColor(), paletteAlpha); } break; case TWILIGHT_POST_SUNRISE: colorTop.set(primaryPalette.getSunRiseDarkColor()); dstColor.set(primaryPalette.getPostDawnDarkColor()); if (secondaryPalette != null) { colorTop.lerp(secondaryPalette.getSunRiseDarkColor(), paletteAlpha); dstColor.lerp(secondaryPalette.getPostDawnDarkColor(), paletteAlpha); } break; case PRE_MIDDAY: colorTop.set(primaryPalette.getPostDawnDarkColor()); dstColor.set(primaryPalette.getMiddayDarkColor()); if (secondaryPalette != null) { colorTop.lerp(secondaryPalette.getPostDawnDarkColor(), paletteAlpha); dstColor.lerp(secondaryPalette.getMiddayDarkColor(), paletteAlpha); } break; case POST_MIDDAY: colorTop.set(primaryPalette.getMiddayDarkColor()); dstColor.set(primaryPalette.getPreDuskDarkColor()); if (secondaryPalette != null) { colorTop.lerp(secondaryPalette.getMiddayDarkColor(), paletteAlpha); dstColor.lerp(secondaryPalette.getPreDuskDarkColor(), paletteAlpha); } break; case TWILIGHT_PRE_SUNSET: colorTop.set(primaryPalette.getPreDuskDarkColor()); dstColor.set(primaryPalette.getSunSetDarkColor()); if (secondaryPalette != null) { colorTop.lerp(secondaryPalette.getPreDuskDarkColor(), paletteAlpha); dstColor.lerp(secondaryPalette.getSunSetDarkColor(), paletteAlpha); } break; case TWILIGHT_POST_SUNSET: colorTop.set(primaryPalette.getSunSetDarkColor()); dstColor.set(primaryPalette.getPostDuskDarkColor()); if (secondaryPalette != null) { colorTop.lerp(secondaryPalette.getSunSetDarkColor(), paletteAlpha); dstColor.lerp(secondaryPalette.getPostDuskDarkColor(), paletteAlpha); } break; case PRE_MIDNIGHT: colorTop.set(primaryPalette.getPostDuskDarkColor()); dstColor.set(primaryPalette.getMidnightDarkColor()); if (secondaryPalette != null) { colorTop.lerp(secondaryPalette.getPostDuskDarkColor(), paletteAlpha); dstColor.lerp(secondaryPalette.getMidnightDarkColor(), paletteAlpha); } break; default: colorTop.set(primaryPalette.getMidnightDarkColor()); dstColor.set(primaryPalette.getPreDawnDarkColor()); if (secondaryPalette != null) { colorTop.lerp(secondaryPalette.getMidnightDarkColor(), paletteAlpha); dstColor.lerp(secondaryPalette.getPreDawnDarkColor(), paletteAlpha); } break; } colorTop.lerp(dstColor, timeManager.getTPeriod()); // For the moment, ignore offset // TODO: add gradient offset to the pixmap generation vgradient.setPosition(getX(), getY()); vgradient.setSize(getWidth(), getHeight()); // ------------------------------------------------------------------------ // Use a custom shader for creating the gradient based on the // vgradient sprite // ------------------------------------------------------------------------ shaderProgram.setAttributef(getShaderAttrNameColorTop(), colorTop.r, colorTop.g, colorTop.b, colorTop.a); shaderProgram.setAttributef(getShaderAttrNameColorBottom(), colorBottom.r, colorBottom.g, colorBottom.b, colorBottom.a); batch.setShader(shaderProgram); vgradient.draw(batch); // Restore default shader batch.setShader(null); }
From source file:com.quadbits.gdxhelper.actors.SpriteActor.java
License:Apache License
@Override public void draw(Batch batch, float parentAlpha) { if (useCustomShader) { batch.setShader(preDrawShader); }/*w ww.j a v a 2 s . c o m*/ setSpriteGridPropertiesFromActor(); spriteGrid.draw(batch, parentAlpha); if (useCustomShader && preDrawShader != postDrawShader) { batch.setShader(postDrawShader); } }
From source file:com.strategames.engine.gameobject.types.Text.java
License:Open Source License
@Override public void draw(Batch batch, float parentAlpha) { batch.setShader(fontShader); font.draw(batch, text, getX(), getY()); batch.setShader(null);/*from w ww .ja v a2 s. com*/ }