Sign in to follow this  

don't read file .fx ?

This topic is 2651 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 have a program for read from a file .fx but don't read.
this file effect.fx

uniform extern float4x4 gWVP;

struct OutputVS
{
float4 posH : POSITION0;
};

OutputVS TransformVS(float3 posL : POSITION0)
{
// Zero out our output.
OutputVS outVS = (OutputVS)0;

// Transform to homogeneous clip space.
outVS.posH = mul(float4(posL, 1.0f), gWVP);

// Done--return the output.
return outVS;
}
}
float4 TransformPS() : COLOR
{
return float4(0.0f, 0.0f, 0.0f, 1.0f);
}

technique TransformTech
{
pass P0
{
// Specify the vertex and pixel shader associated with this pass.
vertexShader = compile vs_2_0 TransformVS();
pixelShader = compile ps_2_0 TransformPS();

// Specify the render/device states associated with this pass.
FillMode = Wireframe;
}
}

and read function

void CubeDemo::buildFX()
{
//khoi tao co tro store error
ID3DXBuffer *error=0;
D3DXCreateEffectFromFile(d3ddv,"effect.fx",0,0,D3DXSHADER_DEBUG,0,&FX,&error);
if(error)
{
MessageBox(0,"don't read this file transform ","error",0);
return;
}
//get handle
WVP=FX->GetParameterByName(0,"gWVP");
Tech=FX->GetTechniqueByName("TransformTech");

}

. when reading, this show a MessageBox(...);
i don't know what ?

Share this post


Link to post
Share on other sites
Try:

if(error)
{
char *msg = (char*)error->GetBufferPointer();
MessageBox(0,msg,"error",0);
error->Release(); // EDIT - IIRC, ID3DXBuffer is a COM object
return;
}

to get the error message which should be more informative.

You should also check the return from D3DXCreateEffectFromFile to ensure all the arguments (such as the filepath) are valid, such as:

HRESULT hr = D3DXCreateEffectFromFile(...);
if( FAILED(hr) )
{
MessageBox(NULL, DXGetErrorDescription9(hr), "D3DXCreateEffectFromFile Error", MB_OK);
return;
}

Assumes you're using DX9. If so:
#include "dxerr9.h"

and link to dxerr9.lib.

Share this post


Link to post
Share on other sites
if i copy from other file .fx ,this program run normal. but i write same that file and don't run. if copy it run.

Share this post


Link to post
Share on other sites

This topic is 2651 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this