本文整理汇总了Java中android.opengl.GLES20.glRenderbufferStorage方法的典型用法代码示例。如果您正苦于以下问题:Java GLES20.glRenderbufferStorage方法的具体用法?Java GLES20.glRenderbufferStorage怎么用?Java GLES20.glRenderbufferStorage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.opengl.GLES20
的用法示例。
在下文中一共展示了GLES20.glRenderbufferStorage方法的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: RenderBuffer
import android.opengl.GLES20; //导入方法依赖的package包/类
public RenderBuffer(int width, int height, int activeTexUnit) {
this.width = width;
this.height = height;
this.activeTexUnit = activeTexUnit;
int[] genbuf = new int[1];
// Generate and bind 2d texture
GLES20.glActiveTexture(activeTexUnit);
texId = MyGLUtils.genTexture();
// No reason to specify any pixels as input data of texture attachment of FBO. by begeekmyfriend
// https://github.com/nekocode/CameraFilter/pull/17/commits/2160638bb17c82adcf22b2ad29a2d0703b81a151
// IntBuffer texBuffer =
// ByteBuffer.allocateDirect(width * height * 4).order(ByteOrder.nativeOrder()).asIntBuffer();
// GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, texBuffer);
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
// Generate frame buffer
GLES20.glGenFramebuffers(1, genbuf, 0);
frameBufferId = genbuf[0];
// Bind frame buffer
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, frameBufferId);
// Generate render buffer
GLES20.glGenRenderbuffers(1, genbuf, 0);
renderBufferId = genbuf[0];
// Bind render buffer
GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER, renderBufferId);
GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER, GLES20.GL_DEPTH_COMPONENT16, width, height);
unbind();
}
示例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: storage
import android.opengl.GLES20; //导入方法依赖的package包/类
public void storage(int format, int width, int height) {
GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER, format, width, height);
}
示例6: storage
import android.opengl.GLES20; //导入方法依赖的package包/类
public void storage( int format, int width, int height ) {
GLES20.glRenderbufferStorage( GLES20.GL_RENDERBUFFER, format , width, height );
}
示例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]);
}