Android GLES3.0 帧缓冲区不完整
Android GLES3.0 framebuffer incomplete
你能帮我弄清楚为什么下面的代码会生成 GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
mBitmap = BitmapFactory.decodeFile(imagePath);
int[] handles = { 0 };
GLES30.glGenTextures(1, handles, 0);
if (checkGlError("glGenTextures")) {
return 0;
}
outputTextureHandle = handles[0];
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, outputTextureHandle);
if (checkGlError("glBindTexture")) {
return 0;
}
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MIN_FILTER, GLES30.GL_LINEAR);
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MAG_FILTER, GLES30.GL_LINEAR);
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_S, GLES30.GL_CLAMP_TO_EDGE);
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_T, GLES30.GL_CLAMP_TO_EDGE);
if (checkGlError("glTexParameteri")) {
return 0;
}
int format = GLES30.GL_RGBA;
GLES30.glTexImage2D(GLES30.GL_TEXTURE_2D, 0, format, framebufferWidth, framebufferHeight, 0, format,
GLES30.GL_UNSIGNED_BYTE, null);
if (checkGlError("glTexImage2D")) {
return 0;
}
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, 0);
if (checkGlError("glBindTexture 0")) {
return 0;
}
framebufferWidth = mBitmap.getWidth();
framebufferHeight = mBitmap.getHeight();
int[] rfhandles = { 0 };
GLES30.glGenRenderbuffers(1, rfhandles, 0);
if (checkGlError("glGenRenderbuffers")) {
return 0;
}
int renderBufferId = rfhandles[0];
GLES30.glBindRenderbuffer(GLES30.GL_RENDERBUFFER, renderBufferId);
GLES30.glRenderbufferStorage(GLES30.GL_RENDERBUFFER, GLES30.GL_DEPTH_COMPONENT16, framebufferWidth,
framebufferHeight);
GLES30.glBindRenderbuffer(GLES30.GL_RENDERBUFFER, 0);
int[] fbhandles = { 0 };
GLES30.glGenFramebuffers(1, fbhandles, 0);
if (checkGlError("glGenFramebuffers")) {
return 0;
}
framebufferHandle = fbhandles[0];
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, framebufferHandle);
if (checkGlError("glBindFramebuffer")) {
return 0;
}
GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_COLOR_ATTACHMENT0, GLES30.GL_TEXTURE_2D,
outputTextureHandle, 0);
if (checkGlError("glFramebufferTexture2D")) {
return 0;
}
GLES30.glFramebufferRenderbuffer(GLES30.GL_FRAMEBUFFER, GLES30.GL_DEPTH_ATTACHMENT, GLES30.GL_RENDERBUFFER,
renderBufferId);
if (checkGlError("glFramebufferRenderbuffer")) {
return 0;
}
int framebufferStatus = GLES30.glCheckFramebufferStatus(GLES30.GL_FRAMEBUFFER);
Log.d(TAG, "framebufferStatus: " + framebufferStatus);
if (GLES30.GL_FRAMEBUFFER_COMPLETE != framebufferStatus) {
Log.d(TAG, "framebuffer incomplete");
return 0;
}
if (checkGlError("glCheckFramebufferStatus")) {
return 0;
}
是的,确实@andras的建议是对的。 outputTextureHandle
的维度设置为 0。
我需要搬家
framebufferWidth = mBitmap.getWidth();
framebufferHeight = mBitmap.getHeight();
准备outputTextureHandle
的代码之前。
你能帮我弄清楚为什么下面的代码会生成 GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
mBitmap = BitmapFactory.decodeFile(imagePath);
int[] handles = { 0 };
GLES30.glGenTextures(1, handles, 0);
if (checkGlError("glGenTextures")) {
return 0;
}
outputTextureHandle = handles[0];
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, outputTextureHandle);
if (checkGlError("glBindTexture")) {
return 0;
}
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MIN_FILTER, GLES30.GL_LINEAR);
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_MAG_FILTER, GLES30.GL_LINEAR);
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_S, GLES30.GL_CLAMP_TO_EDGE);
GLES30.glTexParameteri(GLES30.GL_TEXTURE_2D, GLES30.GL_TEXTURE_WRAP_T, GLES30.GL_CLAMP_TO_EDGE);
if (checkGlError("glTexParameteri")) {
return 0;
}
int format = GLES30.GL_RGBA;
GLES30.glTexImage2D(GLES30.GL_TEXTURE_2D, 0, format, framebufferWidth, framebufferHeight, 0, format,
GLES30.GL_UNSIGNED_BYTE, null);
if (checkGlError("glTexImage2D")) {
return 0;
}
GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, 0);
if (checkGlError("glBindTexture 0")) {
return 0;
}
framebufferWidth = mBitmap.getWidth();
framebufferHeight = mBitmap.getHeight();
int[] rfhandles = { 0 };
GLES30.glGenRenderbuffers(1, rfhandles, 0);
if (checkGlError("glGenRenderbuffers")) {
return 0;
}
int renderBufferId = rfhandles[0];
GLES30.glBindRenderbuffer(GLES30.GL_RENDERBUFFER, renderBufferId);
GLES30.glRenderbufferStorage(GLES30.GL_RENDERBUFFER, GLES30.GL_DEPTH_COMPONENT16, framebufferWidth,
framebufferHeight);
GLES30.glBindRenderbuffer(GLES30.GL_RENDERBUFFER, 0);
int[] fbhandles = { 0 };
GLES30.glGenFramebuffers(1, fbhandles, 0);
if (checkGlError("glGenFramebuffers")) {
return 0;
}
framebufferHandle = fbhandles[0];
GLES30.glBindFramebuffer(GLES30.GL_FRAMEBUFFER, framebufferHandle);
if (checkGlError("glBindFramebuffer")) {
return 0;
}
GLES30.glFramebufferTexture2D(GLES30.GL_FRAMEBUFFER, GLES30.GL_COLOR_ATTACHMENT0, GLES30.GL_TEXTURE_2D,
outputTextureHandle, 0);
if (checkGlError("glFramebufferTexture2D")) {
return 0;
}
GLES30.glFramebufferRenderbuffer(GLES30.GL_FRAMEBUFFER, GLES30.GL_DEPTH_ATTACHMENT, GLES30.GL_RENDERBUFFER,
renderBufferId);
if (checkGlError("glFramebufferRenderbuffer")) {
return 0;
}
int framebufferStatus = GLES30.glCheckFramebufferStatus(GLES30.GL_FRAMEBUFFER);
Log.d(TAG, "framebufferStatus: " + framebufferStatus);
if (GLES30.GL_FRAMEBUFFER_COMPLETE != framebufferStatus) {
Log.d(TAG, "framebuffer incomplete");
return 0;
}
if (checkGlError("glCheckFramebufferStatus")) {
return 0;
}
是的,确实@andras的建议是对的。 outputTextureHandle
的维度设置为 0。
我需要搬家
framebufferWidth = mBitmap.getWidth();
framebufferHeight = mBitmap.getHeight();
准备outputTextureHandle
的代码之前。