cannot retrieve effect.fx file
Posted
by numerical25
on Stack Overflow
See other posts from Stack Overflow
or by numerical25
Published on 2010-05-23T23:48:20Z
Indexed on
2010/05/23
23:50 UTC
Read the original article
Hit count: 331
I am having issues loading my effect.fx from directx. When I step into my application, my ID3D10Effect *m_pDefaultEffect; pointer remains empty. the address remains at 0x000000
below 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 implementation
bool 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)
© Stack Overflow or respective owner