   Troubles loading FX file
  I am having issues loading my effect.fx from directx. When I step into my application, my ID3D10Effect *m_pDefaultEffect; pointer remains empty after calling D3DX10CreateEffectFromFile. the address remains at 0x000000below is my code    #pragma once    #include "stdafx.h"    #include "resource.h"    #include "d3d10.h"    #include "d3dx10.h"    #include "dinput.h"  #define MAX_LOADSTRING 100   class RenderEngine {    protected:   RECT m_screenRect;   //direct3d Members    ID3D10Device *m_pDevice; // The IDirect3DDevice10    // interface    ID3D10Texture2D *m_pBackBuffer; // Pointer to the back buffer    ID3D10RenderTargetView *m_pRenderTargetView; // Pointer to render target view    IDXGISwapChain *m_pSwapChain; // Pointer to the swap chain    RECT m_rcScreenRect; // The dimensions of the screen   ID3D10Texture2D *m_pDepthStencilBuffer;    ID3D10DepthStencilState *m_pDepthStencilState;    ID3D10DepthStencilView *m_pDepthStencilView;   //transformation matrixs    D3DXMATRIX g_mtxWorld;    D3DXMATRIX g_mtxView;    D3DXMATRIX g_mtxProj;   //Effect members    ID3D10Effect *m_pDefaultEffect;    ID3D10EffectTechnique *m_pDefaultTechnique;   ID3DX10Font *m_pFont; // The font used for rendering text    // Sprites used to hold font characters    ID3DX10Sprite *m_pFontSprite;   ATOM RegisterEngineClass();    void DoFrame(float);    bool LoadEffects();   public:    static HINSTANCE m_hInst;    HWND m_hWnd;    int m_nCmdShow;    TCHAR m_szTitle[MAX_LOADSTRING];// The title bar text    TCHAR m_szWindowClass[MAX_LOADSTRING];// the main window class name   void DrawTextString(int x, int y, D3DXCOLOR color, const TCHAR *strOutput);   //static functions    static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);    static INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);   bool InitWindow();    bool InitDirectX();    bool InitInstance();    int Run();    void ShutDown();   RenderEngine()    {    m_screenRect.right = 800;    m_screenRect.bottom = 600;    }   };below is the implementationbool RenderEngine::LoadEffects()    {    HRESULT hr;   ID3D10Blob *pErrors = 0;    // Create the default rendering effect   hr = D3DX10CreateEffectFromFile(L"effect.fx", NULL, NULL,    "fx_4_0", D3D10_SHADER_DEBUG, 0, m_pDevice, NULL, NULL, &m_pDefaultEffect,    &pErrors, NULL);  if(pErrors)// at this point, m_pDefaultEffect is still empty but pErrors returns data which means there is{//errors    return false; //ends here    }   //m_pDefaultTechnique = m_pDefaultEffect->GetTechniqueByName("DefaultTechnique");   return true;    }My directx Device does work. My effect.fx file is in the same folder as my solution files (.cpp and header files)
  Try putting your effect file into the same folder your executable is in.Also make sure that the effect is compiled correctly.   ;Quote:Original post by HyunkelTry putting your effect file into the same folder your executable is in.Also make sure that the effect is compiled correctly.Yea I tried to put it into the same folder as my exe folder too. samething happens. Here is my effect.fx codematrix g_mtxWorld;matrix g_mtxView;matrix g_mtxProj;#define MAX_LIGHTS 10 // Ensure this is the same as the C++ valueint4 g_viLightStatus;float4 g_vLightColors[MAX_LIGHTS];float4 g_vLightDirections[MAX_LIGHTS];struct VS_INPUT{float3 vPosition : POSITION;float3 vNormal : NORMAL;float4 vColor : COLOR0;float2 vTexCoords : TEXCOORD;};struct VS_OUTPUT{float4 vPosition : SV_POSITION;float3 vNormal : NORMAL;float4 vColor : COLOR0;};VS_OUTPUT DefaultVS(VS_INPUT dataIn){VS_OUTPUT result;float4 vPos = float4(dataIn.vPosition, 1.0f);float4 vFinalPos = mul(vPos, g_mtxWorld);vFinalPos = mul(vFinalPos, g_mtxView);vFinalPos = mul(vFinalPos, g_mtxProj);result.vPosition = vFinalPos;result.vNormal = float3(0,0,0);result.vColor = float4(1,0,0,0);return result;}float4 DefaultPS(VS_OUTPUT dataIn) : SV_Target{return dataIn.vColor;}technique10 DefaultTechnique{pass Pass0{SetGeometryShader(NULL);SetVertexShader(CompileShader(vs_4_0, VS()));SetPixelShader(CompileShader(ps_4_0, PS()));}}not sure if this matters , but i have not created my vertex layout yet. I am trying to take it one step at a time.   ;  Figured it outSetVertexShader(CompileShader(vs_4_0, VS()));SetPixelShader(CompileShader(ps_4_0, PS()));should beSetVertexShader(CompileShader(vs_4_0, DefaultVS()));SetPixelShader(CompileShader(ps_4_0, DefaultPS()));in result. buggy HLSL code can cause D3DX10CreateEffectFromFile to fail.;  Yes, see my code, to see what you can do against that:ID3D10Blob* ShaderBlob=NULL;ID3D10Blob*Blob_Errors=NULL;//Precompile the shader and check for errors HRESULT hr=D3DX11CompileFromFile(L"TempShader.fx", NULL, NULL,NULL, "fx_5_0",D3D10_SHADER_OPTIMIZATION_LEVEL3 | D3D10_SHADER_ENABLE_STRICTNESS, NULL, NULL, &ShaderBlob,&Blob_Errors,NULL);if(Blob_Errors){if(!ShaderBlob){MessageBoxA(NULL,(char *)Blob_Errors->GetBufferPointer(),"There are errors in that fx file!",MB_OK | MB_ICONERROR | MB_TOPMOST);break;}else{MessageBoxA(NULL,(char *)Blob_Errors->GetBufferPointer(),"There are warnings in that fx file!",MB_OK | MB_ICONWARNING | MB_TOPMOST);}Blob_Errors->Release();break;}else{...I use DX11 and precompile the shader, but the ErrorBlob parameter is there in your function, too :)   ;Quote:Original post by numerical25Figured it outSetVertexShader(CompileShader(vs_4_0, VS()));SetPixelShader(CompileShader(ps_4_0, PS()));should beSetVertexShader(CompileShader(vs_4_0, DefaultVS()));SetPixelShader(CompileShader(ps_4_0, DefaultPS()));in result. buggy HLSL code can cause D3DX10CreateEffectFromFile to fail.Yep. One of the parameters to D3DX10CreateEffectFromFile is an ID3D10Blob*. It's used to return an optional error message. Generally you'll try to deal with such errors gracefully (i.e., not crashing your program) and report them in a log file or something.   ;Quote:Original post by AristeQuote:Original post by numerical25Figured it outSetVertexShader(CompileShader(vs_4_0, VS()));SetPixelShader(CompileShader(ps_4_0, PS()));should beSetVertexShader(CompileShader(vs_4_0, DefaultVS()));SetPixelShader(CompileShader(ps_4_0, DefaultPS()));in result. buggy HLSL code can cause D3DX10CreateEffectFromFile to fail.Yep. One of the parameters to D3DX10CreateEffectFromFile is an ID3D10Blob*. It's used to return an optional error message. Generally you'll try to deal with such errors gracefully (i.e., not crashing your program) and report them in a log file or something.I'm a newb, but I will manage to do that one of these days. When I feel confortable enough with directX, I will setup more effective systems. 