public void render () { Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); batch.begin(); batch.setBlendFunction(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA); batch.draw(badTexture, 0, Gdx.graphics.getHeight(), Gdx.graphics.getWidth() * 0.5f, -Gdx.graphics.getHeight()); batch.draw(goodTexture, Gdx.graphics.getWidth() * 0.5f, Gdx.graphics.getHeight(), Gdx.graphics.getWidth() * 0.5f, -Gdx.graphics.getHeight()); batch.end(); }
spriteBatch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
spriteBatch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
@Override public void setBlendFunction(int srcFunc, int dstFunc) { spriteBatch.setBlendFunction(srcFunc, dstFunc); }
@Override public void clearBlendFunction() { spriteBatch.setBlendFunction(defaultBlendSrcFunc, defaultBlendDstFunc); }
private void drawForeground(SpriteBatch batch, float clipX, float clipY, float clipWidth, float clipHeight) { //now that the buffer has our alpha, we simply draw the sprite with the mask applied Gdx.gl.glColorMask(true, true, true, true); batch.setBlendFunction(GL10.GL_DST_ALPHA, GL10.GL_ONE_MINUS_DST_ALPHA); batch.draw(spriteRegion, clipX, // corrected center position.x clipY, // corrected center position.y 0, //origin x 0, //origin y spriteRegion.getRegionWidth() , //w spriteRegion.getRegionHeight(), //h item.t_scale, //scale x item.t_scale, //scale y item.manager.radiansToDegrees(item.rotation)); //angle //remember to flush before changing GL states again batch.flush(); // set it back to however it was before batch.setBlendFunction(src, dst); }
private void drawAlphaMask(SpriteBatch batch, float x, float y, float width, float height) { //disable RGB color, only enable ALPHA to the frame buffer Gdx.gl.glColorMask(false, false, false, true); // Get these values so I can be sure I set them back to how it was dst = batch.getBlendDstFunc(); src = batch.getBlendSrcFunc(); //change the blending function for our alpha map batch.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ZERO); //draw alpha mask sprite batch.draw(alphaRegion, x, // position.x y, // position.y 0, // origin x 0, // origin y alphaRegion.getRegionWidth(), // w alphaRegion.getRegionHeight(), // h item.t_scale, // scale x item.t_scale, // scale y item.manager.radiansToDegrees(item.rotation)); // angle //flush the batch to the GPU batch.flush(); }
sb.setBlendFunction(srcFunc, dstFunc);
@Override public void draw (float delta) { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); viewMatrix.setToOrtho2D(0, 0, 480, 320); spriteBatch.setProjectionMatrix(viewMatrix); spriteBatch.setTransformMatrix(transformMatrix); spriteBatch.begin(); spriteBatch.disableBlending(); spriteBatch.setColor(Color.WHITE); spriteBatch.draw(background, 0, 0, 480, 320, 0, 0, 512, 512, false, false); spriteBatch.enableBlending(); spriteBatch.draw(logo, 0, 320 - 128, 480, 128, 0, 256, 512, 256, false, false); String text = "It is the end my friend.\nTouch to continue!"; TextBounds bounds = font.getMultiLineBounds(text); spriteBatch.setBlendFunction(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA); font.drawMultiLine(spriteBatch, text, 0, 160 + bounds.height / 2, 480, HAlignment.CENTER); spriteBatch.end(); }
@Override public void draw (float delta) { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); viewMatrix.setToOrtho2D(0, 0, 480, 320); spriteBatch.setProjectionMatrix(viewMatrix); spriteBatch.setTransformMatrix(transformMatrix); spriteBatch.begin(); spriteBatch.disableBlending(); spriteBatch.setColor(Color.WHITE); spriteBatch.draw(background, 0, 0, 480, 320, 0, 0, 512, 512, false, false); spriteBatch.enableBlending(); spriteBatch.draw(logo, 0, 320 - 128, 480, 128, 0, 0, 512, 256, false, false); spriteBatch.setBlendFunction(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA); String text = "Touch screen to start!"; float width = font.getBounds(text).width; font.draw(spriteBatch, text, 240 - width / 2, 128); if (Gdx.app.getType() == ApplicationType.WebGL) { text = "Press Enter for Fullscreen Mode"; width = font.getBounds(text).width; font.draw(spriteBatch, "Press Enter for Fullscreen Mode", 240 - width / 2, 128 - font.getLineHeight()); } spriteBatch.end(); }
Gdx.graphics.getGL20().glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); Engine.getSpriteBatch().setColor(color2); Engine.getSpriteBatch().setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE); Engine.getSpriteBatch().begin(); for (Particle p : particles) { fbo.end(); Engine.getSpriteBatch().setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE); Engine.getSpriteBatch().begin(); Engine.getSpriteBatch().draw(fbo.getColorBufferTexture(), 0, 0, fbo.getColorBufferTexture().getWidth(), fbo.getColorBufferTexture().getHeight(), 0, 0, 1, 1); Engine.getSpriteBatch().end(); Engine.getSpriteBatch().setColor(Color.WHITE); Engine.getSpriteBatch().setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
spriteBatch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
Engine.getSpriteBatch().setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE); begin1.draw(Engine.getSpriteBatch()); begin2.draw(Engine.getSpriteBatch()); Engine.getSpriteBatch().setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);