c++ - D3D line draw split into trinangles -almost- works, but need a hint -


i'm trying write general d3d11 line draw variable width. works when line 45 degrees. 'breaks up' shown in pic. ignore model , triangle....

screenshot

first, calls attempt draw lines, pretty basic:

g_uilineshader.setactive(); (float x = 0; x < 800; x = x + 10) {     g_uilineshader.drawuiline(pd3ddevice, x, 0, 800-x, 600, 3, xmfloat4(1.0f, 1.0f, 0.0f, 1.0f)); } g_uilineshader.render(pd3ddevice); 

and ultimately, render code triangle list:

hresult render(id3d11device * pd3ddevice) {     auto devcon = dxutgetd3d11devicecontext();      // copy of vertices in array vertex buffer      d3d11_mapped_subresource ms;     devcon->map(_pvertexbuffer, null, d3d11_map_write_discard, null, &ms);      // map buffer     memcpy(ms.pdata, &_vertices[0], _vertices.size() * sizeof(uilinevertex));   // copy data     devcon->unmap(_pvertexbuffer, null);                                        // unmap buffer      // set vertex buffer on device context     uint stride = sizeof(uilinevertex);     uint offset = 0;     id3d11buffer * pbuffer = _pvertexbuffer;     devcon->iasetvertexbuffers(0, 1, &pbuffer, &stride, &offset);      // select primtive type using     devcon->iasetprimitivetopology(d3d10_primitive_topology_trianglelist);      // draw vertex buffer buffer     devcon->draw(_vertices.size(), 0);      // once rendered can discard of vertex data     _vertices.clear();     return s_ok; } 

can spot bug or fundamental misunderstanding? if there's better way draw lines in screen space allow different angles , thicknesses, i'd rather not reinvent wheel haven't come across one.

the shader seems fine , merely divides screen space coords screen size -1,+1 space in both x , y dimensions. don't think normals matter, or they?

any appreciated!

just in case runs vaguely similar, turned out rasterizer state; cull mode opposite of way winding triangles. "yay" vs2013 graphics debugger.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -