   ID3DXEffect::SetValue
  Hi,I'm trying to pass a texture (IDirect3DTexture9) to my shader using SetValue.I have this piece of code:void Shader::setValue(const tstring& sParameterName, IDirect3DTexture9* texturePtr){ HR(m_effectPtr->SetValue(m_mapParameters[sParameterName], texturePtr, sizeof(IDirect3DTexture9*)));}where 'm_mapParameters[sParameterName]' results in the handle to the shaderparameter.But doing this causes a non-directx runtime error, so it appears I'm messing with the memory. I'm having doubts about the sizeof though; should I take the size of the IDirect3DTexture9 pointer or IDirect3DTexture9 as a whole? But I even tried both, and didn't succeed.But then I tried this one:HR(m_effectPtr->SetTexture(m_mapParameters[sParameterName], texturePtr));and it worked.So I wonder if I'm doing something wrong or is this SetValue method not for setting textures and should I use SetTexture?Cheers   
  I always use SetTexture for textures and SetValue for floats.SetMatrix for matrices and SetVector for vectors [smile]   ;  Hmm yeah, but SetVector takes a D3DXVECTOR4 and if I just want to pass a D3DXVECTOR2 to my shader, I have to make a temporary vector etc. So that's why I started using this SetValue method so I can pass anything to the shader.Cheers   ;  You can also use SetFloatArray, and cast the D3DXVECTOR2 to a (float*).   ;  Hi,Solution to your problem is quite simple. The 2nd parameter of ID3DXBaseEffect::SetValue() function is a LPCVOID type variable. So, if you want to pass your texture(s) via SetValue() function, you need to use & (address) operator:void Shader::setValue(const tstring& sParameterName, IDirect3DTexture9* texturePtr){HR(m_effectPtr->SetValue(m_mapParameters[sParameterName], &texturePtr, sizeof(IDirect3DTexture9*)));}Look, I made just a little modification on your original function. It's the & operator.This will work for all types of your variables/values ;)[Edited by - programci_84 on May 8, 2009 3:21:54 PM];  what is the type of m_effect?look up the method and look at the arguments carefully.I really doubt any call is asking you for the sizeof a pointer.We all already know (hopefully) the sizeof a pointer.They are usually asking you for a pointer and the size of the object it points to, so they know how much memory from that address they can read.I can only guess:ID3DXBaseEffect::SetValueSet the value of an arbitrary parameter or annotation, including simple types, structs, arrays, strings, shaders and textures. HRESULT SetValue(  D3DXHANDLE hParameter,  LPCVOID pData,  UINT Bytes);ParametershParameter [in] Unique identifier. See Handles (Direct3D 9). pData [in] Pointer to a buffer containing data. Bytes [in] [in] Number of bytes in the buffer. Pass in D3DX_DEFAULT if you know your buffer is large enough to contain the entire parameter, and you want to skip size validation.Bunches of calls are in this format. Pass a pointer to something, and pass how many bytes that something is.