   Send an array EffectVariable-SetRawValue (D3D 10)[Solved]]
  Hello.I've got a struct for using lights in a shader:struct Light{Light( void ){}Light(bool clear){  if( clear )  ZeroMemory(this, sizeof(Light));}D3DXVECTOR3position;float  pad1; // not usedD3DXVECTOR3 direction;Real32 pad2; // not usedD3DXCOLOR ambientColor;D3DXCOLOR diffuseColor;D3DXCOLOR specularColor;D3DXVECTOR3attenuation;float spotPower;float  range;};And I can send one instance this struct to my shader like this:LightVar->SetRawValue(&light, 0, sizeof(Light));but I can't figure out how to send an array of lightsex: Light** pLights = new Light*[ 2 ];...do stuff with the lights now send the it to the shader,//this is wrongLightVar->SetRawValue(*pLights , 0, sizeof(Light)* 2);How do I send them correctly??//HermanssoN[Edited by - HermanssoN on May 10, 2009 3:23:41 PM]
  Is it eaven possible to set an array with the SetRawValue?Iv'e managed to set element one of two inside my shader:C++:Light L[2];L[0].diffuseColor = D3DXCOLOR_RED;L[1].diffuseColor = D3DXCOLOR_BLUE;LightVar->SetRawValue( (void*)&L, 0, sizeof(Light)*2);HLSL:cbuffer cbPerFrame{Light g_pointLights[2];float4 g_ambientLight;float3 g_eyePos; };float4 PS_Ambient(VS_OUT In) : SV_Target{  //Works fine , a red cube    return g_pointLights[0].diffuse;   //Don't work, nothing is rendered   //return g_pointLights[1].diffuse;}   ;  Here is how I do 8 light structsif( FAILED(D3DX10CreateEffectPoolFromFile(effectPoolPath.c_str(),NULL,NULL,"fx_4_0",D3D10_SHADER_ENABLE_BACKWARDS_COMPATIBILITY,0,&m_device,NULL,&m_effectPool,NULL,NULL)) )   { exception.m_msg = std::string("Could not create effect pool from file: ") + effectPoolPath; throw exception;   }   // Get the shared matrix variables   ID3D10Effect * pool = m_effectPool->AsEffect();   m_effectVariable_view = pool->GetVariableByName("view")->AsMatrix();   m_effectVariable_projection = pool->GetVariableByName("projection")->AsMatrix();   if( !m_effectVariable_view->IsValid() ||   !m_effectVariable_projection->IsValid() )   { exception.m_msg = "Could not retreive matrix variables from the effect pool"; throw exception;   }   // Set the shared matrix variables   D3DXMATRIX identity;   D3DXMatrixIdentity(&identity);    if( FAILED(m_effectVariable_view->SetMatrix((float *)&identity)) )   { exception.m_msg = "Could not set view matrix default value"; throw exception;   }   if( FAILED(m_effectVariable_projection->SetMatrix((float *)&identity)) )   { exception.m_msg = "Could not set projection matrix default value"; throw exception;   } // Get the ambient light variables   ID3D10EffectVariable * ambientLight = pool->GetVariableByName("ambientLight"); if( !ambientLight->IsValid() )   { exception.m_msg = "Could not retreive ambient light structure from the effect pool"; throw exception;   }   m_effectVariable_ambientLight.m_effectVariable_intensity = ambientLight->GetMemberByName("intensity")->AsScalar();   m_effectVariable_ambientLight.m_effectVariable_color= ambientLight->GetMemberByName("color")->AsVector();   if( !m_effectVariable_ambientLight.m_effectVariable_intensity->IsValid() ||   !m_effectVariable_ambientLight.m_effectVariable_color->IsValid() )   { exception.m_msg = "Could not retreive ambient light variables from the effect pool"; throw exception;   }   // Set the ambient light variables   D3DXCOLOR color(1.0f, 1.0f, 1.0f, 1.0f ); if( FAILED(m_effectVariable_ambientLight.m_effectVariable_intensity->SetFloat(1.0f)) )   { exception.m_msg = "Could not set ambient light intensity default value"; throw exception;   }   if( FAILED(m_effectVariable_ambientLight.m_effectVariable_color->SetFloatVector((float *)&color)) )   { exception.m_msg = "Could not set ambient light color default value"; throw exception;   }   // Get the directional light variables   ID3D10EffectVariable * directionalLights = pool->GetVariableByName("directionalLights");   if( !directionalLights->IsValid() )   { exception.m_msg = "Could not retreive directional lights array from the effect pool"; throw exception;   }   ID3D10EffectType * type = directionalLights->GetType(); D3D10_EFFECT_TYPE_DESC typeDesc;   type->GetDesc(&typeDesc);   for(unsigned i = 0; i < typeDesc.Elements; ++i)   { ID3D10EffectVariable * directionalLight = directionalLights->GetElement(i); m_effectVariable_directionalLights.m_effectVariable_enabled   = directionalLight->GetMemberByName("enabled")->AsScalar(); m_effectVariable_directionalLights.m_effectVariable_direction = directionalLight->GetMemberByName("direction")->AsVector(); m_effectVariable_directionalLights.m_effectVariable_color= directionalLight->GetMemberByName("color")->AsVector(); if( !m_effectVariable_directionalLights.m_effectVariable_enabled->IsValid()   || !m_effectVariable_directionalLights.m_effectVariable_direction->IsValid() ||!m_effectVariable_directionalLights.m_effectVariable_color->IsValid() ) {    exception.m_msg = "Could not retreive directional light variables from the effect pool";    throw exception; } // Set the directional light variables if( FAILED(m_effectVariable_directionalLights.m_effectVariable_enabled->SetBool(false)) ) {    exception.m_msg = "Could not set directional light enabled default value";throw exception; }   }BaseException exception("Not Set",  "void EffectManager::SetDirectionalLight(DirectionalLight * directionalLight, unsigned index)","EffectManager.cpp");   // Check for a valid light   if( !directionalLight )   { exception.m_msg = "Directional Light is NULL"; throw exception;   }   // Check for a valid index   if( index >= sizeof(m_effectVariable_directionalLights) / sizeof(EffectVariable_DirectionalLight) )   { exception.m_msg = "Invalid"; throw exception;   }   // Set the directional light m_effectVariable_directionalLights[index].m_effectVariable_enabled->SetBool(directionalLight->m_enabled);   m_effectVariable_directionalLights[index].m_effectVariable_direction->SetFloatVector((float *)&(directionalLight->m_direction));   m_effectVariable_directionalLights[index].m_effectVariable_color->SetFloatVector((float *)&(directionalLight->m_color));   /**   *   **/   typedef struct EffectVariable_DirectionalLight   { EffectVariable_DirectionalLight()    :    m_effectVariable_enabled(0),    m_effectVariable_direction(0),    m_effectVariable_color(0) {} ID3D10EffectScalarVariable * m_effectVariable_enabled; ID3D10EffectVectorVariable * m_effectVariable_direction; ID3D10EffectVectorVariable * m_effectVariable_color;   }; EffectVariable_DirectionalLight m_effectVariable_directionalLights[8];shared cbuffer Lights{   struct AmbientLight   { float  intensity; float4 color;   }; struct DirectionalLight   { bool   enabled; float3 direction; float4 color;   }; AmbientLightambientLight;   DirectionalLight directionalLights[8];};...doesn't it bug you how some forums use "["code"]" and some use "["source"]" and some use a button? Can't we standardize forum tags? :)   ;  Aha!! so:  awsome code Well thank you for both the reply and the hin't for code posting :)How ever, I checked out the direct3D SK sample about Effect Pools, I found it kind of comlicated. I used the D3DX10CreateEffectFromFileto create my shader, is :D3DX10CreateEffectPoolFromFilea replacement for D3DX10CreateEffectFromFile??When using D3DX10CreateEffectPoolFromFile I  get a compile error, it fails to create the ID3D10EffectPool*.The only thin that's done with the ID3D10EffectPool* is got get a pointer to the ID3D10Effect*, wich I already got when using  D3DX10CreateEffectFromFile.//HermanssoN[Edited by - HermanssoN on May 10, 2009 6:06:17 AM];  Sry, forgot to meantion it works when I use the regular D3DX10CreateEffectFromFile, so I'm very gratefulf or your help :)The question about the D3DX10CreateEffectPoolFromFile is just beacuse I'm curious.   