Ejemplo n.º 1
0
 public void setElement(SceneElement e) {
   super.setElement(e);
   RuntimeDrawable<?> r = (RuntimeDrawable<?>) assetHandler.getRuntimeAsset(transition.getMask());
   texture = r.getTextureHandle();
   offset = new Vector3();
   if (maskShader == null) {
     maskShader =
         new ShaderProgram(
             assetHandler.getTextFile("@binary/shaders/mask.vert"),
             assetHandler.getTextFile("@binary/shaders/mask.frag"));
     if (maskShader.getLog().length() != 0) logger.warn(maskShader.getLog());
     nextSceneBuffer = new FrameBuffer(Format.RGBA8888, 800, 600, false);
   }
   maskShader.begin();
   maskShader.setUniformi("mask_texture", 1);
   maskShader.setAttributef("a_sizes", 800, 600, r.getWidth(), r.getHeight());
   maskShader.end();
 }
Ejemplo n.º 2
0
  @Override
  public void drawChildren(SpriteBatch batch, float parentAlpha) {
    previousScene.setVisible(true);
    nextScene.setVisible(false);
    super.drawChildren(batch, parentAlpha);
    batch.end();
    nextSceneBuffer.begin();
    batch.begin();

    previousScene.setVisible(false);
    nextScene.setVisible(true);

    super.drawChildren(batch, parentAlpha);
    nextSceneBuffer.end();

    batch.flush();
    batch.setShader(maskShader);
    maskShader.setAttributef("a_offset", offset.x, offset.y, offset.z, 0);
    texture.bind(1);
    Gdx.gl.glActiveTexture(GL10.GL_TEXTURE0);
    Gdx.gl.glBindTexture(GL10.GL_TEXTURE_2D, 0);
    batch.draw(nextSceneBuffer.getColorBufferTexture(), 0, 0);
    batch.setShader(null);
  }