   Vertex Declaration...
  Im getting into shaders so im creating a vertex declaration that i can pass into my shaders. Heres what im doing:#include <d3d9.h>#include <d3dx9.h>#include "CManager.h"#include "Globals.h"#include "Structs.h"bool Manager::Init( void ){if( !Globals::GameCamera.Init() )return false;if( !BSPLoader.Load(L"maps/tutorial.bsp") )return false;AmbientLight.SetDirectionalLight( D3DXVECTOR3(0, -1, 0) );AmbientLight.SetAmbient( 0.5f, 0.5f, 0.5f );AmbientLight.SetLightIndex( 0 );AmbientLight.Apply();VertexShader.Load( L"shaders/test.fx" );RocketLauncher.Init();/*this is what my struct looks likestruct Vertex{float x, y, z;D3DXVECTOR3 Normal;DWORD color;float u, v;float lu, lv;};*/D3DVERTEXELEMENT9 Elements[] = {{0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},{0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0},{0, 24, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0},{0, 28, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},{0, 36, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},D3DDECL_END() };Globals::D3DDevice->CreateVertexDeclaration( Elements, &Dec );Globals::D3DDevice->SetVertexDeclaration( Dec );return true;}void Manager::Render( void ){Globals::CameraFrustum.CalculateFrustum();Globals::GameCamera.Update();unsigned int Passes = 0;VertexShader.GetEffect()->SetMatrix( "WorldViewProj", &(Globals::GameCamera.GetViewMatrix() * Globals::GameCamera.GetProjectionMatrix()) );VertexShader.GetEffect()->Begin( &Passes, NULL );for( unsigned int x = 0 ; x < Passes; x++ ){VertexShader.GetEffect()->BeginPass( x );BSPLoader.Render();VertexShader.GetEffect()->EndPass();}VertexShader.GetEffect()->End();RocketLauncher.Render();}Manager::~Manager( void ){Dec->Release();}Im not sure were the problem is, if im forgetting something, or my vertex declaration is wrong.Thanks   
Quote:Original post by fitfool...Im not sure were the problem is...Me neither, you might want to try telling us what's going wrong in the first place [wink]Edit: ok, I'll give it a shot. At first glance, your Color component won't work. In the struct it's a 32bit DWORD, while you're defining it as a 4 x 32bit float4 in the declaration. I've never used vertex colors myself, so I can't tell you what it should be, but there's bound to be a fitting type in D3DDECLTYPE... At second glance, you're defining two TexCoord elements with the same index, which is probably invalid.I hope you don't mind me saying it wouldn't hurt to review the documentation on vertex declarations and find a few samples using less complex vertices to get a feel for how this works.[Edited by - remigius on August 27, 2007 3:56:34 AM];  The debug runtimes tend to be very good at pointing these sorts of issues out.hthJack   