I am trying to change from triangle_list to point_list
but only 1 point is showing. what am i missing to set to 1 that was 3 before?
[source lang="cpp"] // create a triangle using the VERTEX struct VERTEX OurVertices[] = { {0.0f, 0.1f, 0.0f, D3DXCOLOR(0.0f, 1.0f, 0.0f, 1.0f)}, //This is the only one showing on screen. {0.0f, 0.0f, 0.0f, D3DXCOLOR(0.0f, 1.0f, 0.0f, 1.0f)}, {0.1f, 0.1f, 0.0f, D3DXCOLOR(0.0f, 1.0f, 0.0f, 1.0f)}, }; // create the vertex buffer D3D11_BUFFER_DESC bd; ZeroMemory(&bd, sizeof(bd)); bd.Usage = D3D11_USAGE_DYNAMIC; // write access access by CPU and GPU bd.ByteWidth = sizeof(VERTEX); // size is the VERTEX struct * 3 bd.BindFlags = D3D11_BIND_VERTEX_BUFFER; // use as a vertex buffer bd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; // allow CPU to write in buffer dev->CreateBuffer(&bd, NULL, &pVBuffer); // create the buffer // copy the vertices into the buffer D3D11_MAPPED_SUBRESOURCE ms; devcon->Map(pVBuffer, NULL, D3D11_MAP_WRITE_DISCARD, NULL, &ms); // map the buffer memcpy(ms.pData, OurVertices, sizeof(OurVertices)); // copy the data devcon->Unmap(pVBuffer, NULL); // unmap the buffer // select which vertex buffer to display UINT stride = sizeof(VERTEX); UINT offset = 0; devcon->IASetVertexBuffers(0, 1, &pVBuffer, &stride, &offset); // select which primtive type we are using devcon->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_POINTLIST); // draw the vertex buffer to the back buffer // set the new values for the constant buffer devcon->UpdateSubresource(pCBuffer, 0, 0, &matFinal, 0, 0); //As many OurVertices.count. devcon->Draw(30, 0);[/source]
Why only one point DIrectX11
Started by KurtO, Sep 21 2012 11:07 AM
6 replies to this topic
Sponsor:
#2 Members - Reputation: 459
Posted 21 September 2012 - 04:28 PM
There's a lot of reasons that this can happen, and it's notoriously difficult to determine just by looking at code. Try debugging the values on teh CPU side and see what you get on the GPU side with PIX, that'll give you a good place to start.
Perception is when one imagination clashes with another
#3 Members - Reputation: 2031
Posted 22 September 2012 - 05:48 AM
You need to allocate more space in the vertex buffer. Funnily enough, the comment in the relevant line is correct but the actual statement isn't 
Also, if you only have 3 vertices, you should not try to draw 30 of them. That can cause an access violation in the GPU, and can ultimately result in very funky behavior, including missing geometry or crash.
Also, if you only have 3 vertices, you should not try to draw 30 of them. That can cause an access violation in the GPU, and can ultimately result in very funky behavior, including missing geometry or crash.
Edited by Nik02, 22 September 2012 - 05:54 AM.
Niko Suni
Software developer
Software developer
#4 Members - Reputation: 4032
Posted 22 September 2012 - 06:20 AM
D3D11 actually does support drawing beyond the end of a vertex buffer; you'll get "Vertex Buffer at the input vertex slot 0 is not big enough for what the Draw*() call expects to traverse. This is OK, as reading off the end of the Buffer is defined to return 0. However the developer probably did not intend to make use of this behavior. [ EXECUTION WARNING #356: DEVICE_DRAW_VERTEX_BUFFER_TOO_SMALL ]" under the debug runtimes, but it won't crash.
It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.
#5 Members - Reputation: 2031
Posted 22 September 2012 - 07:03 AM
Ah, didn't remember that 
Anyway, in this case, taking geometry beyond the buffer is very likely not the original intention.
As a side note, it is also valid to not use a vertex buffer at all, if you don't use any components from the input assembler and instead construct the data in the vertex shader itself by using the SV_VertexId for flow control.
Anyway, in this case, taking geometry beyond the buffer is very likely not the original intention.
As a side note, it is also valid to not use a vertex buffer at all, if you don't use any components from the input assembler and instead construct the data in the vertex shader itself by using the SV_VertexId for flow control.
Niko Suni
Software developer
Software developer






