glTexImage2D - GL_TEXTURE_RECTANGLE_NV and compressed internal format

I have modified a legacy code (OpenGL 2.1) which uses glTexImage2D with GL_TEXTURE_RECTANGLE_NV texture target. I have noticed that when I set some compressed internal format, for example GL_COMPRESSED_RGBA_S3TC_DXT5_EXT it doesn’t work with GL_TEXTURE_RECTANGLE_NV (I get a white texture). I have tested other scenarios and everything works fine, i.e. GL_TEXTURE_2D with compressed internal format, GL_TEXTURE_RECTANGLE_NV with non-compressed internal format. Does it mean that GL_TEXTURE_RECTANGLE_NV can’t be used with compressed formats ?

I would consult the extension spec first:

Can compressed texture images be specified for a rectangular texture?

  RESOLUTION:  The generic texture compression internal formats
  introduced by ARB_texture_compression are supported for rectangular
  textures because the image is not presented as compressed data and
  the ARB_texture_compression extension always permits generic texture
  compression internal formats to be stored in uncompressed form.
  Implementations are free to support generic compression internal
  formats for rectangular textures if supported but such support is
  not required.

  This extensions makes a blanket statement that specific compressed
  internal formats for use with CompressedTexImage<n>DARB are NOT
  supported for rectangular textures.  This is because several
  existing hardware implementations of texture compression formats
  such as S3TC are not designed for compressing rectangular textures.
  This does not preclude future texture compression extensions from
  supporting compressed internal formats that do work with rectangular
  extensions (by relaxing the current blanket error condition).

Incidentally, ARB_texture_rectangle makes the same blanket statement.

However, see NV_texture_rectangle_compressed:

(1) What is the purpose of this extension?

RESOLVED:  When the original NV_texture_rectangle extension was first
published, then-current GPUs were incapable of supporting compressed
textures with the TEXTURE_RECTANGLE_NV target.  The rectangle texture
support in all current NVIDIA GPUs has no such limitation, and removing
this limitation allows applications to access compressed textures with
non-normalized texture coordinates.

Just to verify, you can try calling glGetInteralFormativ() to query which texture types/targets a particular internal format (e.g. DXT5) is supported for. For instance:

    const GLuint internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;

    for ( targets = [ The_ones_youre_interested_in ] )
        glGetInternalformativ( target, internalFormat, GL_INTERNALFORMAT_SUPPORTED, 1, &supported );
        glGetInternalformativ( target, internalFormat, GL_INTERNALFORMAT_PREFERRED, 1, &preferred );

Note that supported will get a bool result, and preferred will get an “internal format” result. Also check out GL_VERTEX_TEXTURE and GL_FRAGMENT_TEXTURE from the glGetInteralFormativ() page.