如何获取当前绑定FBO的颜色附件数量?我检查了'-|[[:blank:]]+'
和glGetInteger
,但他们没有枚举来获取这些值。
答案 0 :(得分:4)
未经测试,但应该这样做:
GLint maxAtt = 0;
glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &maxAtt);
int nAtt = 0;
for (int iAtt = 0; iAtt < maxAtt; ++iAtt) {
GLint objType = GL_NONE;
glGetFramebufferAttachmentParameteriv(
GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + iAtt,
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &objType);
if (objType != GL_NONE) {
++nAtt;
}
}
// nAtt is the number of color attachments.
您可以使用GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME
代替GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
执行类似操作,并将值与0
进行比较。