I'm having a bit of trouble at the moment.
I'm reading Frank Luna's "Introduction to 3D Game Programming with DirectX 11" (great book so far by the way) and going through tutorials on
> http://www.braynzarsoft.net/index.php?p=DX11Lessons < Also pretty awesome. Well one of the exercises at the end of the 4th tutorial off of the braynzarsoft site, is to " Try to draw a square" which they give you a hint, it's "Vertex Buffer." However, I cannot seem to figure out how to change the code / add to it to make this happen. I've heard a few times that you need to use two triangles to make a square in DX (and maybe a few others libraries) but I'm still not sure about that either. I've read this the tutorials and through some of the book I mentioned and I just can't find it. I've search on here, and through google for a while but with no avail.
The full source is here:
http://pastebin.com/XaJvnB1B <
Because the hint is "Vertex Buffer" i thought maybe it would be in this section of code:
//set the vertex and pixel shaders
Vertex v[] =
{
//X / Y/ Z
Vertex(0.0f, 0.5f, 0.5f),
Vertex(0.5f, -0.5f, 0.5f),
Vertex(-0.5f, -0.5f, 0.5f),
//Vertex(0.2f, 0.5f, -0.5f),
};
D3D11_BUFFER_DESC vertexBufferDesc;
ZeroMemory(&vertexBufferDesc, sizeof(vertexBufferDesc));
vertexBufferDesc.Usage = D3D11_USAGE_DEFAULT;
vertexBufferDesc.ByteWidth = sizeof(Vertex) * _countof(v); //was * 3
vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
vertexBufferDesc.CPUAccessFlags = 0;
vertexBufferDesc.MiscFlags = 0;
D3D11_SUBRESOURCE_DATA vertexBufferData;
ZeroMemory(&vertexBufferData, sizeof(vertexBufferData));
vertexBufferData.pSysMem = v;
hr = d3d11Device->CreateBuffer(&vertexBufferDesc, &vertexBufferData, &triangleVertBuffer);
But i'm still not sure how to advance in all honestly. I know that the "Vertex v[]" and the coordinates given are to point to where which line should go (?) but after playing with it and attempting to add an extra vertex, it didn't seem to update after i compiled and ran it.
(For the record, this is DX11, and i'm using Visual Studio 2010 Ultimate.)