本文整理匯總了Java中android.opengl.GLES20.glFramebufferRenderbuffer方法的典型用法代碼示例。如果您正苦於以下問題:Java GLES20.glFramebufferRenderbuffer方法的具體用法?Java GLES20.glFramebufferRenderbuffer怎麽用?Java GLES20.glFramebufferRenderbuffer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.opengl.GLES20
的用法示例。
在下文中一共展示了GLES20.glFramebufferRenderbuffer方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createFrameBuffer
import android.opengl.GLES20; //導入方法依賴的package包/類
/**
* 創建FrameBuffer
* @param hasRenderBuffer 是否啟用RenderBuffer
* @param width 寬度
* @param height 高度
* @param texType 類型,一般為{@link GLES20#GL_TEXTURE_2D}
* @param texFormat 紋理格式,一般為{@link GLES20#GL_RGBA}、{@link GLES20#GL_RGB}等
* @param minParams 紋理的縮小過濾參數
* @param maxParams 紋理的放大過濾參數
* @param wrapS 紋理的S環繞參數
* @param wrapT 紋理的W環繞參數
* @return 創建結果,0表示成功,其他值為GL錯誤
*/
public int createFrameBuffer(boolean hasRenderBuffer,int width,int height,int texType,int texFormat,
int minParams,int maxParams,int wrapS,int wrapT){
mFrameTemp=new int[4];
GLES20.glGenFramebuffers(1,mFrameTemp,0);
GLES20.glGenTextures(1,mFrameTemp,1);
GLES20.glBindTexture(texType,mFrameTemp[1]);
GLES20.glTexImage2D(texType, 0,texFormat, width, height,
0, texFormat, GLES20.GL_UNSIGNED_BYTE, null);
//設置縮小過濾為使用紋理中坐標最接近的一個像素的顏色作為需要繪製的像素顏色
GLES20.glTexParameteri(texType, GLES20.GL_TEXTURE_MIN_FILTER,minParams);
//設置放大過濾為使用紋理中坐標最接近的若幹個顏色,通過加權平均算法得到需要繪製的像素顏色
GLES20.glTexParameteri(texType, GLES20.GL_TEXTURE_MAG_FILTER,maxParams);
//設置環繞方向S,截取紋理坐標到[1/2n,1-1/2n]。將導致永遠不會與border融合
GLES20.glTexParameteri(texType, GLES20.GL_TEXTURE_WRAP_S,wrapS);
//設置環繞方向T,截取紋理坐標到[1/2n,1-1/2n]。將導致永遠不會與border融合
GLES20.glTexParameteri(texType, GLES20.GL_TEXTURE_WRAP_T,wrapT);
GLES20.glGetIntegerv(GLES20.GL_FRAMEBUFFER_BINDING,mFrameTemp,3);
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,mFrameTemp[0]);
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0,
texType, mFrameTemp[1], 0);
if(hasRenderBuffer){
GLES20.glGenRenderbuffers(1,mFrameTemp,2);
GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER,mFrameTemp[2]);
GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER,GLES20.GL_DEPTH_COMPONENT16,width,height);
GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER,GLES20.GL_DEPTH_ATTACHMENT,GLES20.GL_RENDERBUFFER,mFrameTemp[2]);
}
return GLES20.glGetError();
}
示例2: createEffectTexture
import android.opengl.GLES20; //導入方法依賴的package包/類
private void createEffectTexture() {
AndroidUntil.checkGlError("initFBO_S");
GLES20.glGenFramebuffers(1, mFboId, 0);
GLES20.glGenRenderbuffers(1, mRboId, 0);
GLES20.glGenTextures(1, mTexId, 0);
GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER, mRboId[0]);
GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER,
GLES20.GL_DEPTH_COMPONENT16, mWidth, mHeight);
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mFboId[0]);
GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER,
GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_RENDERBUFFER, mRboId[0]);
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexId[0]);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA,
mWidth, mHeight, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,
GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, mTexId[0], 0);
if (GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER) !=
GLES20.GL_FRAMEBUFFER_COMPLETE) {
throw new RuntimeException("glCheckFramebufferStatus()");
}
AndroidUntil.checkGlError("initFBO_E");
}
示例3: bind
import android.opengl.GLES20; //導入方法依賴的package包/類
public void bind() {
GLES20.glViewport(0, 0, width, height);
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, frameBufferId);
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0,
GLES20.GL_TEXTURE_2D, texId, 0);
GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER, GLES20.GL_DEPTH_ATTACHMENT,
GLES20.GL_RENDERBUFFER, renderBufferId);
}
示例4: prepareFramebuffer
import android.opengl.GLES20; //導入方法依賴的package包/類
/**
* Prepares the off-screen framebuffer.
*/
private void prepareFramebuffer(int width, int height) {
GlUtil.checkGlError("prepareFramebuffer start");
int[] values = new int[1];
// Create a texture object and bind it. This will be the color buffer.
GLES20.glGenTextures(1, values, 0);
GlUtil.checkGlError("glGenTextures");
mOffscreenTexture = values[0]; // expected > 0
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mOffscreenTexture);
GlUtil.checkGlError("glBindTexture " + mOffscreenTexture);
// Create texture storage.
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0,
GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
// Set parameters. We're probably using non-power-of-two dimensions, so
// some values may not be available for use.
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER,
GLES20.GL_NEAREST);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER,
GLES20.GL_LINEAR);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S,
GLES20.GL_CLAMP_TO_EDGE);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T,
GLES20.GL_CLAMP_TO_EDGE);
GlUtil.checkGlError("glTexParameter");
// Create framebuffer object and bind it.
GLES20.glGenFramebuffers(1, values, 0);
GlUtil.checkGlError("glGenFramebuffers");
mFramebuffer = values[0]; // expected > 0
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mFramebuffer);
GlUtil.checkGlError("glBindFramebuffer " + mFramebuffer);
// Create a depth buffer and bind it.
GLES20.glGenRenderbuffers(1, values, 0);
GlUtil.checkGlError("glGenRenderbuffers");
mDepthBuffer = values[0]; // expected > 0
GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER, mDepthBuffer);
GlUtil.checkGlError("glBindRenderbuffer " + mDepthBuffer);
// Allocate storage for the depth buffer.
GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER, GLES20.GL_DEPTH_COMPONENT16,
width, height);
GlUtil.checkGlError("glRenderbufferStorage");
// Attach the depth buffer and the texture (color buffer) to the framebuffer object.
GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER, GLES20.GL_DEPTH_ATTACHMENT,
GLES20.GL_RENDERBUFFER, mDepthBuffer);
GlUtil.checkGlError("glFramebufferRenderbuffer");
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0,
GLES20.GL_TEXTURE_2D, mOffscreenTexture, 0);
GlUtil.checkGlError("glFramebufferTexture2D");
// See if GLES is happy with all this.
int status = GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER);
if (status != GLES20.GL_FRAMEBUFFER_COMPLETE) {
throw new RuntimeException("Framebuffer not complete, status=" + status);
}
// Switch back to the default framebuffer.
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
GlUtil.checkGlError("prepareFramebuffer done");
}
示例5: attach
import android.opengl.GLES20; //導入方法依賴的package包/類
public void attach(int point, Renderbuffer buffer) {
bind();
GLES20.glFramebufferRenderbuffer(GLES20.GL_RENDERBUFFER, point, GLES20.GL_TEXTURE_2D, buffer.id());
}
示例6: attach
import android.opengl.GLES20; //導入方法依賴的package包/類
public void attach( int point, Renderbuffer buffer ) {
bind();
GLES20.glFramebufferRenderbuffer( GLES20.GL_RENDERBUFFER, point, GLES20.GL_TEXTURE_2D, buffer.id() );
}
示例7: initFBO
import android.opengl.GLES20; //導入方法依賴的package包/類
private void initFBO() {
// 初始化輸出紋理
if (mTextureOut != null) {
GLES20.glDeleteTextures(1, mTextureOut, 0);
mTextureOut = null;
}
mTextureOut = new int[1];
GLES20.glGenTextures(1, mTextureOut, 0);
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureOut[0]);
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA,
getWidth(), getHeight(), 0, GLES20.GL_RGBA,
GLES20.GL_UNSIGNED_BYTE, null);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S,
GLES20.GL_CLAMP_TO_EDGE);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T,
GLES20.GL_CLAMP_TO_EDGE);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,
GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
// 初始化幀緩衝和深度緩衝
if (mFrameBuffer != null) {
GLES20.glDeleteFramebuffers(1, mFrameBuffer, 0);
mFrameBuffer = null;
}
if (mDepthRenderBuffer != null) {
GLES20.glDeleteRenderbuffers(1, mDepthRenderBuffer, 0);
mDepthRenderBuffer = null;
}
mFrameBuffer = new int[1];
mDepthRenderBuffer = new int[1];
GLES20.glGenFramebuffers(1, mFrameBuffer, 0);
GLES20.glGenRenderbuffers(1, mDepthRenderBuffer, 0);
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mFrameBuffer[0]);
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,
GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D,
mTextureOut[0], 0);
GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER, mDepthRenderBuffer[0]);
GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER,
GLES20.GL_DEPTH_COMPONENT16, getWidth(), getHeight());
GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER,
GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_RENDERBUFFER,
mDepthRenderBuffer[0]);
}