Jump to content
  • Advertisement
Sign in to follow this  
nguyen my

don't read file .fx ?

This topic is 2832 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!