let me run down a noob problem im having right now.
I have a struct LandVert
struct LandVert{ float x, y, z ; // The transformed position for the vertex. float nx, ny, nz; //the normal for the square DWORD color; //the diffuse color of the vertex, also stores alpha. float tu,tv; // The vertex texture coordinates.// };//here i initialize the pointerLandVert* vertices = 0; //pointer to vertices array In a call to the object that contains the struct i need to newnumofVerts vertices, so i need an array of my struct with numofVerts elements. HRESULT TListAuthor::MakeTListAuthor(int numofVerts){ vertices = new LandVert[(numofVerts - 1)];} Later on i attempt to manipulate the components of the struct vertices[0].x = -1.0f; vertices[0].y = 2.0f; vertices[0].tu = 0.0f; vertices[0].tv = 0.0f; vertices[1].x = 1.0f; vertices[1].y = 2.0f; vertices[1].tu = 1.0f; vertices[1].tv = 0.0f; vertices[2].x = -1.0f; vertices[2].y = 0.0f; vertices[2].tu = 0.0f; vertices[2].tv = 1.0f; vertices[3].x = -1.0f; vertices[3].y = 0.0f; vertices[3].tu = 0.0f; vertices[3].tv = 1.0f; vertices[4].x = 1.0f; vertices[4].y = 2.0f; vertices[4].tu = 1.0f; vertices[4].tv = 0.0f; vertices[5].x = 1.0f; vertices[5].y = 0.0f; vertices[5].tu = 1.0f; vertices[5].tv = 1.0f; for (int i = 0; i < numofVerts; i++) { vertices[i].color = 0xFFFFFFFF; vertices[i].nx = 0.0f; vertices[i].ny = 1.0f; vertices[i].nz = 0.0f; vertices[i].z = -5.0f; } later on i create the V Bufferand then finally draw g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE); g_pd3dDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_NONE); g_pd3dDevice->SetFVF(UNTRANS_CUSTOMVERTEX); g_pd3dDevice->SetStreamSource(0,g_pVBuff,0 , sizeof(LandVert)); g_pd3dDevice->SetTexture(0,g_texture); g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLELIST,0,2); g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,FALSE);
when i create my array of structs statically it renders fine,
but when i try to create the array dynamically nothing renders.
the reason i included the drawing code is because the sizeof operators and any possible conflicts between
sizeof(Struct) and sizeof (pointertoStruct)
anyone mind helping out,
*edit* just wanted to pint out that the code compiles,
i have debug code that lets me know the VertexBuffer and Texture are being created, thx for any help, just cant figure it out.
Dreddnafious Maelstrom
"If I have seen further, it was by standing on the shoulders of Giants"
Sir Isaac Newton
[edited by - Dreddnafious Maelstrom on May 1, 2003 5:40:02 PM]
[edited by - Dreddnafious Maelstrom on May 1, 2003 5:49:24 PM]