(Solved) [SlimDX] Setting Shader Resource Variables in DirectX 10

Started by
4 comments, last by GoodFun 15 years, 11 months ago
Hi there, does anyone have some examples on how to set resource variables in shaders using SlimDX and DirectX 10? i.e. extern Texture2D variables and also variables in cbuffers? The only DirectX 10 example that I have only has a simple vertex shader but no textures or cbuffers. Any help is as usual greatly appreciated Thanks Marcel [Edited by - GoodFun on May 13, 2008 6:21:48 PM]
Advertisement
Bump
Any of the SlimDX developers on that can nudge me in the right direction on this???

Thanks in advance
Marcel
Setting effect state is done the same way as the native interface. See here for example. Simply GetEffectVariableBy[Name|Semantic], call AsWhatever() on the resulting EffectVariable to get a WhateverEffectVariable, and then call the appropriate Set() method on that WhateverEffectVariable. Some of the sets and/or gets are missing, but mainly only the uncommon ones. File a bug report if you do happen to find a setter or getter you're missing.
Thanks, I'll give that a try...
jpetrie's suggestion worked... this is the code I've used...

public void SetShaderData(D3D10.Effect shader, D3D10.Device device, Vector4 offset, Vector4 scale)
{
D3D10.EffectVectorVariable texOffset = shader.GetVariableByName("texOffset").AsVector();
D3D10.EffectVectorVariable texScale = shader.GetVariableByName("texScale").AsVector();
D3D10.EffectResourceVariable shaderTexture = shader.GetVariableByName("dataTexture").AsResource();

texOffset.Set(offset);
texScale.Set(scale);

D3D10.ShaderResourceView textureView = new D3D10.ShaderResourceView(device, _texture);
shaderTexture.SetResource(textureView);
}

I've also added overloads to set int and float arrays, I'll post a bug report with the code I've added.

Thanks for your help Josh

This topic is closed to new replies.

Advertisement