Jump to content
  • Advertisement
Sign in to follow this  
Sepiantum

Lines in Direct 3D 11

This topic is 2522 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 tried using Google and I never really found any tutorials for drawing lines from pixel coordinates in Direct3D 11. Could someone enlighten me on this topic?

Thanks in advance,
Sepiantum

Share this post


Link to post
Share on other sites
Advertisement
it's actually very very simple. you set the primitive topology to D3D11_PRIMITIVE_TOPOLOGY_LINELIST like this:

d3d11DevCon->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST );

and instead of every 3 indices in the index buffer, this will use every 2 indices to create a line. for example, if you were making a square, the index buffer might look like this:

0,1,2
0,2,3


but now you want to use lines for the square, it would look like this:

0,1
1,2
2,3
3,0


hope that answers your question!

oh sorry, my mistake. I overlooked the part where you said pixel coordinates ;) Edited by iedoc

Share this post


Link to post
Share on other sites
OK let me rephrase. I know how to use LINELIST with primitive topology. The question is when I create vertices, do I use pixel coordinates or do I have to convert them to 3D coordinates?

Share this post


Link to post
Share on other sites
The device itself always uses normalized device coordinates, no matter the scene type. Your projection matrix is usually responsible for converting from "3D world" coordinates, or "2D screen" coordinates into NDC.

So, if you want to do 2D rendering in pixel coordinates, then configure your projection matrix to be an ortho projection ranging from 0 to numPixels-1.

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!