Game Development Community

Chapter 17 - GenericMaterial Bombs

by David Everhart · in · 12/17/2008 (2:52 pm) · 1 replies

I am testing out the setup for the HLSL from the example:

GenericMaterialTextureBind textureBind = new GenericMaterialTextureBind();
            textureBind.BindType = BindType.Name;
            textureBind.BindAddress = "baseTexture";
            textureBind.TextureFilename = "images/Background.png";

            GenericMaterial material = new GenericMaterial();
            material.EffectFilename = "data/TestEffect.xnb";
            material.TextureBinds.Add(textureBind);

It will bomb on the material.EffectFileName, because the texturebinds are null at that point. GenericMaterial.cs line 582. It will also bomb on the floatbinds check as well. Any idea on this? I can easily modify the source if I have to by adding a null check, but wanted to make sure there wasnt something wild going on.

#1
12/17/2008 (3:56 pm)
I got around it by adding null checks to the ClearParameters function in GenericMaterial, and instantiating a new list for the generic material. Sounds like maybe this is fixed in tx 3.0?
GenericMaterial material = new GenericMaterial();
            material.EffectFilename = "data/TestEffect.xnb";
            material.TextureBinds = new List<GenericMaterialTextureBind>();
            material.TextureBinds.Add(textureBind);