Need a little bit of help with the Input Assembly stage of Direct3D 11

Hi, I am currently making a game with directx 11 and I am having a little bit of trouble with the rendering pipeline.

I have already described the swap chain on my game, as well as the back buffer. I also already set the render target to the back buffer, so i already understand the basics of directx. But I am stuck in the first stage of the pipeline, the input assembly stage. I am trying to draw the vertices of a triangle and display them on the screen, but so far nothing will show up.

Here is my code for the first stage..
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
void InputAssemblerStage()
{
	D3D11_INPUT_ELEMENT_DESC Layouts[2] =					
	{
		{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},			
		{"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA , 0}		
	};										
	Vertex VerticesData[] =
	{
		D3DXVECTOR3(0.1f, 0.2f, 0.3f),
		D3DXCOLOR(0.2f, 0.2f, 0.2f, 0.0f),
		D3DXVECTOR3(0.1f, 0.1f, -0.5f),
		D3DXCOLOR(0.1f, 0.2f, 0.3f, 0.1f)
	};									

	  D3D11_BUFFER_DESC VertexBufferDesc;						

	VertexBufferDesc.Usage = D3D11_USAGE_DEFAULT;			
	VertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;  
	VertexBufferDesc.CPUAccessFlags = 0;					
	VertexBufferDesc.MiscFlags = 0;								
	VertexBufferDesc.ByteWidth = sizeof(Vertex);		

	D3D11_SUBRESOURCE_DATA VertexData;

	VertexData.pSysMem = VerticesData;
	VertexData.SysMemPitch = 0;
	VertexData.SysMemSlicePitch = 0;
										
				/* Creating the input layout */
	device->CreateInputLayout(Layouts, 2, NULL, NULL, &inputLayout);

				/* Creating the vertex buffer */
	device->CreateBuffer(&VertexBufferDesc, &VertexData, &VertexBuffer);

	UINT stride = sizeof(Vertex);	
        UINT offset = 0;
	DevContext->IASetVertexBuffers(0, 1, &VertexBuffer, &stride, &offset);

	DevContext->IASetInputLayout(inputLayout);

	DevContext->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

	DevContext->Draw(2, 0);
}


and here is the vertex sctructure
1
2
3
4
5
6
struct Vertex
{
	D3DXVECTOR3 position;
	D3DXCOLOR color;
};



Is there anything wrong with my code that will prevent anything from showing up?

or do i have to implement the other stages of the pipeline to actually show something

(Most of the pointers in my code have been declared as global variables)
Last edited on
Topic archived. No new replies allowed.