# 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.

## 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?

Sepiantum

##### Share on other sites
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

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

##### 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 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 on other sites
Thanks. I'll try that when I have time.

1. 1
2. 2
3. 3
4. 4
Rutin
15
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633724
• Total Posts
3013556
×