以下是一些代码,它们应该输出默认帧缓冲区的左背颜色附件的红色组件的大小:
#include <iostream>
#include <GL/glew.h>
#include <GL/gl.h>
#include <GLFW/glfw3.h>
#include "vect2.h"
using namespace std;
void outputError() {
GLenum error = glGetError();
switch (error) {
case GL_NO_ERROR:
cout << "GL_NO_ERROR" << endl;
break;
case GL_INVALID_ENUM:
cout << "GL_INVALID_ENUM" << endl;
break;
case GL_INVALID_VALUE:
cout << "GL_INVALID_VALUE" << endl;
break;
case GL_INVALID_OPERATION:
cout << "GL_INVALID_OPERATION" << endl;
break;
case GL_INVALID_FRAMEBUFFER_OPERATION:
cout << "GL_INVALID_FRAMEBUFFER_OPERATION" << endl;
break;
case GL_OUT_OF_MEMORY:
cout << "GL_OUT_OF_MEMORY" << endl;
break;
default:
cout << "UNKNOWN ERROR: " << error << endl;
break;
}
}
int main() {
glewExperimental = GL_TRUE;
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
GLFWwindow *window = glfwCreateWindow(800, 600, "OpenGL", nullptr, nullptr); // Windowed
glfwMakeContextCurrent(window);
glewInit();
GLint size = 0;
outputError();
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_BACK_LEFT, GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE, &size);
outputError();
return 0;
}
控制台输出是:
GL_NO_ERROR
GL_INVALID_ENUM
表示我对GL_INVALID_ENUM
的调用设置了glGetFramebufferAttachmentParameteriv
错误状态。这里有什么参数错误?
编辑:如果我在main
函数中运行此代码,从自定义FBO而不是默认帧缓冲区请求相同(红色)组件,则没有错误,我得到了预期的{{1}在32
变量中。这意味着当绑定默认帧缓冲区时,附件不仅与绑定FBO时不同,而且可以查询的参数也不同。所以基本上问题是:当绑定默认帧缓冲区时,可以使用此函数查询哪些参数?
size