   [C++/DX] Manually creating a textured mesh (D3DXCreateMeshFVF)
  There is probably something obviously wrong with this code but i can not for the life of me spot what. Nothing crashes/errors and nothing renders. It is a simple inline function to create a box capable of having textures applied (please ignore the fact it is far from optimal, i just want the damn thing to work and understand why it is not at the moment).Here is the code:struct TEXTURED_VERTEX{    float x, y, z;    DWORD color;float u, v;};inline ID3DXMesh *CreateTexturedBoxMesh(float boxWidth, float boxHeight, float boxDepth, IDirect3DDevice9 *device){//(1) Validate callif(!device)return NULL;//(2) Get half dimensionsfloat width = boxWidth/2;float height = boxHeight/2;float depth = boxDepth/2;//(3) Calculate the u and v value ratios based on height being 1.0ffloat heightUVRatio = 1.0f;float depthUVRatio = depth/height;float widthUVRatio = width/height;//(4) Create the indices for the textured box meshWORD *indices = new WORD[36];for(WORD i = 0; i < 36; i++){indices = i;}//(5) Create the vertices for the textured box meshTEXTURED_VERTEX vertices[] = {//Front{-width, height,-depth, D3DCOLOR_XRGB(255, 255, 255), 0.0f, 0.0f},{ width, height,-depth, D3DCOLOR_XRGB(255, 255, 255), widthUVRatio, 0.0f},{ width,-height,-depth, D3DCOLOR_XRGB(255, 255, 255), widthUVRatio, heightUVRatio},{-width, height,-depth, D3DCOLOR_XRGB(255, 255, 255), widthUVRatio, 0.0f},{ width,-height,-depth, D3DCOLOR_XRGB(255, 255, 255), widthUVRatio, heightUVRatio},{-width,-height,-depth, D3DCOLOR_XRGB(255, 255, 255), widthUVRatio, heightUVRatio},//Right{ width, height,-depth, D3DCOLOR_XRGB(255, 255, 255), 0.0f, 0.0f},{ width, height, depth, D3DCOLOR_XRGB(255, 255, 255), depthUVRatio, 0.0f},{ width,-height, depth, D3DCOLOR_XRGB(255, 255, 255), depthUVRatio, heightUVRatio},{ width, height,-depth, D3DCOLOR_XRGB(255, 255, 255), 0.0f, 0.0f},{ width,-height, depth, D3DCOLOR_XRGB(255, 255, 255), depthUVRatio, heightUVRatio},{ width,-height,-depth, D3DCOLOR_XRGB(255, 255, 255), 0.0f, heightUVRatio},//Back{ width, height, depth, D3DCOLOR_XRGB(255, 255, 255), 0.0f, 0.0f},{-width, height, depth, D3DCOLOR_XRGB(255, 255, 255), widthUVRatio, 0.0f},{-width,-height, depth, D3DCOLOR_XRGB(255, 255, 255), widthUVRatio, heightUVRatio},{ width, height, depth, D3DCOLOR_XRGB(255, 255, 255), 0.0f, 0.0f},{-width,-height, depth, D3DCOLOR_XRGB(255, 255, 255), widthUVRatio, heightUVRatio},{ width,-height, depth, D3DCOLOR_XRGB(255, 255, 255), 0.0f, heightUVRatio},//Left{-width, height, depth, D3DCOLOR_XRGB(255, 255, 255), 0.0f, 0.0f},{-width, height,-depth, D3DCOLOR_XRGB(255, 255, 255), depthUVRatio, 0.0f},{-width,-height,-depth, D3DCOLOR_XRGB(255, 255, 255), depthUVRatio, heightUVRatio},{-width, height, depth, D3DCOLOR_XRGB(255, 255, 255), 0.0f, 0.0f},{-width,-height,-depth, D3DCOLOR_XRGB(255, 255, 255), depthUVRatio, heightUVRatio},{-width,-height, depth, D3DCOLOR_XRGB(255, 255, 255), 0.0f, heightUVRatio},//Top{-width, height, depth, D3DCOLOR_XRGB(255, 255, 255), 0.0f, 0.0f},{ width, height, depth, D3DCOLOR_XRGB(255, 255, 255), widthUVRatio, 0.0f},{ width, height,-depth, D3DCOLOR_XRGB(255, 255, 255), widthUVRatio, depthUVRatio},{-width, height, depth, D3DCOLOR_XRGB(255, 255, 255), 0.0f, 0.0f},{ width, height,-depth, D3DCOLOR_XRGB(255, 255, 255), widthUVRatio, depthUVRatio},{-width, height,-depth, D3DCOLOR_XRGB(255, 255, 255), 0.0f, depthUVRatio},//Bottom{-width,-height,-depth, D3DCOLOR_XRGB(255, 255, 255), 0.0f, 0.0f},{ width,-height,-depth, D3DCOLOR_XRGB(255, 255, 255), widthUVRatio, 0.0f},{ width,-height, depth, D3DCOLOR_XRGB(255, 255, 255), widthUVRatio, depthUVRatio},{-width,-height,-depth, D3DCOLOR_XRGB(255, 255, 255), 0.0f, 0.0f},{ width,-height, depth, D3DCOLOR_XRGB(255, 255, 255), widthUVRatio, depthUVRatio},{-width,-height, depth, D3DCOLOR_XRGB(255, 255, 255), 0.0f, depthUVRatio}};//(7) Create a mesh for the textured boxID3DXMesh *texturedBox = NULL;if(FAILED(D3DXCreateMeshFVF(12, 36, D3DPOOL_DEFAULT, D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1, device, &texturedBox))){return NULL;}//(8) Set the indicesvoid *ptrToIB = NULL;if(FAILED(texturedBox->LockIndexBuffer(0,&ptrToIB))){SAFE_RELEASE(texturedBox);return NULL;}memcpy(ptrToIB,&indices,(36 * sizeof(WORD)));if(FAILED(texturedBox->UnlockIndexBuffer())){SAFE_RELEASE(texturedBox);return NULL;}//(9) Set the verticesvoid *ptrToVB = NULL;if(FAILED(texturedBox->LockVertexBuffer(0,&ptrToVB))){SAFE_RELEASE(texturedBox);return NULL;}memcpy(ptrToVB,&vertices,(sizeof(TEXTURED_VERTEX)*36));if(FAILED(texturedBox->UnlockVertexBuffer())){SAFE_RELEASE(texturedBox);return NULL;}return texturedBox;}Thanks for your time in advance,Alex.   
  Attribute buffer and attribute table might be your problemLook up ID3DXMesh::SetAttributeTable() and ID3DXMesh::SetAttributeBuffer() - they're pretty straight forward to use.I think theres a default one set up though, so it may not be the problem.Also, make sure you check with D3DRS_CULLMODE = D3DCULL_NONE if nothing renders - its all too easy to muddle up your winding orders and have it cull the wrong triangles [smile]hthJack   ;  Hey Jack,Yeah i tried that already (as you said i did not think it was the problem as the default is a single attribute covering the entire mesh). The latter is set as well so it's not that either! :(Alex.   ;  Any other ideas? This is REALLY annoying me!Thanks,Alex.   