Click here to Skip to main content
15,900,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I get this error

Unhandled exception at 0x012c17d2 in DirectXProgram.exe: 0xC0000005: Access violation reading location 0x00000000.

This is my code..
C++
bool InitScene()
{
	//The vertices for the triangle
	Vertex vertices[] =
    {
        D3DXVECTOR3( 0.0f, 0.5f, 0.5f ),
        D3DXVECTOR3( 0.5f, -0.5f, 0.5f ),
        D3DXVECTOR3( -0.5f, -0.5f, 0.5f ),
    }; 

	//Filling the buffer descriptor 
	D3D10_BUFFER_DESC bd;
    bd.Usage = D3D10_USAGE_DEFAULT;
    bd.ByteWidth = sizeof( Vertex ) * 3;
    bd.BindFlags = D3D10_BIND_VERTEX_BUFFER;
    bd.CPUAccessFlags = 0;
    bd.MiscFlags = 0;

	//Sub resource data for the Input Assembler
	D3D10_SUBRESOURCE_DATA InitData;
    InitData.pSysMem = vertices;

	 d3dDevice->CreateBuffer( &bd, &InitData, &VertexBuffer );

	unsigned int stride = sizeof( Vertex );
	unsigned int offset = 0;
	d3dDevice->IASetVertexBuffers( 0, 1, &VertexBuffer, &stride, &offset );

	 D3DX10CreateEffectFromFile( "vertex.fx", NULL, NULL, "fx_4_0", D3D10_SHADER_ENABLE_STRICTNESS, 0,
                                         d3dDevice, NULL, NULL, &FX, NULL, NULL );

    Technique = FX->GetTechniqueByName( "Tech" );

	D3D10_PASS_DESC PassDesc;
    Technique->GetPassByIndex( 0 )->GetDesc( &PassDesc );

	d3dDevice->CreateInputLayout( layout, 1, PassDesc.pIAInputSignature,
                                          PassDesc.IAInputSignatureSize, &VertexLayout );

	d3dDevice->IASetInputLayout( VertexLayout ); 
	d3dDevice->IASetPrimitiveTopology( D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST );
	return true;
}


There is a break at Technique = FX->GetTechniqueByName("Tech");
Posted
Updated 28-May-14 22:34pm
v2

1 solution

With the info you provided it's unlikely you will get a too specific answer, but if you mean it crashes on FX->Get... by "There is a break at...", then most likely your D3DX10CreateEffectFromFile(...) call fails, examine the HRESULT[^] it returns to see what might be wrong.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900