Original Post
I have never seen the use of structures in HLSL besides for vertex/pixel shader input/output. For this reason I don't even know if what I'm doing is valid... This is in my HLSL effect file: The reason I'm using a structure is to simply encapsulate the material into one D3DXHANDLE and to directly parallel the D3DMATERIAL9 structure within the application. This is in the application code: where Effect is a valid ID3DXEffect interface, material is a valid D3DMATERIAL9 structure, and hMaterial is a valid D3DXHANDLE to the "Material" parameter in the effect. hr == INVALIDCALL Either what I'm doing isn't valid or I'm forgetting something? [Edit] Apparently I bypassed the phrase "Gets the handle of a top-level parameter or a structure member parameter." in the ID3DXBaseEffect::GetParameter documentation. I assume this is the issue, but is there any better way to do this than just doing 4 calls to SetFloatArray and 1 call to SetFloat? I thought maybe SetRawValue but I'm not sure if this would be better or not and I'd have to split off the Power since it isn't an even float4 structure. [Edited by - Gondolin on August 31, 2006 3:49:04 AM]
struct MeshMaterial
{
vector DiffuseColor;
vector AmbientColor;
vector SpecularColor;
vector EmissiveColor;
float Power;
};
MeshMaterial Material < string Binding = "Mesh.Material"; >;
HRESULT hr = Effect->SetFloatArray(hMaterial, (float*)&material, 17);