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 ?
don't read file .fx ?
Try:
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:
Assumes you're using DX9. If so:
#include "dxerr9.h"
and link to dxerr9.lib.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement