title: LibGDX FrameBuffer
body: <p>I'm trying to make a game where you build a spaceship from parts, and fly it around and such.</p>
  <p>I would like to create the ship from a series of components (from a TextureAtlas for instance).  I'd like to draw the ship from it's component textures, and then save the drawn ship as one large Texture. (So i don't have to draw 50 component textures, just one ship texture. What would be the best way to go about this?</p>
  <p>I've been trying to do so using a FrameBuffer.  I've been able to draw the components to a Texture, and draw the texture to the screen, but no matter what I try the Texture ends up with a solid background the size of the frame buffer. It's like the clear command can't clear with transparency. Here's the drawing code I have at the moment. The ship is just a Sprite which i save the FrameBuffer texture to.</p>
  <pre class="lang-java prettyprint-override"><code>public void render(){
  
      if (ship == null){
          int screenwidth = Gdx.graphics.getWidth();
          int screenheight = Gdx.graphics.getHeight();
  
          SpriteBatch fb = new SpriteBatch();
  
          FrameBuffer fbo = new FrameBuffer(Format.RGB888, screenwidth, screenheight, false);
  
          fbo.begin();
  
          fb.enableBlending();
          Gdx.gl.glBlendFuncSeparate(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA);
  
          Gdx.gl.glClearColor(1, 0, 1, 0);
          Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  
          fb.begin();
  
          atlas.createSprite(&quot;0&quot;).draw(fb);
  
          fb.end();
  
          fbo.end();
  
          ship = new Sprite(fbo.getColorBufferTexture());
          ship.setPosition(0, -screenheight);
      }
  
      Gdx.gl.glClearColor(1, 0, 0, 1);
      Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  
      batch.begin();
  
      batch.enableBlending();
      batch.setBlendFunction(GL20.GL_ONE, GL20.GL_ZERO);
      ship.draw(batch);
      batch.end();
  }
  </code></pre>