Create D3D device error
Hi,
I am getting a runtime error when attempting to create the D3D device.
The piece of code is
m_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
m_hWnd, CreateFlags, &d3dpp, m_pD3DDevice );
m_pD3D is the Direct 3D object.
The handle to the window m_hWnd comes as being 'unused' whatever that means.
I have created another project with the same code and everything works fine.
Could anyone suggest what the runtime error might be about.
You can check with IsWindow(m_hwnd) prior to the call. I assume you check the validity of the window handle when you create it prior to creating the device.
Post the actual text of the error message rather than just a description. There should be an error code involved somewhere.
Post the actual text of the error message rather than just a description. There should be an error code involved somewhere.
What is the exact error message?
What do the debug runtimes tell you?
Have you stepped through the program with the debugger and made sure nothing funny is going on?
Do you do proper error checking (e.g., checking if CreateWindow(Ex) returns NULL)?
What do the debug runtimes tell you?
Have you stepped through the program with the debugger and made sure nothing funny is going on?
Do you do proper error checking (e.g., checking if CreateWindow(Ex) returns NULL)?
I checked with IsWindow(m_hwnd) prior to the call and it turned up okay so I presume the handle to the window is alright. The error message that comes up is
First-chance exception at 0x0042781d in Game Engine.exe: 0xC0000005: Access violation reading location 0x00000000.
Unhandled exception at 0x0042781d in Game Engine.exe: 0xC0000005: Access violation reading location 0x00000000.
First-chance exception at 0x0042781d in Game Engine.exe: 0xC0000005: Access violation reading location 0x00000000.
Unhandled exception at 0x0042781d in Game Engine.exe: 0xC0000005: Access violation reading location 0x00000000.
Looks like you are dereferencing a NULL pointer. Maybe m_pD3D is NULL?
Also, are you using the debug runtimes?
Finally, I will repeat my recommendation to use the debugger. You might see something you didn't expect (like a pointer being NULL when it shouldn't be).
Also, are you using the debug runtimes?
Finally, I will repeat my recommendation to use the debugger. You might see something you didn't expect (like a pointer being NULL when it shouldn't be).
Mandatory linkage.
You need to be checking the return values of all of your important functions, where "important" means any function that returns data that you then rely on. That means functions like CreateDevive(), CreateVertexBuffer(), D3DXCreateTextureFromFile(), GetCaps(), etc.
If you don't check the return code, and the function fails, you're extremely likely to get a crash, or your code just not working (I.e. nothing being rendered) on some hardware.
You need to be checking the return values of all of your important functions, where "important" means any function that returns data that you then rely on. That means functions like CreateDevive(), CreateVertexBuffer(), D3DXCreateTextureFromFile(), GetCaps(), etc.
If you don't check the return code, and the function fails, you're extremely likely to get a crash, or your code just not working (I.e. nothing being rendered) on some hardware.
Oops sorry it is "&m_pDevice" in the actual program. My bad.
Could you tell me how do I use the debugger? Is there like a a guide on the net that could perhaps tell me?
Thanks.
Could you tell me how do I use the debugger? Is there like a a guide on the net that could perhaps tell me?
Thanks.
Quote:Original post by Drats
Could you tell me how do I use the debugger? Is there like a a guide on the net that could perhaps tell me?
Yes there is.
Quote:it is "&m_pDevice" in the actual program
Uh.. you do realize people are taking the time to try to help you, right?
Rather than posting "I have a problem and my code looks something like this. What's wrong?" - post your actual code. Solutions will definitely come faster.
BTW, where did the info that the window is "unused" come from? That may be significant also.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement