Jump to content
  • Advertisement
Sign in to follow this  
Drats

Create D3D device error

This topic is 3810 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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)?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
Hah! Missed it the first couple times around.

It should be:

CreateDevice(..., &m_pDevice);

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!