I want to use glClear and glClearColor to fill a frame buffer with a colour including alpha transparency. However the framebuffer always renders as opaque when binded to a textu
I think there's a basic misunderstanding of the framebuffer here. The framebuffer is not really a buffer of data in itself, it does not hold any data. You attach buffers TO it (like a texture) so that you can render to offscreen buffers in the same manner you draw to the screen. So when you say you want to "glClear and glClearColor to fill a frame buffer with a colour including alpha transparency", it doesn't quite make sense because the framebuffer does not hold any color data itself.
When you attach the texture to the framebuffer with this call:
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, surface.texture, 0)
You're making the "surface.texture" the rendering destination of the framebuffer. In other words, you're essentially saying "When I draw to this framebuffer, draw into this texture.".
The clear color alpha of the FBO must be equal to 0 :
glColorMask(TRUE, TRUE, TRUE, TRUE);
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT);
If you are trying to make the framebuffer transparent so you can render an object on top of your Desktop, you must know that that's not possible through Glut.
This kind of effect is specific to the platform you are using. What is it? Linux? Windows? Mac OS X? You'll have to get your hands dirty (drop Glut out of the equation) and understand a little more about building windows.
By the way, if your target is Windows you should check this:
(win32) How to make an OpenGL rendering context with transparent background?