Here is some code that's supposed to output the size of the red component of the default framebuffer's left back color attachment:
#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;
}
The console output is:
GL_NO_ERROR
GL_INVALID_ENUM
Meaning there is a GL_INVALID_ENUM error state set from my call to glGetFramebufferAttachmentParameteriv. What parameter is wrong here?
EDIT: If I run this code in the main function, requesting the same (red) component from a custom FBO instead of the default framebuffer, then there is no error and I get the expected 32 in the size variable. This means that not only are the attachments different when the default framebuffer is bound vs when an FBO is bound, but the parameters that can be queried for are also different. So basically the question is: what parameters can be queried for using this function when the default framebuffer is bound?
glGenFramebuffers(1, &framebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
glGenRenderbuffers(1, &rboColor);
glBindRenderbuffer(GL_RENDERBUFFER, rboColor);
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA32F, 800, 600);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, rboColor);
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE, &size);