• Advertisement
Sign in to follow this  

[.net] 2D graphics? Drawing to direct screen coordinates?

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

Hi, I am wondering if it is possible to set directx up so I can draw graphics to direct x and y coordinates like draw(x,y) where 0 < x < resolution width and 0 < y < res height? i am trying to make a 2d application in 3d... thanks!

Share this post


Link to post
Share on other sites
Advertisement
I've found out I need to use an orthographic projection but I am not exactly sure how to correctly set one up.

d3d_device.Transform.Projection = Matrix.OrthoLH(this.Width, this.Height, 0, 1.0f) is not working at all...

thanks

Share this post


Link to post
Share on other sites
You don't need to do any projection. Just make sure your device.Viewport is set to the exact window width and height. This should be sufficient.

Share this post


Link to post
Share on other sites

Matrix ortho = new Matrix();
Matrix identity = new Matrix();

ortho = Matrix.OrthoOffCenterLH(0.0f, 640.0f, 480.0f, 0.0f, 0.0f, 100.0f);
identity = Matrix.Identity;

device.SetTransform(TransformType.Projection, ortho);
device.SetTransform(TransformType.World, identity);
device.SetTransform(TransformType.View, identity);



640.0f, 480.0f are your widths / height. Enjoy!

Share this post


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

  • Advertisement