E_FAIL: An undetermined error occurred (-2147467259) when loading a cube texture

Posted by Boreal on Game Development See other posts from Game Development or by Boreal
Published on 2012-04-01T00:50:07Z Indexed on 2012/04/01 17:44 UTC
Read the original article Hit count: 601

Filed under:
|
|
|

I'm trying to implement a skybox into my engine, and I'm having some trouble loading the image as a cube map. Everything works (but it doesn't look right) if I don't load using an ImageLoadInformation struct in the ShaderResourceView.FromFile() method, but it breaks if I do.

I need to, of course, because I need to tell SlimDX to load it as a cubemap. How can I fix this?

Here is my new loading code after the "fix":

public static void LoadCubeTexture(string filename)
{
    ImageLoadInformation loadInfo = new ImageLoadInformation()
    {
        BindFlags = BindFlags.ShaderResource,
        CpuAccessFlags = CpuAccessFlags.None,
        Depth = 32,
        FilterFlags = FilterFlags.None,
        FirstMipLevel = 0,
        Format = SlimDX.DXGI.Format.B8G8R8A8_UNorm,
        Height = 512,
        MipFilterFlags = FilterFlags.Linear,
        MipLevels = 1,
        OptionFlags = ResourceOptionFlags.TextureCube,
        Usage = ResourceUsage.Default,
        Width = 512
    };
    textures.Add(filename, ShaderResourceView.FromFile(Graphics.device, "Resources/" + filename, loadInfo));
}

Each of the faces of my cube texture are 512x512.

© Game Development or respective owner

Related posts about c#

Related posts about directx11