Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
    
Try using debug DirectX runtime. Maybe it will print more precise error message. –  Mārtiņš Možeiko Apr 1 '12 at 1:19
    
I tried using it with DebugView, but it only prints a few HR originated and HR propagated messages. –  Boreal Apr 1 '12 at 1:24
add comment

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
    
Okay, I did that, and I still get a similar error (E_INVALIDARG: An invalid parameter was passed to the returning function (-2147024809)). –  Boreal Apr 1 '12 at 1:15
    
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. –  MikeP Apr 1 '12 at 3:01
    
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. –  Boreal Apr 1 '12 at 12:49
    
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. –  MikeP Apr 1 '12 at 13:59
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.