• Advertisement
Sign in to follow this  

Directx8 Basic question

This topic is 4049 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

I am trying to draw a line whose start point is fixed at origin and the end point will be set to the last mouse click point. My problem is the line's end point is not updated on the screen. I think the following are main steps to do this 1. m_d3d.Device.CreateVertexBuffer 2. Set the data to the vertex buffer (D3DVertexBuffer8SetData) 3. m_d3d.Device.SetStreamSource 4. m_d3d.Device.DrawPrimitive I am calling the step 1 & 2 during the line creation. step 3 & 4 are called in the renderline() function. Whenever I click a new point using the mouse, I update the vertex's x, y, z values and renderline() gets called. In this case the vertex buffer still has only the old values and keeps drawing the line with the original values. Is this right? In order to make the drawing code use the updated vertex's x, y, z values should i call both step 1 & step 2 everytime mouse is clicked or step 2 alone is sufficient?

Share this post


Link to post
Share on other sites
Advertisement
You don't need to recreate the vertex buffer each time the line changes, but you do need to update its contents.

So yes, step 2 is sufficient.

Share this post


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

  • Advertisement