Lines in Direct 3D 11

Started by
3 comments, last by Sepiantum 12 years, 3 months ago
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
Follow and support my game engine (still in very basic development)? Link
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 ;)
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?
Follow and support my game engine (still in very basic development)? Link
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.
Thanks. I'll try that when I have time.
Follow and support my game engine (still in very basic development)? Link

This topic is closed to new replies.

Advertisement