BoyUnderTheMoon
BoyUnderTheMoon

Reputation: 771

DirectX11 Non-Solid wireframe

I'm attempting to draw a 100x100 grid in DirectX11 using C++, but the following issue happens:

Wireframe lines not solid

The image above shows a grid I am drawing in wireframe, using a rasterizer with its fillmode set to 'D3D11_FILL_WIREFRAME' and a 'D3D11_PRIMITIVE_TOPOLOGY_LINELIST' topology. The lines of the wireframe appear staggered rather than straight, with some parts of the wireframe missing.

As I'm not sure what this issue is referred to as, I'm not entirely sure what I should be looking for and as such, any help is appreciated.

Upvotes: 2

Views: 1416

Answers (2)

Chuck Walbourn
Chuck Walbourn

Reputation: 41067

This is a classic problem of 'aliasing'.

With Direct3D 11, you can use either MSAA which is a general anti-aliasing option, or use a specific line algorithm if you are not using MSAA. See D3D11_RASTERIZER_DESC AntialiasedLineEnable and MultisampleEnable.

See Aliasing and Multisample anti-aliasing

UPDATE: I've added MSAA and the AA mode to the DirectX Tool Kit tutorial.

Upvotes: 4

BoyUnderTheMoon
BoyUnderTheMoon

Reputation: 771

I stumbled across the solution to this and it wasn't what I expected at all. Since the window I created had outline bars, the windows client area was being misrepresented. So when I was creating my graphics device, I was initializing it with the windows size, rather than the windows client size. Somehow, this caused the issue above.

I fixed this by implementing a 'GetClientSize' method for the window, using 'GetWindowRect'.

Upvotes: 0

Related Questions