Jump to content
  • Advertisement
Sign in to follow this  
HarrisonPloeg

Can't add vertices

This topic is 4334 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do I add vertices that are placed by the user of the program, I've tried to use a while loop but when you click somewhere the program crashes. Part of an example function: void init_graphics() { CUSTOMVERTEX t_vert[] = { { 64.0f, -64.0f, 0.5f, D3DCOLOR_XRGB(255, 0, 255), }, { -64.0f, -64.0f, 0.5f, D3DCOLOR_XRGB(255, 255, 100), }, { 64.0f, 64.0f, 0.5f, D3DCOLOR_XRGB(0, 255, 255), }, { -64.0f, 64.0f, 0.5f, D3DCOLOR_XRGB(0, 0, 255), }, }; while(position <= positionInArray - 1) /* positionInArray is the position of the last vertex in the arrays */ { t_vert[position + 4].X = vertexX[position]; t_vert[position + 4].Y = vertexY[position]; t_vert[position + 4].Z = vertexZ[position]; t_vert[position + 4].COLOR = D3DCOLOR_XRGB(255, 255, 0); position++; }; gd3dDevice->CreateVertexBuffer((positionInArray+4)*sizeof(CUSTOMVERTEX), 0, CUSTOMFVF, D3DPOOL_MANAGED, &t_buffer, NULL); VOID* pVoid; // lock t_buffer and load the vertices into it t_buffer->Lock(0, 0, (void**)&pVoid, 0); memcpy(pVoid, t_vert, sizeof(t_vert)); t_buffer->Unlock(); position = 0; return; } [Edited by - HarrisonPloeg on January 29, 2007 2:00:43 AM]

Share this post


Link to post
Share on other sites
Advertisement
This code doesn't make any sense. The beginning of it is that you seem to be writing into arbitrary positions of t_vert, which are 8 or higher (assuming 'position' isn't negative), and it's defined to be of size 4 (according to the way it's initialised). WTF?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!