Jump to content
  • Advertisement
Sign in to follow this  

Why only one point DIrectX11

This topic is 2100 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
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
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
// 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]

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
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 smile.png

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

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
I am still fighting to get along with my triangles and squares. =)
but i have the triangleStrip ok but my Triangle_list wont render texture correct.

I guess i need to go back to basic samples. again, thanks for the answers.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!