   [MDX 2.0] How to Dispose a vertexbuffer
  Finally, I've made it:My programm is alt-tab/ctr-esc etc. save. It was a hard week...In addition to that I can draw sprites, dispose and reload them (and the textures) if needed. But I dont know how to Dispose my vertexbuffer (and its Data) correctly if a DeviceLost occurs. This is one function where I use the vertexbuffer:   public void DrawLine(int x, int y, int zx, int zy)   {  PositionColored[] vert = new PositionColored[2];  vert[0].X = x;  vert[0].Y = y;  vert[0].Z = 0.0f;  vert[0].Color = System.Drawing.Color.Green;  vert[1].X = zx;  vert[1].Y = zy;  vert[1].Z = 0.0f;  vert[1].Color = System.Drawing.Color.Green;    vertexBuffer.Lock<PositionColored>(0, 2, LockFlags.None).Write(vert);  vertexBuffer.Unlock();  DirectXDevice.SetStreamSource(0, vertexBuffer, 0, PositionColored.StrideSize);  DirectXDevice.DrawPrimitives(PrimitiveType.LineList, 0, 1);  // Now I want release the data in the vertexbuffer  vertexBuffer.Lock<PositionColored>(0, 2, LockFlags.None).Dispose(); // With this Dispose() call I can call vertexBuffer.Dispose() if a DeviceLost occurs. But this has a strange behavior, some lines are not drawn!   }Has anyone an idea?   
  when you lose the device you need to call .Release on the VB. when you get the device back, you have to reset the VB. usually, you write a RestoreDeviceObjects()function that you call from the constructor and when you lose the device that does this. by the way, you know locking the VB is super slow right? avoid it whenever possible. for colors use materials (unless u need per vertex color). write a shader if vertex movement can easily be written by a function. if you are advanced, you can even stream the vertex colpr, pos etc to the shader without ever locking.-programmer_tom   ;  Hello Tom!Quote:Original post by programmer_tomwhen you lose the device you need to call .Release on the VB. when you get the device back, you have to reset the VB. usually, you write a RestoreDeviceObjects()function that you call from the constructor and when you lose the device that does this. Im working with Managed DirectX 2.0, this means there are no functions like "Release" or "Reset". I can only see "Dispose". I must somehow clear the vertexbuffer-data before I can say "vertexbuffer.Dispose()".At the moment I do this like in the code example. This is ugly, but I dont have another idea...Quote:Original post by programmer_tomby the way, you know locking the VB is super slow right? avoid it whenever possible. for colors use materials (unless u need per vertex color). write a shader if vertex movement can easily be written by a function. if you are advanced, you can even stream the vertex colpr, pos etc to the shader without ever locking.-programmer_tomIm definitely not advanced in directx ;-) I will try to avoid useless locking!;Quote:Original post by programmer_tomif you are advanced, you can even stream the vertex colpr, pos etc to the shader without ever locking.Although it is off-topic: interesting, can you explain that?