private boolean bindTexture(BasicTexture texture) { if (!texture.onBind(this)) return false; mGLState.setTexture2DEnabled(true); mGL.glBindTexture(GL11.GL_TEXTURE_2D, texture.getId()); return true; }
private boolean bindTexture(final BasicTexture texture) { if (!texture.onBind(this)) { return false; } final int target = texture.getTarget(); mGLState.setTextureTarget(target); mGL.glBindTexture(target, texture.getId()); return true; }
/** * Updates the content on GPU's memory. * * @param canvas */ public void updateContent(final GLCanvas canvas) { if (!isLoaded()) { if (mThrottled && ++sUploadedCount > UPLOAD_LIMIT) { return; } uploadToCanvas(canvas); } else if (!mContentValid) { final Bitmap bitmap = getBitmap(); final int format = GLUtils.getInternalFormat(bitmap); final int type = GLUtils.getType(bitmap); canvas.getGLInstance().glBindTexture(GL10.GL_TEXTURE_2D, mId); GLUtils.texSubImage2D(GL10.GL_TEXTURE_2D, 0, 0, 0, bitmap, format, type); freeBitmap(); mContentValid = true; } }
gl.glBindTexture(GL10.GL_TEXTURE_2D, sTextureId[0]); gl.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE); gl.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
public BasicTexture copyTexture(int x, int y, int width, int height) { if (isMatrixRotatedOrFlipped(mMatrixValues)) { throw new IllegalArgumentException("cannot support rotated matrix"); } float points[] = mapPoints(mMatrixValues, x, y + height, x + width, y); x = (int) points[0]; y = (int) points[1]; width = (int) points[2] - x; height = (int) points[3] - y; GL11 gl = mGL; RawTexture texture = RawTexture.newInstance(this); gl.glBindTexture(GL11.GL_TEXTURE_2D, texture.getId()); texture.setSize(width, height); int[] cropRect = {0, 0, width, height}; gl.glTexParameteriv(GL11.GL_TEXTURE_2D, GL11Ext.GL_TEXTURE_CROP_RECT_OES, cropRect, 0); gl.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP_TO_EDGE); gl.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP_TO_EDGE); gl.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); gl.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); gl.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, x, y, texture.getTextureWidth(), texture.getTextureHeight(), 0); return texture; }
/** * Updates the content on GPU's memory. * @param canvas */ public void updateContent(GLCanvas canvas) { if (!isLoaded(canvas)) { if (mThrottled && ++sUploadedCount > UPLOAD_LIMIT) { return; } uploadToCanvas(canvas); } else if (!mContentValid) { try { Bitmap bitmap = getBitmap(); int format = GLUtils.getInternalFormat(bitmap); int type = GLUtils.getType(bitmap); canvas.getGLInstance().glBindTexture(GL11.GL_TEXTURE_2D, mId); GLUtils.texSubImage2D(GL11.GL_TEXTURE_2D, 0, mBorder, mBorder, bitmap, format, type); freeBitmap(); mContentValid = true; } catch (Error e) { Log.e(TAG, "Error loading bitmap", e); if (mBitmap != null) freeBitmap(); mContentValid = false; } } }
gl.glBindTexture(GL11.GL_TEXTURE_2D, sTextureId[0]); gl.glTexParameterfv(GL11.GL_TEXTURE_2D, GL11Ext.GL_TEXTURE_CROP_RECT_OES, sCropRect, 0);
gl.glBindTexture(GL10.GL_TEXTURE_2D, sTextureId[0]); gl.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE); gl.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);