Jump to content
  • Advertisement
Sign in to follow this  
Garra

Unhandled Exception

This topic is 2642 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'm getting the below error while trying to call D3DX10CreateEffectFromFile. Basically when my game calls the initialize function when starting up my InitializeShader function is called and auto throws the following error when the D3DX10CreateEffectFromFile function is called. I'm confused about whats going on so I thought I'd get someone to maybe have a look at my effect file just be be sure everything is good with it. I just recently started working with them. The effect file is going to be used for terrain lighting. I have loaded in another effect file that I was using to light up my terrain grid with no problems, but when i modified the effect file and source code for lighting it started throwing this exception at me.

Unhandled exception at 0x6be16d41 in FinalGame.exe: 0xC0000005: Access violation writing location 0x00000000.


////////////////////////////////////////////////////////////////////////////////
// Filename: terrain.fx
////////////////////////////////////////////////////////////////////////////////


/////////////
// GLOBALS //
/////////////
SamplerState SampleType;

matrix worldMatrix;
matrix viewMatrix;
matrix projectionMatrix;

cbuffer LightBuffer
{
float4 ambientColor;
float4 diffuseColor;
float3 lightDirection;
float padding;
};

//////////////
// TYPEDEFS //
//////////////
struct VertexInputType
{
float4 position : POSITION;
float3 normal : NORMAL;
};

struct PixelInputType
{
float4 position : SV_POSITION;
float3 normal : NORMAL;
};


////////////////////////////////////////////////////////////////////////////////
// Vertex Shader
////////////////////////////////////////////////////////////////////////////////
PixelInputType TerrainVertexShader(VertexInputType input)
{
PixelInputType output;


// Change the position vector to be 4 units for proper matrix calculations.
input.position.w = 1.0f;

// Calculate the position of the vertex against the world, view, and projection matrices.
output.position = mul(input.position, worldMatrix);
output.position = mul(output.position, viewMatrix);
output.position = mul(output.position, projectionMatrix);

output.normal = mul(input.normal, (float3x3)worldMatrix);

//normalize the normal vector
output.normal = normalize(output.normal);

return output;
}


////////////////////////////////////////////////////////////////////////////////
// Pixel Shader
////////////////////////////////////////////////////////////////////////////////
float4 TerrainPixelShader(PixelInputType input) : SV_Target
{
float3 lightDir;
float lightIntensity;
float4 color;


// Set the default output color to the ambient light value for all pixels.
color = ambientColor;

// Invert the light direction for calculations.
lightDir = -lightDirection;

// Calculate the amount of light on this pixel.
lightIntensity = saturate(dot(input.normal, lightDir));

if(lightIntensity > 0.0f)
{
// Determine the final diffuse color based on the diffuse color and the amount of light intensity.
color += (diffuseColor * lightIntensity);
}

// Saturate the final light color.
color = saturate(color);

return color;
}


////////////////////////////////////////////////////////////////////////////////
// Technique
////////////////////////////////////////////////////////////////////////////////
technique10 TerrainTechnique
{
pass pass0
{
SetVertexShader(CompileShader(vs_4_0, TerrainVertexShader()));
SetPixelShader(CompileShader(ps_4_0, TerrainPixelShader()));
SetGeometryShader(NULL);
}
}



result = D3DX10CreateEffectFromFile(filename.c_str(),
0,
0,
"fx_4_0",
D3D10_SHADER_ENABLE_STRICTNESS,
0,
device,
0,
0,
&m_effect,
&errorMessage,
0);

Share this post


Link to post
Share on other sites
Advertisement

I'm getting the below error while trying to call D3DX10CreateEffectFromFile. Basically when my game calls the initialize function when starting up my InitializeShader function is called and auto throws the following error when the D3DX10CreateEffectFromFile function is called. I'm confused about whats going on so I thought I'd get someone to maybe have a look at my effect file just be be sure everything is good with it. I just recently started working with them. The effect file is going to be used for terrain lighting. I have loaded in another effect file that I was using to light up my terrain grid with no problems, but when i modified the effect file and source code for lighting it started throwing this exception at me.

Unhandled exception at 0x6be16d41 in FinalGame.exe: 0xC0000005: Access violation writing location 0x00000000.


////////////////////////////////////////////////////////////////////////////////
// Filename: terrain.fx
////////////////////////////////////////////////////////////////////////////////


/////////////
// GLOBALS //
/////////////
SamplerState SampleType;

matrix worldMatrix;
matrix viewMatrix;
matrix projectionMatrix;

cbuffer LightBuffer
{
float4 ambientColor;
float4 diffuseColor;
float3 lightDirection;
float padding;
};

//////////////
// TYPEDEFS //
//////////////
struct VertexInputType
{
float4 position : POSITION;
float3 normal : NORMAL;
};

struct PixelInputType
{
float4 position : SV_POSITION;
float3 normal : NORMAL;
};


////////////////////////////////////////////////////////////////////////////////
// Vertex Shader
////////////////////////////////////////////////////////////////////////////////
PixelInputType TerrainVertexShader(VertexInputType input)
{
PixelInputType output;


// Change the position vector to be 4 units for proper matrix calculations.
input.position.w = 1.0f;

// Calculate the position of the vertex against the world, view, and projection matrices.
output.position = mul(input.position, worldMatrix);
output.position = mul(output.position, viewMatrix);
output.position = mul(output.position, projectionMatrix);

output.normal = mul(input.normal, (float3x3)worldMatrix);

//normalize the normal vector
output.normal = normalize(output.normal);

return output;
}


////////////////////////////////////////////////////////////////////////////////
// Pixel Shader
////////////////////////////////////////////////////////////////////////////////
float4 TerrainPixelShader(PixelInputType input) : SV_Target
{
float3 lightDir;
float lightIntensity;
float4 color;


// Set the default output color to the ambient light value for all pixels.
color = ambientColor;

// Invert the light direction for calculations.
lightDir = -lightDirection;

// Calculate the amount of light on this pixel.
lightIntensity = saturate(dot(input.normal, lightDir));

if(lightIntensity > 0.0f)
{
// Determine the final diffuse color based on the diffuse color and the amount of light intensity.
color += (diffuseColor * lightIntensity);
}

// Saturate the final light color.
color = saturate(color);

return color;
}


////////////////////////////////////////////////////////////////////////////////
// Technique
////////////////////////////////////////////////////////////////////////////////
technique10 TerrainTechnique
{
pass pass0
{
SetVertexShader(CompileShader(vs_4_0, TerrainVertexShader()));
SetPixelShader(CompileShader(ps_4_0, TerrainPixelShader()));
SetGeometryShader(NULL);
}
}



result = D3DX10CreateEffectFromFile(filename.c_str(),
0,
0,
"fx_4_0",
D3D10_SHADER_ENABLE_STRICTNESS,
0,
device,
0,
0,
&m_effect,
&errorMessage,
0);



Sounds like you are accessing a NULL pointer.
Have you checked that the filename string is valid?

Share this post


Link to post
Share on other sites
thanks, I'm not exactly sure what was wrong with it.. but I think somewhere something had to be a NULL pointer. The filename seemed to be fine. However, I replaced some of the code in my main file and it worked perfect... so not sure what was the deal/

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!