这是我创建新 FBO 的代码。现在,我正在使用渲染缓冲区。
/**
* Creates a new FBO.
* @param width The width of the FBO to create.
* @param height The height of the FBO to create.
* @return an int[] array containing the buffer IDs in the
* following order: {frameBufferID, colorBufferID (texture), depthBufferID}.
*/
public static int[] newFBO(int width, int height) {
int[] out = new int[3];
out[0] = glGenFramebuffersEXT();
out[1] = glGenTextures();
out[2] = glGenRenderbuffersEXT();
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, out[0]);
glBindTexture(GL_TEXTURE_2D, out[1]);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, org.lwjgl.opengl.GL12.GL_TEXTURE_MAX_LEVEL,20);
glTexParameteri(GL_TEXTURE_2D, GL14.GL_GENERATE_MIPMAP,GL_TRUE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0,GL_RGBA, GL_INT, (java.nio.ByteBuffer) null);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_COLOR_ATTACHMENT0_EXT,GL_TEXTURE_2D, out[1], 0);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, out[2]);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL14.GL_DEPTH_COMPONENT24, width, height);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,GL_DEPTH_ATTACHMENT_EXT,GL_RENDERBUFFER_EXT, out[2]);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
return out;
}
我想将渲染/深度缓冲区切换到深度纹理。我会改变什么来做到这一点?(我正在使用 LWJGL)