Converting world coords To screen coords


I have a fair number of single dots that I need to convert to screen space each frame and I use the following snippet of code below to do so. This is, however, the most costly lines of code in my game.

I draw one small texture at each point to define a trace line. Should I be doing this some other way? Perhaps using a transformation matrix passed into the constructor of the spritebatch used?

public Vector2 ConvertWorldToScreen(Vector2 location)
     Vector3 t = new Vector3(location, 0);
     t = _viewport.Project(t, _projection, _view, Matrix.Identity);

     return new Vector2(t.X, t.Y);

I think you should use matrix invert to do this …

I’m on mobile so I can’t answer clearly , but I can give you some useful link I found for my case ::

I think you can found your way here, tell me I you have another problem !