我想将深度纹理作为颜色附件附加到帧缓冲区。(我在 iOS 上,支持 GL_OES_depth_texture)
所以我设置了这样的纹理:
glGenTextures(1, &TextureName);
glBindTexture(GL_TEXTURE_2D, TextureName);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, ImageSize.Width, ImageSize.Height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, 0);
glGenFramebuffers(1, &ColorFrameBuffer);
glBindFramebuffer(GL_FRAMEBUFFER, ColorFrameBuffer);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, TextureName, 0);
但是现在如果我检查帧缓冲区状态,我会得到一个GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
我在这里做错了什么?
我也尝试了一些与GL_DEPTH_COMPONENT16
,的组合GL_DEPTH_COMPONENT24_OES
,GL_DEPTH_COMPONENT32_OES
但这些都不起作用(也支持 GL_OES_depth24)