| | |
LPDIRECT3DDEVICE9 ... failed?
Please support our Game Development advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Jun 2009
Posts: 10
Reputation:
Solved Threads: 0
Hey All
I am trying to create a DLL to handle some directx for me. But it seems to be acting up. If you take a look at the picture below you will see that the LPDIRECT3DDEVICE9 d3ddev; pointer is not being created? While at the same time, the D3DPRESENT_PARAMETERS d3dpp; is.
http://www.exsolved.com/media/d3d.jpg
The directx header is being included at the top of the file like so:
Everything else directx wise works except for
Is there a reason LPDIRECT3DDEVICE9 d3ddev; & LPDIRECT3D9 d3d; are not being created?
Thanks a ton.
I am trying to create a DLL to handle some directx for me. But it seems to be acting up. If you take a look at the picture below you will see that the LPDIRECT3DDEVICE9 d3ddev; pointer is not being created? While at the same time, the D3DPRESENT_PARAMETERS d3dpp; is.
http://www.exsolved.com/media/d3d.jpg
The directx header is being included at the top of the file like so:
#include <d3d9.h> #pragma comment (lib, "d3d9.lib")
Everything else directx wise works except for
LPDIRECT3D9 d3d; LPDIRECT3DDEVICE9 d3ddev;
Is there a reason LPDIRECT3DDEVICE9 d3ddev; & LPDIRECT3D9 d3d; are not being created?
Thanks a ton.
You're just creating a pointer variable without actually setting it to anything, so what you're getting is 'worse' than a null pointer, it's a pointer to some random location. The message in the screenshot is caused by the debugger trying to treat whatever's at that random location as a direct3d device, which it almost certainly isn't.
You have to call a function (and I don't remember which one) to actually create and return a direct3d device, then store a pointer to it in a LPDIR...CE9 variable.
Are you following a tutorial or trying to assume/guess how to do things? I would suggest looking at some working source code that uses the API before trying to use it yourself.
You have to call a function (and I don't remember which one) to actually create and return a direct3d device, then store a pointer to it in a LPDIR...CE9 variable.
Are you following a tutorial or trying to assume/guess how to do things? I would suggest looking at some working source code that uses the API before trying to use it yourself.
Plato forgot the nullahedron..
•
•
Join Date: Jun 2009
Posts: 10
Reputation:
Solved Threads: 0
No, I believe I am setting it to something, but during that setup its failing. Here's the exact function taken straight out the DLL source code:
However, it keeps crashing everytime d3ddev is called... usually crashing at the line:
So I added a breakpoint just above that line, and when hovering over d3ddev, it says "iUnknown {...}".
Any ideas mate?
Thanks
extern "C" e2api void initDirectX(HWND &handle, int windowed, int width, int height)
{
d3d = Direct3DCreate9(D3D_SDK_VERSION);
D3DPRESENT_PARAMETERS d3dpp;
LPDIRECT3D9 d3d;
LPDIRECT3DDEVICE9 d3ddev;
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = windowed;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = handle;
d3d->CreateDevice(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
handle,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp,
&d3ddev);
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 40, 100), 1.0f, 0);
d3ddev->BeginScene();
d3ddev->EndScene();
d3ddev->Present(NULL, NULL, NULL, NULL);
}However, it keeps crashing everytime d3ddev is called... usually crashing at the line:
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 40, 100), 1.0f, 0);
So I added a breakpoint just above that line, and when hovering over d3ddev, it says "iUnknown {...}".
Any ideas mate?
Thanks
Ah ok. There shouldn't be any problem with doing what you're doing from a DLL. I have only ever written DX applications that are staticly linked and DLLs that don't do anything DX, so I don't know for sure if there are any specific issues with DX calls in DLLs, but I would think that it's unlikely to be a problem.
What is the return value from CreateDevice?
What is the return value from CreateDevice?
Plato forgot the nullahedron..
•
•
Join Date: Jun 2009
Posts: 10
Reputation:
Solved Threads: 0
I'm not sure how I check that directly, but I added a breakpoint just below the call, and checked d3d as that's holding CreateDevice's return value (I believe), and it's saying the same thing as d3ddev.. "__vfptr = CXX0030: Error: expression cannot be evaluated". So I think the problem is the CreateDevice function itself. Either I am calling it incorrectly, or one or more of its arguments are not quite there.
The function call CreateDevice returns a HRESULT (error code), so do:
the possible values are defined as D3D_OK, D3DERR_DEVICELOST, D3DERR_INVALIDCALL, D3DERR_NOTAVAILABLE, D3DERR_OUTOFVIDEOMEMORY ( see http://msdn.microsoft.com/en-us/libr...3(VS.85).aspx).
So do something like:
Just to find out what (if anything) DX thinks is going wrong.
HRESULT result = CreateDevice (...);
the possible values are defined as D3D_OK, D3DERR_DEVICELOST, D3DERR_INVALIDCALL, D3DERR_NOTAVAILABLE, D3DERR_OUTOFVIDEOMEMORY ( see http://msdn.microsoft.com/en-us/libr...3(VS.85).aspx).
So do something like:
switch ( result ) {
case D3DERR_DEVICELOST: std::cerr << "device lost"; break;
... etc ...
}Just to find out what (if anything) DX thinks is going wrong.
Last edited by MattEvans; Jul 5th, 2009 at 10:53 am.
Plato forgot the nullahedron..
Just FYI, the __vfptr = CXX0030 thing is because the debugger thinks that d3ddev is pointing to an actual instance of a D3D device, if there's some error in the call to CreateDevice, and for whatever reason the device isn't created, then the pointer doesn't get assigned a value, and it'll have an 'undefined' value (since you don't initialize the pointer to anything). Basically, if you declare & initialize d3ddev like:
Then, should the CreateDevice call fail to initialize that variable, the debugger will give a less confusing message, i.e. it will report d3ddev as still being NULL (and it shouldn't try to dereference it and complain about a bad virtual function table, which is what that __vfptr is all about)
LPDIRECT3DDEVICE9 d3ddev = NULL;
Plato forgot the nullahedron..
![]() |
Similar Threads
- Disk Access: Sense Operation Failed (Windows NT / 2000 / XP)
- msurl.exe DLL Initialization failed (Viruses, Spyware and other Nasties)
- Floppy test failed! (Windows NT / 2000 / XP)
- s.m.a.r.t. command failed (Windows 95 / 98 / Me)
- How delete failed W2000 installation (Windows NT / 2000 / XP)
- Iexplore.exe application failed?? (Web Browsers)
- Win XP - Application Failed to Initialize (Windows NT / 2000 / XP)
- Tried to install Panther. Failed (OS X)
Other Threads in the Game Development Forum
- Previous Thread: Dark GDK
- Next Thread: Want an advise with u guyz help me..
| Thread Tools | Search this Thread |
3d advertising ai algorithm ban c++ cambridge camera censorship china competition console development engine fov fpx game gamer games gaming gauntanamo government idaho in-gameadvertisement intellectualproperty l-systems laracroft lindenmayer live manhunt math mathematics matrix mercenaries microsoft mmorpg modded msn naked news nintendo obama opengl palin physics pirate playstation politics projection ps3 rpg search selection software sony stephenhawking stocks studio technology terrorism tombraider uk videogame web wii world-of-warcraft xbox xbox-live xbox360






