[DirectX]An Invalid parameter was passed to the returning function?

Hi, Am trying to follow
http://www.braynzars...x.php?p=D3D11BD
This tutorial but I keep getting
An Invalid parameter was passed to the returning function.
When my code try to run
hr = D3d11Device->CreateVertexShader(VSBuffer->GetBufferPointer(), VSBuffer->GetBufferSize(), NULL, &VS);
I get a error message saying that An Invalid parameter was passed to the returning function and am not sure why
Thank you if you could explain it to me I also copy pasted my code in here if it was needed

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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104

bool InitScene()
{

	//Compile Shaders from shader file 5 or 4 = VERSION 
	hr = D3DX11CompileFromFile("Effects.fx", 0, 0, "VS", "vs_4_0", 0, 0, 0, &VSBuffer, 0, 0);
	if(FAILED(hr))
	{
		MessageBox(NULL,DXGetErrorDescription(hr),"D3DX11CompileFromFile Failed VS",MB_OK);
	}	
	else if(SUCCEEDED(hr))
	{
			MessageBox(NULL,DXGetErrorDescription(hr),"D3DX11CompileFromFile Succeded VS",MB_OK);
	}

	hr = D3DX11CompileFromFile("Effects.fx", 0, 0, "PS", "ps_4_0", 0, 0, 0, &VSBuffer, 0, 0);
	if(FAILED(hr))
	{
		MessageBox(NULL,DXGetErrorDescription(hr),"D3DX11CompileFromFile Failed PS",MB_OK);
	}
	else if(SUCCEEDED(hr))
	{
			MessageBox(NULL,DXGetErrorDescription(hr),"D3DX11CompileFromFile Succeded PS",MB_OK);
	}

	//Create the Shader Objects
	//The problem
	hr = D3d11Device->CreateVertexShader(VSBuffer->GetBufferPointer(), VSBuffer->GetBufferSize(), NULL, &VS);
	if(FAILED(hr))
	{
		MessageBox(NULL,DXGetErrorDescription(hr),"D3d11Device->CreateVertexShader Failed",MB_OK);
	}
		else if(SUCCEEDED(hr))
	{
		MessageBox(NULL,DXGetErrorDescription(hr),"D3d11Device->CreatePixelShader Success",MB_OK);

	}
	hr = D3d11Device->CreatePixelShader(PSBuffer->GetBufferPointer(), PSBuffer->GetBufferSize(), NULL, &PS);
	if(FAILED(hr))
	{
		MessageBox(NULL,DXGetErrorDescription(hr),"D3d11Device->CreatePixelShader Failed",MB_OK);
	}		
	else if(SUCCEEDED(hr))
	{
		MessageBox(NULL,DXGetErrorDescription(hr),"D3d11Device->CreatePixelShader Failed",MB_OK);

	}

	//Set Vertex and Pixel Shaders
	D3d11DevCon->VSSetShader(VS, 0, 0);
	D3d11DevCon->PSSetShader(PS, 0, 0);

	//Create the vertex buffer
	Vertex v[] =
	{
		Vertex( 0.0f, 0.5f, 0.5f ),
		Vertex( 0.5f, -0.5f, 0.5f ),
		Vertex( -0.5f, -0.5f, 0.5f ),
	};
	D3D11_BUFFER_DESC vertexBufferDesc;
	ZeroMemory( &vertexBufferDesc, sizeof(vertexBufferDesc) );

	vertexBufferDesc.Usage = D3D11_USAGE_DEFAULT;
	vertexBufferDesc.ByteWidth = sizeof( Vertex ) * 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);

	//Set the vertex buffer
	UINT stride = sizeof( Vertex );
	UINT offset = 0;
	D3d11DevCon->IASetVertexBuffers( 0, 1, &TriangleVertBuffer, &stride, &offset );

	//Create the Input Layout
	hr = D3d11Device->CreateInputLayout( layout, numElements, VSBuffer->GetBufferPointer(), 
		VSBuffer->GetBufferSize(), &VertLayout );
	//Set the Input Layout
	D3d11DevCon->IASetInputLayout( VertLayout );

	//Set Primitive Topology
	D3d11DevCon->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST );

	//Create the Viewport
	D3D11_VIEWPORT viewport;
	ZeroMemory(&viewport, sizeof(D3D11_VIEWPORT));

	viewport.TopLeftX = 0;
	viewport.TopLeftY = 0;
	viewport.Width = windowWidth;
	viewport.Height = windowHeight;

	//Set the Viewport
	D3d11DevCon->RSSetViewports(1, &viewport);


	return true;
}
Last edited on
Topic archived. No new replies allowed.