I'm attempting to create a 16-bit texture to hold the height-map for my terrain patches, however both of the following are returning "invalid enumerant" errors. The CHECK_GL_ERROR() macro shows the gluErrorString as a message and breaks if glGetError returns something other than GL_NO_ERROR.
CHECK_GL_ERROR( glTexImage2D( GL_TEXTURE_2D, 0, GL_LUMINANCE16, width_, depth_, 0, GL_LUMINANCE, GL_UNSIGNED_SHORT, 0 /*data_.raw_data()*/ ) );
CHECK_GL_ERROR( glTexImage2D( GL_TEXTURE_2D, 0, GL_ALPHA16, width_, depth_, 0, GL_ALPHA, GL_UNSIGNED_SHORT, 0 /*data_.raw_data()*/ ) );
I have a created texture bound to the GL_TEXTURE_2D target, and have the same error with and without:
glPixelStorei( GL_UNPACK_ALIGNMENT, 2 );
I'm using an OpenGL 3.2 context, NVIDIA CUDA dev drivers 286.16 on a GTX 560Ti. Can anyone see what I am doing wrong?
Cheers
If you're using a core context, then that should be expected. There's no GL_LUMINANCE
or GL_ALPHA
image formats anymore.
If you want to emulate the effect of them, you need to create a single-channel image format. So GL_R16
should be your internal format. Then set up a texture swizzle mask on the texture object, so that the single Red channel is broadcast to either RGB or Alpha, as you see fit.
It's really better this way.