在 Android OpenGL ES 3.1 上设置帧缓冲区的 Depth/Stencil 缓冲区
Setting Framebuffer's Depth/Stencil Buffer on Android OpenGL ES 3.1
我正在尝试将深度和模板缓冲区附加到帧缓冲区。我这样做如下:
int[] bufferHandle = new int[1];
GLES31.glGenRenderbuffers(1, bufferHandle, 0); // glError = 0 (GL_NO_ERROR)
GLES31.glRenderbufferStorage(GLES31.GL_RENDERBUFFER, GLES31.GL_DEPTH24_STENCIL8, width, height); // glError = 1282 (GL_INVALID_OPERATION)
GLES31.glBindRenderbuffer(GLES31.GL_RENDERBUFFER, 0); // // glError = 0 (GL_NO_ERROR)
GLES31.glFramebufferRenderbuffer(GLES31.GL_FRAMEBUFFER, GLES31.GL_DEPTH_STENCIL_ATTACHMENT, GLES31.GL_RENDERBUFFER, bufferHandle); // glError = 1282 (GL_INVALID_OPERATION)
glRenderbufferStorage
和 glFramebufferRenderbuffer
呼叫 return 1282 (GL_INVALID_OPERATION)。有什么我可能遗漏的想法吗?
错误发生,因为没有创建渲染缓冲区对象。
glGenRenderbuffers
generates a unused name respectively reserves a name, which can be used for a render buffer, but it doesn't create or bind the render buffer object. For this you've to call glBindRenderbuffer
:
int[] bufferHandle = new int[1];
GLES31.glGenRenderbuffers(1, bufferHandle, 0);
GLES31.glBindRenderbuffer(GLES31.GL_RENDERBUFFER, bufferHandle[0]);
GLES31.glRenderbufferStorage(GLES31.GL_RENDERBUFFER, GLES31.GL_DEPTH24_STENCIL8, width, height);
注意,render buffer对象是在第一次调用glBindRenderbuffer
时创建的,同时对象绑定到指定的target。
glRenderbufferStorage
建立数据存储的格式和大小。
我正在尝试将深度和模板缓冲区附加到帧缓冲区。我这样做如下:
int[] bufferHandle = new int[1];
GLES31.glGenRenderbuffers(1, bufferHandle, 0); // glError = 0 (GL_NO_ERROR)
GLES31.glRenderbufferStorage(GLES31.GL_RENDERBUFFER, GLES31.GL_DEPTH24_STENCIL8, width, height); // glError = 1282 (GL_INVALID_OPERATION)
GLES31.glBindRenderbuffer(GLES31.GL_RENDERBUFFER, 0); // // glError = 0 (GL_NO_ERROR)
GLES31.glFramebufferRenderbuffer(GLES31.GL_FRAMEBUFFER, GLES31.GL_DEPTH_STENCIL_ATTACHMENT, GLES31.GL_RENDERBUFFER, bufferHandle); // glError = 1282 (GL_INVALID_OPERATION)
glRenderbufferStorage
和 glFramebufferRenderbuffer
呼叫 return 1282 (GL_INVALID_OPERATION)。有什么我可能遗漏的想法吗?
错误发生,因为没有创建渲染缓冲区对象。
glGenRenderbuffers
generates a unused name respectively reserves a name, which can be used for a render buffer, but it doesn't create or bind the render buffer object. For this you've to call glBindRenderbuffer
:
int[] bufferHandle = new int[1];
GLES31.glGenRenderbuffers(1, bufferHandle, 0);
GLES31.glBindRenderbuffer(GLES31.GL_RENDERBUFFER, bufferHandle[0]);
GLES31.glRenderbufferStorage(GLES31.GL_RENDERBUFFER, GLES31.GL_DEPTH24_STENCIL8, width, height);
注意,render buffer对象是在第一次调用glBindRenderbuffer
时创建的,同时对象绑定到指定的target。
glRenderbufferStorage
建立数据存储的格式和大小。