我正在尝试将大小为1920 X 1080的自定义帧缓冲区转换为大小为800 X 600的默认帧缓冲区。
使用以下选项创建窗口
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_FLOATING , GLFW_TRUE);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
glfwWindowHint(GLFW_SAMPLES, 4);
GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "Renderer", nullptr, nullptr); // Create the render window
glEnable(GL_MULTISAMPLE);
glEnable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
我首先创建一个纹理对象。
// create a texture object
glGenTextures(1, &textureMsaaId);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, textureMsaaId);
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_RGBA8, 1920, 1080, false);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0);
创建帧缓冲区
glGenFramebuffers(1, &fboMsaaId);
glBindFramebuffer(GL_FRAMEBUFFER, fboMsaaId);
// create a 4x MSAA renderbuffer object for depthbuffer
glGenRenderbuffers(1, &rboDepthId);
glBindRenderbuffer(GL_RENDERBUFFER, rboDepthId);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, 4, 1920, 1080);
// attach msaa Texture and RBO to FBO attachment points
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D_MULTISAMPLE, textureMsaaId, 0);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rboDepthId);
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status == GL_FRAMEBUFFER_COMPLETE)
qDebug() << "Frame buffer Completed";
else
qDebug() << "Frame buffer NOT Completed";
glBindFramebuffer(GL_FRAMEBUFFER, 0);
我收到帧缓冲区未完成的错误。
错误是GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT,这是由于渲染缓冲区附件引起的。