Skip to main content
GameDev.net gamedev.net
🔒 Locked

Need help with D3DXCreateEffectFromFile [SOLVED]

Started by D3DXVECTOR3 Aug 9, 2005 at 5:59 PM 6 replies 3.2k views
Original Post
D3DXVECTOR3
D3DXVECTOR3
Im having a strange situation. A week ago reinstalled my PC and installed the April SDK. Befor that I used the Februari SDK. Now i, having some strange errors/problems. I did change a few things in the code but its not much.

LPD3DXBUFFER l_d3dBuffer;

file is type std::string and has a valid path to the effect. the effect is not compiled (i have always used it for quick editing) "loading.fx"

// Create the effect
if FAILED(D3DXCreateEffectFromFile(pd3dDevice, file.c_str(), NULL, NULL, 0, NULL, &m_pd3dEffect, &l_d3dBuffer))
{
	// Show Error message
	MessageBox(NULL, (const char *)l_d3dBuffer->GetBufferPointer(), "Critical Failure", MB_OK);

}


D3DXCreateEffectFromFile fails and d3dBuffer is NULL(0x00000000) so I cant even see what the error message is. The program crashes at MessageBox(); [SOLVED] I dont know how/when/why but the "Working directory" was set to default and i use an \OutPut\.. [Edited by - D3DXVECTOR3 on August 10, 2005 6:10:49 PM]
superpig
superpig
What HRESULT does D3DXCreateEffectFromFile() return?
Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse
D3DXVECTOR3
D3DXVECTOR3
HRESULT returns D3DXERR_INVALIDDATA.

edit: btw im using Visual Studio 2003 with Windows 2000, but I already tested it on a machine with Windows XP and it had no effect same result.

[Edited by - D3DXVECTOR3 on August 9, 2005 6:18:14 PM]
DrGUI
DrGUI
Since it's returning INVALIDDATA I would assume that your effect file is invalid - does your effect compile without errors in EffectEdit (comes with the DX SDK)?

Though I thought usually it would return the errors in your l_d3dBuffer buffer :S

I use Managed DirectX, but I'll take a guess at maybe having to intialize your buffer before passing it in?

As for the crash at your message box, you probably need to check whether l_d3dBuffer is non-null before trying to get it's pointer.

Hope that helped...
DrGUI
DrGUI
OOo sorry, you said it worked with the Feb SDK so your effect file is probably fine...but I remember that in Managed DirectX when I moved from the Feb SDK to April, a new parameter called skipConstants was added to the Effect constructor. So the parameters to the function you're using might have changed so you might be using the wrong overload now..maybe..
D3DXVECTOR3
D3DXVECTOR3
^^ That could be it. FX Composer and EffectEdit compiles the effect file with no problems.

This is what the current SKD shows:
HRESULT WINAPI D3DXCreateEffectFromFile(
LPDIRECT3DDEVICE9 pDevice,
LPCTSTR pSrcFile,
const D3DXMACRO *pDefines,
LPD3DXINCLUDE pInclude,
DWORD Flags,
LPD3DXEFFECTPOOL pPool,
LPD3DXEFFECT *ppEffect,
LPD3DXBUFFER *ppCompilationErrors
);

Anyone have the definition from the feb SDK!?
D3DXVECTOR3
D3DXVECTOR3
I think I have found the problem. I should have seen this. Yesterday I noticed that my logger didnt work anymore while I didnt change anything in it. When I was about to rip my hairs from my head I noticed that all my file IO didnt work. So looks like a folder/user security issue. There is nothing wrong with my code.

Edit:

Nope that was not it. i think im gonna have to try the old SDK

[Edited by - D3DXVECTOR3 on August 10, 2005 6:05:00 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.