   Problem with vertex buffer
  Hello,i have some troubles with vertex buffer and i don't know why, i will be happy, if someone help me :)so, i created own vertex struct and vertex declaration.const D3DVERTEXELEMENT9 FBXMeshDecl[] ={   { 0, 0,  D3DDECLTYPE_FLOAT4,   D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },   { 0, 16, D3DDECLTYPE_FLOAT4,   D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL,   0 },   { 0, 32, D3DDECLTYPE_FLOAT2,   D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },   { 0, 40, D3DDECLTYPE_FLOAT4,   D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR,    0 },   { 0, 56, D3DDECLTYPE_FLOAT4,   D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT,  0 },   { 0, 72, D3DDECLTYPE_FLOAT4,   D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BINORMAL, 0 },   D3DDECL_END()};struct FBXMeshStruct{float x,y,z,w;    float nx,ny,nz,nw;float u,v;DWORD color;float tx,ty,tz,tw;float bx,by,bz,bw;};that's it :) I am filling struct with data there:   FBXMeshStruct* VertexData = new FBXMeshStruct[36];for( int i = 0; i < 36; i++){VertexData.x = verticesdata.x;VertexData.y = verticesdata.y;VertexData.z = verticesdata.z;VertexData.w = verticesdata.w;VertexData.nx = normaldata.x;VertexData.ny = normaldata.y;VertexData.nz = normaldata.z;VertexData.nw = normaldata.w;VertexData.bx = binormaldata.x;VertexData.by = binormaldata.y;VertexData.bz = binormaldata.z;VertexData.bw = binormaldata.w;VertexData.tx = tangentdata.x;VertexData.ty = tangentdata.y;VertexData.tz = tangentdata.z;VertexData.tw = tangentdata.w;VertexData.u = 0.0f;VertexData.v = 0.0f;VertexData.color = D3DCOLOR_ARGB((unsigned char)colordata.w*255,(unsigned char)colordata.x*255,(unsigned char)colordata.y*255,(unsigned char)colordata.z*255);}yes, It's a cube with 36 vertices for test, I am not using static array, because I am loading data from FBX file.GraphicsMgr::GetDevice()->CreateVertexDeclaration( FBXMeshDecl, &object->MeshDecl );GraphicsMgr::GetDevice()->SetVertexDeclaration(object->MeshDecl);GraphicsMgr::GetDevice()->CreateVertexBuffer(3*sizeof(FBXMeshStruct),0,0, D3DPOOL_DEFAULT,&object->VertexBuffer,0);void* pVert = 0;    object->VertexBuffer->Lock(0, sizeof(FBXMeshStruct)*36, (void**) &pVert,0);memcpy( pVert, VertexData, sizeof(FBXMeshStruct)*36);object->VertexBuffer->Unlock();and this is last thing, when i run it in nondebug  .. it hangs on "memcpy( pVert, VertexData, sizeof(FBXMeshStruct)*36);" .. if i run it in debug, nothing happend in this part, so something is wrong there.thank yo uvery much for help :)
Quote:GraphicsMgr::GetDevice()->CreateVertexBuffer(3*sizeof(FBXMeshStruct),0,0, D3DPOOL_DEFAULT,&object->VertexBuffer,0);You're trying to stuff 36 vertices into a buffer with only room for 3.;  Really ? damn !i have thought, 3*sizeof(FBXMeshStruct) is size of one polygon :Dthanks, going to try it :)   ;  I have another problem related to my code here.How does DX knows, what data are correct ???for example, how DX knows, that these variables float nx,ny,nz,nw; are NORMALS ?Looks like, my applications read Tangents or Binormals like normals :)thanks   ;Quote:for example, how DX knows, that these variables float nx,ny,nz,nw; are NORMALS ?You just told them with the vertex declaration, that's what it's for:...{ 0, 16, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },...Here, D3DDECLUSAGE_NORMAL is the so-called semantic, the "meaning".By the way: Make sure the vertex declaration and your struct match. For instance your color is definitively wrong. Your struct declares it as a DWORD but the vertex declaration has a FLOAT4 type. Either use D3DDECLTYPE_D3DCOLOR type - and of course adjust the offsets - or declare four floats in your struct, i.e. float r,g,b,a.Hope that helps.   