Original Post
Hi! I'm new to DirectX and was trying to put the basic initialization stuff in some classes. So I have a gfx_core class which has a IDirect3DDevice9* pD3DDevice9 declared as private and a "IDirect3DDevice9* GetDevice()" method (public of course). Then theres a sprite and a texture class. Inside this texture class I try to load a texture as followed: In gfx_core: GFX is a singleton object to my mentioned gfx_core class. The program crashes with an unhandled exception because D3DXCreateTextureFromFileEx returns false. It seems to me that this GFX->GetDevice stuff doesn't work or rather IDirect3DDevice doesn't like to get passed via methods returning that deviceobject. I bet it would work if I do the textureloading inside my gfx_core class which holds the device object. I'm getting desperate.
LPDIRECT3DTEXTURE9 pD3DTexture;
D3DXIMAGE_INFO SrcInfo;
D3DCOLOR colorkey = 0xFFFF00FF;
if(FAILED(D3DXCreateTextureFromFileEx(GFX->GetDevice(), "metal.png", 0, 0, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED,
D3DX_FILTER_NONE, D3DX_DEFAULT, colorkey, &SrcInfo, NULL, &pD3DTexture))) {
//error handling
}
IDirect3DDevice9* GetDevice() {
return pD3DDevice9;
}