@Override public int createTexture(boolean repeatX, boolean repeatY, boolean mipmaps) { int[] tex = new int[1]; gl.glGenTextures(1, tex, 0); gl.glBindTexture(GL_TEXTURE_2D, tex[0]); gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, magFilter); gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, mipmapify(minFilter, mipmaps)); gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, repeatX ? GL_REPEAT : GL_CLAMP_TO_EDGE); gl.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, repeatY ? GL_REPEAT : GL_CLAMP_TO_EDGE); if (STATS_ENABLED) stats.texCreates++; return tex[0]; }
void viewDidAppear() { // Apple re-disables GL_BLEND &c between our call to init() and the eventual call to this // method; why why why? I want my six hours spend on bullshit debugging back! gl.glDisable(GL_CULL_FACE); gl.glEnable(GL_BLEND); gl.glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); gl.glClearColor(0, 0, 0, 1); defaultFramebuffer = gl.glGetInteger(GL_FRAMEBUFFER_BINDING); }
@Override public void generateMipmap(int tex) { gl.glBindTexture(GL_TEXTURE_2D, tex); gl.glGenerateMipmap(GL_TEXTURE_2D); }
@Override public void clear(float r, float g, float b, float a) { gl.glClearColor(r, g, b, a); gl.glClear(GL_COLOR_BUFFER_BIT); }
@Override public void bindTexture(int tex) { // TODO: track last bound texture, and avoid calling if it didn't change? gl.glBindTexture(GL_TEXTURE_2D, tex); if (STATS_ENABLED) stats.texBinds++; }
void updateTexture(int tex, int width, int height, IntPtr data) { gl.glBindTexture(GL_TEXTURE_2D, tex); gl.glPixelStorei(GL_UNPACK_ALIGNMENT, 1); OpenGLES.glTexImage2Dp(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); } }
@Override public int createTexture(int width, int height, boolean repeatX, boolean repeatY, boolean mm) { int tex = createTexture(repeatX, repeatY, mm); gl.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (ByteBuffer) null); return tex; }
@Override public boolean startClipped(int x, int y, int width, int height) { flush(); // flush any pending unclipped calls Rectangle r = pushScissorState(x, curFbufHeight - y - height, width, height); gl.glScissor(r.x, r.y, r.width, r.height); if (getScissorDepth() == 1) gl.glEnable(GL_SCISSOR_TEST); return !r.isEmpty(); }
@Override public int getInteger(int param) { return gl.glGetInteger(param); }
void updateTexture(int tex, ImageElement img) { gl.glBindTexture(HtmlGL20.GL_TEXTURE_2D, tex); glc.texImage2D(TEXTURE_2D, 0, RGBA, RGBA, UNSIGNED_BYTE, img); }
@Override public void texImage2D(Image image, int target, int level, int internalformat, int format, int type) { gl.glTexImage2D(target, level, internalformat, (int) image.width(), (int) image.height(), 0, format, type, getRgba(image)); }
public void init() { gl.glDisable(GL_CULL_FACE); gl.glEnable(GL_BLEND); gl.glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); gl.glClearColor(0, 0, 0, 1); if (quadShader != null) { quadShader.clearProgram(); } if (trisShader != null) { trisShader.clearProgram(); } quadShader = createQuadShader(); trisShader = new IndexedTrisShader(this); checkGLError("initGL"); }
void updateTexture(int texture, Bitmap image) { gl.glBindTexture(GL20.GL_TEXTURE_2D, texture); GLUtils.texImage2D(GL20.GL_TEXTURE_2D, 0, image, 0); checkGLError("updateTexture end"); }
@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); } } }
void updateTexture(int texture, Bitmap image) { gl.glBindTexture(GL20.GL_TEXTURE_2D, texture); GLUtils.texImage2D(GL20.GL_TEXTURE_2D, 0, image, 0); checkGLError("updateTexture end"); }
@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); } } }