0
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ Try using debug DirectX runtime. Maybe it will print more precise error message. \$\endgroup\$ Apr 1, 2012 at 1:19
  • \$\begingroup\$ I tried using it with DebugView, but it only prints a few HR originated and HR propagated messages. \$\endgroup\$
    – jmegaffin
    Apr 1, 2012 at 1:24

1 Answer 1

3
\$\begingroup\$

The ImageLoadInformation struct does not have sane defaults. You need to make sure they're all set to an acceptable value. You can use the ImageLoadInformation.FromDefaults() function to get a starting value with more appropriate defaults.

EDIT: You don't mention in your post whether you're loading from a DDS file. I don't think D3DX knows how to load a cube texture from any format besides DDS.

\$\endgroup\$
4
  • \$\begingroup\$ Okay, I did that, and I still get a similar error (E_INVALIDARG: An invalid parameter was passed to the returning function (-2147024809)). \$\endgroup\$
    – jmegaffin
    Apr 1, 2012 at 1:15
  • \$\begingroup\$ The FromDefaults function just fills each parameter with D3DX_DEFAULT. I don't know if the loading function can accept that. You probably need to set at least a few of the fields. \$\endgroup\$
    – MikeP
    Apr 1, 2012 at 3:01
  • \$\begingroup\$ I filled out the whole struct and now I get a super non-descriptive E_FAIL: An undetermined error occurred (-2147467259). I edited my original question. \$\endgroup\$
    – jmegaffin
    Apr 1, 2012 at 12:49
  • \$\begingroup\$ Are you sure there's no debug output? Make sure you create your Device with the Debug flag and that you've enabled unmanaged debugging in your project. \$\endgroup\$
    – MikeP
    Apr 1, 2012 at 13:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .