   Vertex buffer not rendering?
  Hi all, i've been working on a little project to teach myself the DirectX API and game programming techniques etc. But i've ran into something that i can't work out...#define CUSTOMFVF (D3DFVF_XYZRHW  | D3DFVF_DIFFUSE)struct CUSTOMVERTEX{FLOAT x, y, z, rhw;DWORD color;};void CDXRender::InitVBuffer(){d3ddev->CreateVertexBuffer(3*sizeof(CUSTOMVERTEX),0,CUSTOMFVF, D3DPOOL_MANAGED,&v_buffer,NULL);}void CDXRender::LoadVertices(CUSTOMVERTEX vertices[]){VOID* pVoid;v_buffer->Lock(0, 0, (void**)&pVoid, 0);memcpy(pVoid, vertices, sizeof(vertices));v_buffer->Unlock();}void CDXRender::RenderVertices(){d3ddev->SetFVF(CUSTOMFVF);d3ddev->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX));d3ddev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);}The "v_buffer" variable is stored in the class as protected -"LPDIRECT3DVERTEXBUFFER9  v_buffer;"and in my WinMain function...CDXRender* Renderer = new CDXRender;Renderer->Initialize(hWnd, 800, 600, TRUE);Renderer->InitVBuffer();CUSTOMVERTEX vert[] ={   { 400.0f, 62.5f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 0, 255), },   { 650.0f, 500.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(0, 255, 0), },   { 150.0f, 500.0f, 0.5f, 1.0f, D3DCOLOR_XRGB(255, 0, 0), },    };Renderer->LoadVertices(vert);... Main Loop here    Renderer->Start(); // Just clears the screen and begins the scene    Renderer->RenderVertices();    Renderer->Stop(); // End's scene and presentsAll this code compiles with no errors or warnings, it starts up and is just blank, the background colour gets set by the d3ddev->Clear() function but the vertices don't get rendered? Any help? Thanks in advance (:   
  Just a quick look: it appears your vertices are in CCW order, not CW order. Also, be sure your eyepoint and viewport are setup such that you can see the triangle.Just in case, see what the Debug Runtime tells you.   ;  Turns out that if I put    CUSTOMVERTEX vertices[] ={   { 3.0f, -3.0f, 0.0f, D3DCOLOR_XRGB(0, 0, 255), },   { 0.0f, 3.0f, 0.0f, D3DCOLOR_XRGB(0, 255, 0), },   { -3.0f, -3.0f, 0.0f, D3DCOLOR_XRGB(255, 0, 0), },    };in with my "CDXRender::LoadVertices()" function the vertices then get drawn... Must be how I was copying the vertices over :S   ;  as noted, your vertices were improperly wound, use SetRenderState(D3DRS_CULLMODE, D3DCULL_cw) OR specify your vertices in reverse order. ALSO, if until your sure which way they are wound, D3DCULL_NONE will ensure your verts show up no matter what.   ;  I have been using D3DCULL_NONE the whole time... and i have copied the code into a new project and took the whole thing out of a class and it works and it also works when i declare the vertices in actual class itself, the problem is that the array of vertices wasn't getting copied into the class variable for it to put into the buffer, i'm still having problems drawing something with custom set verticies... But i've created a void "DrawRect(FLOAT x, FLOAT y, int width, int height, DWORD Color);" function in my class and this works perfectly fine!   ;Quote:void CDXRender::LoadVertices(CUSTOMVERTEX vertices[])//...memcpy(pVoid, vertices, sizeof(vertices));I'm guessing that may be the problem. In that context, vertices is a pointer and the size of a pointer is 4 bytes. You're only copying 4 bytes instead of 3 vertex structures.There's no way that LoadVertices(..) can tell how big the array is. You'll have to find a way to tell it. For testing purposes, you may want to try:memcpy(pVoid, vertices, 3*sizeof(CUSTOMVERTEX));and see if that works.;  Aha, thanks buckeye! I never would of thought that, it now works and insted of loading an array of CUSTOMVERTEX's i'm adding one at a time and this works perfectly, thanks again!   