/** Stores the metadata for the currently bound frame buffer, and binds the supplied framebuffer. * This must be followed by a call to {@link #popFramebuffer}. Also, it is not allowed to push a * framebuffer if a framebuffer is already pushed. Only one level of nesting is supported. */ public void pushFramebuffer(int fbuf, int width, int height) { assert pushedFramebuffer == -1 : "Already have a pushed framebuffer"; pushedFramebuffer = lastFramebuffer; pushedWidth = curFbufWidth; pushedHeight = curFbufHeight; bindFramebuffer(fbuf, width, height); }
/** Pops the framebuffer pushed by a previous call to {@link #pushFramebuffer} and restores the * framebuffer that was active prior to that call. */ public void popFramebuffer() { assert pushedFramebuffer != -1 : "Have no pushed framebuffer"; bindFramebuffer(pushedFramebuffer, pushedWidth, pushedHeight); pushedFramebuffer = -1; }
protected void viewConfigChanged () { bindFramebuffer(); }
@Override protected void bindFramebuffer() { ctx.bindFramebuffer(fbuf, texWidth, texHeight); }
public void bindFramebuffer() { bindFramebuffer(defaultFramebuffer(), defaultFbufWidth, defaultFbufHeight); }
protected void createTexture() { tex = ctx.createTexture(texWidth, texHeight, false, false, false); fbuf = ctx.createFramebuffer(tex); ctx.bindFramebuffer(fbuf, texWidth, texHeight); ctx.clear(0, 0, 0, 0); }
@Override public void onSurfaceCreated() { createTexture(); if (cachedPixels != null) { try { AndroidGLContext actx = (AndroidGLContext) ctx; ByteBuffer pixelBuffer = ByteBuffer.allocate(texWidth * texHeight * 4); FileInputStream in = new FileInputStream(cachedPixels); in.read(pixelBuffer.array()); in.close(); int bufferTex = actx.createTexture(false, false, false); actx.gl.glTexImage2D(GL20.GL_TEXTURE_2D, 0, GL20.GL_RGBA, texWidth, texHeight, 0, GL20.GL_RGBA, GL20.GL_UNSIGNED_BYTE, pixelBuffer); // bind our surface framebuffer and render the saved texture data into it bindFramebuffer(); ctx.quadShader(null).prepareTexture(bufferTex, Tint.NOOP_TINT).addQuad( StockInternalTransform.IDENTITY, 0, texHeight, texWidth, 0, 0, 0, 1, 1); // rebind the default frame buffer (which will flush the rendering operation) ctx.bindFramebuffer(); ctx.destroyTexture(bufferTex); pixelBuffer = null; cachedPixels.delete(); cachedPixels = null; } catch (IOException e) { PlayN.reportError("Error reading cached surface pixels from file.", e); } } }
@Override public void onSurfaceCreated() { createTexture(); if (cachedPixels != null) { try { AndroidGLContext actx = (AndroidGLContext) ctx; ByteBuffer pixelBuffer = ByteBuffer.allocate(texWidth * texHeight * 4); FileInputStream in = new FileInputStream(cachedPixels); in.read(pixelBuffer.array()); in.close(); int bufferTex = actx.createTexture(false, false, false); actx.gl.glTexImage2D(GL20.GL_TEXTURE_2D, 0, GL20.GL_RGBA, texWidth, texHeight, 0, GL20.GL_RGBA, GL20.GL_UNSIGNED_BYTE, pixelBuffer); // bind our surface framebuffer and render the saved texture data into it bindFramebuffer(); ctx.quadShader(null).prepareTexture(bufferTex, Tint.NOOP_TINT).addQuad( StockInternalTransform.IDENTITY, 0, texHeight, texWidth, 0, 0, 0, 1, 1); // rebind the default frame buffer (which will flush the rendering operation) ctx.bindFramebuffer(); ctx.destroyTexture(bufferTex); pixelBuffer = null; cachedPixels.delete(); cachedPixels = null; } catch (IOException e) { PlayN.reportError("Error reading cached surface pixels from file.", e); } } }