Your question is somewhat confused as you are asking for two different things.
Here is a simple question:
How can I get the size of the first color attachment, given only the framebuffer object identifier (fboId)?
It's simple: add the texture / renderbuffer to this attachment, get what mipmap level and array level is connected, then request the texture / renderbuffer how big it is.
The first two steps are done with glGetFramebufferAttachmentParameter (note the Attachment keyword) for GL_COLOR_ATTACHMENT0 . You request GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE to get, whether it be a rendering GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE or texture. You can get the name renderbuffer / texture with GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME .
If the object is a rendering buffer, you can bind the rendering buffer and use glGetRenderbufferParameter to retrieve the rendering of the GL_RENDERBUFFER_WIDTH and GL_RENDERBUFFER_HEIGHT .
If the object is a texture, you will need to do more work. You need to request the GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL binding parameter to get the mipmap level.
Of course, now you need to know how to tie it. If you use versions of OpenGL up to 4.4 or without specific extensions, this is difficult. See, you need to know what type of target texture to use. Stupid and annoying, it might seem, the only way to determine the goal only on behalf of the texture object is to ... try it all. Go through each target and mark glGetError . One for which GL_INVALID_OPERATION does not return is correct.
If you have GL 4.4 or ARB_multi_bind , you can simply use glBindTextures (note the "s"), which does not require a target. And if you have 4.5 or ARB_direct_state_access , you don't need to bind the texture at all. Functions like DSA do not need a target texture, and also provides glBindTextureUnit , which binds the texture to its natural internal purpose.
Once you have a texture border and a mipmap level, you use glGetTexLevelParameter to query GL_TEXTURE_WIDTH and GL_TEXTURE_HEIGHT for that level.
Now this is a simple problem. The tough problem is that your title asks:
I want to determine the size (width, height) of a framebuffer object.
The size of the rendered FBO area does not match the size of GL_COLOR_ATTACHMENT0 . The output area of ββthe FBO is the intersection of all sizes of all images attached to the FBO.
Unless you have special knowledge about this FBO, you cannot assume that the FBO contains only one image or all images are the same size (and if you have special knowledge about FBO, then, frankly, you should also have special knowledge about how big they are). Therefore, you will need to repeat the above procedure for each attachment (if the type is GL_NONE , then nothing is attached). Then take the intersection of the return values ββ(i.e. the smallest width and height).
In general, you do not need to ask the FBO what you created, how big it is. Just as you do not need to specify textures, how large they are. You made them; by definition, you know how big they are. You put them in the FBO, so again you know how great it is.