   DrawPrimitive fails.
  for some reason, DrawPrimitive fails when i try to draw a box using it it says Direct3D9: (ERROR) :Stream 0 does not have required number of verticesFirst-chance exception at 0x75ddf328 in Pong V1.0.exe: Microsoft C++ exception: long at memory location 0x002ef6a0..Direct3D9: (ERROR) :DrawPrimitive failed.here is my code for creating and drawing the box.int TwoDBoxes::Create2DBox(IDirect3DDevice9 *dev, float X1, float Y1,float X2, float Y2, D3DCOLOR ColorA, D3DCOLOR ColorB, D3DCOLOR ColorC, D3DCOLOR ColorD){this->pDevice = dev;HRESULT HR = pDevice->CreateVertexBuffer(4*sizeof(VertexPColor),0,D3DFVF_HEALTHBOX,D3DPOOL_DEFAULT,&this->vertexBuffer,NULL);if(FAILED(HR)){MessageBoxA(NULL,"Could not create VertexBuffer 9",NULL,MB_OK);return 0;}vertexBuffer->Lock(0,0,(void**)&this->vColor,0);vColor[0] = VertexPColor(X1,Y1,1.0,ColorA);vColor[1] = VertexPColor(X2,Y1,1.0,ColorB);vColor[2] = VertexPColor(X1,Y2,1.0,ColorC);vColor[3] = VertexPColor(X2,Y2,1.0,ColorD);vertexBuffer->Unlock();return 1;}int TwoDBoxes::Draw2DBox(IDirect3DDevice9 *dev){dev->SetStreamSource(0,vertexBuffer,0,sizeof(VertexPColor));dev->SetFVF(D3DFVF_HEALTHBOX);dev->DrawPrimitive(D3DPT_TRIANGLELIST,0,2);return 1;}any idea why it doesn't work for me? i'm doing it right, as far as i know...   
  Hi,You used, dev->DrawPrimitive(D3DPT_TRIANGLELIST,0,2); but in initialization you given only 4 vertexes. With:vColor[0] = VertexPColor(X1,Y1,1.0,ColorA);vColor[1] = VertexPColor(X2,Y1,1.0,ColorB);vColor[2] = VertexPColor(X1,Y2,1.0,ColorC);vColor[3] = VertexPColor(X2,Y2,1.0,ColorD);So triangle list means you will give each vertex of a triangle, which means you will need to give 6 vertex for each corner of a 2 triangles. (3 for first triangle 3 for second one)if you use trianglestrip instead of triangle list you can continously draw triangles. It's hard to describe with words but these images may help.Triangle list:In this picture you need to give each 3 vertexes for every triangle.Triangle Strip:In this one you can create 4 triangles with only 6 vertices... Which is good but it needs to be continous.   ;  I fixed the stream source error but it sees that DrawPrimitive still fails. i changed the D3DPT_TRIANGLELIST to D3DPT_TRIANGLESRTRIP and it still fails. i don't get it, usually when i made a box with 4 points it worked cause that's what i'm trying to do, make a box to use as a health bar.   ;  Hi,Burak is right; if you want to render a rectangle /w your vertices, you need to render'em as a triangle strip. But you're still saying that your draw function fails. What does it mean? Does DrawPrimitive() function return an error? If not, can't you see any shapes in spite of DrawPrimitive() succeeds?I recommend you not to use vertex buffer for that. You can use your custom buffer.1 - Fill your vertex array:VertexPColor vColor[4];vColor[0] = VertexPColor(X1,Y1,1.0,ColorA);vColor[1] = VertexPColor(X2,Y1,1.0,ColorB);vColor[2] = VertexPColor(X1,Y2,1.0,ColorC);vColor[3] = VertexPColor(X2,Y2,1.0,ColorD);2 - Set your fvf like that: D3DFVF_XYZRHW | D3DFVF_DIFFUSE3 - And draw with DrawPrimitiveUP() function:YourD3DDevice->DrawPrimitiveUP (D3DPT_TRIANGLESTRIP, 2, vColor, sizeof (VertexPColor));D3DFVF_XYZRHW is important for rendering directly in screen space (RHW means reciprocal homogeneous W). I'm using these for rendering full-screen quads and it works nice for me.Hope this helps.   ;  Ok, for some reason, the quad doesn't show up at all. I did what you said about using the DrawPrimitiveUP function and it doesn't give any Direct3D Error but the quad wont draw. I don't get it, i've already used the vertex buffer for my screen quad and that draws good. i can't seem to get a simple quad to render to the screen. so i don't get it why it's not drawing to the screen....   ;Quote:Original post by EnerjakOk, for some reason, the quad doesn't show up at all. I did what you said about using the DrawPrimitiveUP function and it doesn't give any Direct3D Error but the quad wont draw. I don't get it, i've already used the vertex buffer for my screen quad and that draws good. i can't seem to get a simple quad to render to the screen. so i don't get it why it's not drawing to the screen....Are your vertices in the correct order? If you disable culling does it show up? You can do that with the line:pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);   ;  my vertices are in the right order, i used the viewport as a guide. But it still doesn't show. I think it draws but since the back buffer is blue the quad might be taking the color of the back buffer. I don't know what to do to make it to work right. maybe not use the viewport as a guide, but making it in screen space is what i need to do to make a screen quad. I just edited my screen qwuad to be able to make it any size i want, so i guess i'm ok, since DrawPrimitive doesn't fial when i use it in my renderer library i made awhile ago.   ;Quote:Original post by Enerjakmy vertices are in the right order, i used the viewport as a guide. But it still doesn't show. I think it draws but since the back buffer is blue the quad might be taking the color of the back buffer. I don't know what to do to make it to work right. maybe not use the viewport as a guide, but making it in screen space is what i need to do to make a screen quad. I just edited my screen qwuad to be able to make it any size i want, so i guess i'm ok, since DrawPrimitive doesn't fial when i use it in my renderer library i made awhile ago.So what are the differences between the current version and the old version? Did you try disabling culling anyway just to be sure?   ;  the old version of the function would set the quad to a pre-set value for the width and height of the viewport, this new one allows me to specify the values for the width and height of the quad, saddly it seems that it doesn't work very well with Irrlicht's way of doing meshes. like if i use the screen quad, Irrlicht's meshes don't show up even though i'm using the Direct3D9 driver, other wise no direct3D functions would work with Irrlicht. so i guess i need to see what i can do about making a screen quad and be able to add HDR to my games which i plan on adding it to my current pong game i've been working on for the last two days.   ;  How do you defined the D3DFVF_HEALTHBOX ? If you wish to draw directly to screen you can use FVF with XYZRHW or if you want to use XYZ one (for having some translation and other things...) you need to switch your projection matrix to 2d space with a matrix created by D3DXMatrixOrthoOffCenterRH function. If you do so, it will be good to make identity the world and view matrices.   