fragment shader output

Hello,

I want to write float data from my fragment shader to texture.

fragment shader code:


#version 150
out float something;

void main(void)
{
  something = 123.321;
}

That’s how I initialized framebuffer and texture:


glBindFragDataLocation(myShader, 0, "something");

...

glBindTexture(GL_TEXTURE_2D, texture);
glTexImage(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, myFramebuffer);
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);

However it doesn’t work with this code.
Does anybody know how to do that?

The depth component is not a color output. It is the depth component. It is written by writing to gl_FragDepth.

Ok, so what texture format should I use?
And I also don’t want to bind texture to GL_DEPTH_ATTACHMENT.

A floating-point texture format that contains a single float value. Like GL_R32F.