Search code examples
c#openglopentk

OpenTK - How to allocate storage for a cubemap array?


I need to create a cubemap array but I am having trouble finding the correct parameters.

There isn't much in terms of sample code but I did find this, in OpenGL:

HiGL_TexStorage3D(
    GL_TEXTURE_CUBE_MAP_ARRAY,
    Data->GetMipMap(),
    DestFormat,
    Data->GetWidth(),
    Data->GetHeight(),
);

So it seems the required texture target is GL_TEXTURE_CUBE_MAP_ARRAY, however OpenTK doesn't list this as an option, only these:

GL.TexStorage3D(TextureTarget3d.ProxyTexture2DArray, 0, format, width, height, depth);   
GL.TexStorage3D(TextureTarget3d.ProxyTexture3D, 0, format, width, height, depth);   
GL.TexStorage3D(TextureTarget3d.ProxyTextureCubeMap, 0, format, width, height, depth);   
GL.TexStorage3D(TextureTarget3d.Texture2DArray, 0, format, width, height, depth);   
GL.TexStorage3D(TextureTarget3d.Texture3D, 0, format, width, height, depth); 
GL.TexStorage3D(TextureTarget3d.TextureCubeMap, 0, format, width, height, depth);   

Can anybody shed some light? www.opentk.com disappeared a few months ago.


Solution

  • By using GL.TexImage3D instead, TextureCubeMapArray becomes accessable.

    GL.TexImage3D(TextureTarget.TextureCubeMapArray, 0, PixelInternalFormat.Rg16, size, size, layers * 6, 0, PixelFormat.Red, PixelType.Float, IntPtr.Zero);
    

    The problem was GL.TexStorage3D takes a parameter of type TextureTarget3D, which does not permit TextureCubeMapArray, whereas GL.TexImage3D takes TextureTarget, which does.

    Subsequently, I'm unsure if this still constitutes a bug, or how these two functions differ.