   [DX9] A problem with vertex buffer..
  Hello, i'm creating a simple class to draw primitives on my scene. I'm following the first simple tutorial for DirectX. All i need is to fill the vertices ad draw my primitive. I've no problem when i use the example on DX9 SDK, but when i try to use my own class can't draw the primitive. This is my code:This is my VertexBuffer Creation:HRESULT RenderSystem::InitVertexBuffer(){if( FAILED( m_DxRenderingDevice->CreateVertexBuffer(3*sizeof(CVertex), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED,&m_DxVertexBuffer, NULL))){return E_FAIL;}m_PrimitiveFactory.Init(m_DxVertexBuffer);return S_OK;}Now i Fill my Vertices in this way:void CPrimitiveTriangle::Create(std::vector<CVertex*>& i_triangle_list){/* E' qui che si fillano nel vertex buffer? */m_v0 = new CVertex(i_triangle_list.at(0)->m_x, i_triangle_list.at(0)->m_y, i_triangle_list.at(0)->m_z);m_v1 = new CVertex(i_triangle_list.at(1)->m_x, i_triangle_list.at(1)->m_y, i_triangle_list.at(1)->m_z);m_v2 = new CVertex(i_triangle_list.at(2)->m_x, i_triangle_list.at(2)->m_y, i_triangle_list.at(2)->m_z);VOID* pVertices;if( FAILED( m_VertexBuffer->Lock( 0, sizeof(this), (void**)&pVertices, 0 ) ) ){pVertices = NULL;}memcpy(pVertices, this, sizeof(this) );m_VertexBuffer->Unlock();}And Finally i Draw my triangle:void RenderSystem::StartRender(){m_DxRenderingDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 255), 1.0f, 0 );if( SUCCEEDED(m_DxRenderingDevice->BeginScene())){m_DxRenderingDevice->SetStreamSource(0, m_DxVertexBuffer, 0, 3*sizeof(CVertex));m_DxRenderingDevice->SetFVF(D3DFVF_CUSTOMVERTEX);m_DxRenderingDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);m_DxRenderingDevice->EndScene();}m_DxRenderingDevice->Present(NULL, NULL, NULL, NULL);}When i execute my program i can't see any triangle. Where i wrong? I'm stuck! :D Thank for any suggests and sorry for my bad english!   
  Have you stepped through the drawing with PIX to see what geometry is actually get through?   ;  No, how can i do that?   ;  Looks like m_v0, m_v1, and m_v2 are pointers, as new would return a pointer.  Change these to be vertices, not pointers to them, and get rid of the 'new's when you copy.When copying into the VB, don't copy 'this'.  Copy from &m_v0 (address of first vertex), and sizeof(CVertex)*3.  'this' may have all sorts of extra data inside it that isn't related to the vertex data.When your lock fails, you'll crash, as you immediately memcpy into address 0... you might want to return an error value.;Quote:Original post by Tano_ITAvoid CPrimitiveTriangle::Create(std::vector<CVertex*>& i_triangle_list){/* E' qui che si fillano nel vertex buffer? */m_v0 = new CVertex(i_triangle_list.at(0)->m_x, i_triangle_list.at(0)->m_y, i_triangle_list.at(0)->m_z);m_v1 = new CVertex(i_triangle_list.at(1)->m_x, i_triangle_list.at(1)->m_y, i_triangle_list.at(1)->m_z);m_v2 = new CVertex(i_triangle_list.at(2)->m_x, i_triangle_list.at(2)->m_y, i_triangle_list.at(2)->m_z);VOID* pVertices;if( FAILED( m_VertexBuffer->Lock( 0, sizeof(this), (void**)&pVertices, 0 ) ) ){pVertices = NULL;}memcpy(pVertices, this, sizeof(this) );m_VertexBuffer->Unlock();}See "memcpy(pVertices, this, sizeof(this) );" you obtained a pointer to buffer correctly (but you should set flags in lock function) but you copy from "this", thats a pointer to CPrimitiveTriangle instance and you perhaps expect members m_v0 m_v1 m_v2 to have data, but they are just 32bit pointers to memory you allocated in three steps, so the memory does not even neighbour.So you are just copying values of 32bit pointers to your buffer.  ;  it looks like m_v0,m_v1,m_v2 are pointer of vector.maybe the codes that you have posted is so little that other can not understand better.   