Floating point depth buffer creation fails

If I try to create a floating point depth buffer via:

glBindTexture(GL_TEXTURE_2D, id);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32F, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);

the glTexImage2D call fails with error 1281 (invalid value). It also fails with GL_DEPTH32F_STENCIL8, but seems to succeed with all the non-floating point formats that I’ve tried.
I’m running on an AMD 6870 under 4.2.

Am I doing something wrong?

Do you have this extension? GL_ARB_depth_buffer_float
http://www.opengl.org/registry/specs/ARB/depth_buffer_float.txt

and if you don’t have it, did you create a minimum of GL 3.0 context?

Did you setup the texture properly?
http://www.opengl.org/wiki/Common_Mistakes#Creating_a_Texture

Also, as always with glGetError(), you’ll have to make sure that the error flag is set to GL_NO_ERROR (or 0 by definition) before evaluating a certain operation. Can you confirm that the INVALID_VALUE is generated by glTexImage2d? To verify that it is, simply add


// clear the/all error flag/s
while(glGetError() != GL_NO_ERROR);

glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32F, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);

// if any, this one's the real error code
GLenum real_error = glGetError();

The reason I tend to propose this is simply because of the following take on error recording:

No other errors are recorded until glGetError is called, the error code is returned, and the flag is reset to GL_NO_ERROR. If a call to glGetError returns GL_NO_ERROR, there has been no detectable error since the last call to glGetError, or since the GL was initialized.

If something doesn’t make sense, because it should work as expected with the supplied values, the error might have been recorded before.

[QUOTE=V-man;1237519]Do you have this extension? GL_ARB_depth_buffer_float
http://www.opengl.org/registry/specs/ARB/depth_buffer_float.txt

and if you don’t have it, did you create a minimum of GL 3.0 context?[/QUOTE]

I created a GL 4.2 context. glGetString(GL_VERSION) reports “4.2.11631 Core Profile Context”.

[QUOTE=V-man;1237519]Did you setup the texture properly?
http://www.opengl.org/wiki/Common_Mistakes#Creating_a_Texture[/QUOTE]

Other than generating the texture id, are there are more steps than the glBindTexture and glTexImage2D calls (prior to these)?
Moving the wrap and filter mode setting to before the glTexImage2D call did not fix it.

There are no errors before the glTexImage2D call. I’m actually using LWJGL in debug, which checks for errors after every GL call. Manually checking for errors didn’t show anything either.

The order in which you set the data, wrap modes and filter modes isn’t important. You need to have set the modes properly in order to be able to sample the texture but not to upload data to the texture object.