Direct3D9: (ERROR) :GetClientRect Failed

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

Recommended Posts

Hi I am creating some simple terrain and get these weird runtime errors. There was another thread where the gentleman was getting the same problem and the suggestion was that the message handling loop might be faulty. My loop is

while(msg.message != WM_QUIT)
{
if(::PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
else
{
app.Render();

}
}


When I run it through the debugger, the errors that come up are: Direct3D9: (ERROR) :GetClientRect Failed ? Direct3D9: (ERROR) :GetClientRect Failed ? Direct3D9: (ERROR) :BitBlt or StretchBlt failed in Present Any ideas on what the problem might be?

Share on other sites
I had a similar problem. Try the code below and let me know how it goes.

while(1)	{		if(::PeekMessage(&msg, 0, 0, 0, PM_REMOVE))		{                        if(msg.message == WM_QUIT)                            break;			::TranslateMessage(&msg);			::DispatchMessage(&msg);		}		else                  {							app.Render();		                  }          }

Share on other sites
Post the section of code in which the first error occurs, indicating the line that results in the error.

Do you check the return codes from your DirectX calls for success or failure?

Share on other sites
The Debugger does not give a specific line of code where the error occurs.

I checked the DirectX call and there is no problem there , the D3DDevice is created successfully.

@boolean010 , I tried your code but i get the same errors.

Any other suggestions? Thanks.

Share on other sites
This is usually caused by rendering to a windows that's been destroyed. Make sure that after your DestroyWindow() call you never make a Present() call.

Also, it's not a good idea to have your main loop like that; you should clear all pending messages and then render once, not handle one message then render. If rendering causes a new message to be sent to your window, you'll gradually fill up your message queue and then Bad Things will happen.

EDIT: Err, ignore that last bit; I'm talking bollocks [smile]

[Edited by - Evil Steve on July 21, 2008 5:46:36 AM]

Share on other sites
Quote:
 The Debugger does not give a specific line of code where the error occurs.

The specific line where the error occurs is for you to determine by setting breakpoints in your code. If you're unfamiliar with that, take a look at introduction to debugging and Debug Runtime.

Quote:
 I checked the DirectX call

In the initial phase of writing your application, you should be checking return codes from just about every DirectX call, not just one. You can use the macro FAILED(HRESULT hr) or SUCCEEDED(hr), depending on your need.
HRESULT hr;if(SUCCEEDED(pDevice->BeginScene()) {  .. render} else MessageBox(NULL,"BeginScene Failed","Device Error",MB_OK);// or use hr to display the problemhr = pDevice->Present(0,0,0,0);if(FAILED(hr)) MessageBox(NULL,DXGetErrorDescription(hr),"Present Failed",MB_OK);

EDIT: Your run loop looks okay to me. It appears you clear all the messages before rendering.

[Edited by - Buckeye on July 21, 2008 8:34:29 AM]

Share on other sites
Interestingly the .exe file that is produced in the application folder as a result of running the program, runs absolutely fine. The terrain is created and displayed properly. So its only when attempting to run the program that those errors are thrown up.

I checked the error codes from the DirectX calls but they all return correctly.

Share on other sites
Quote:
 Original post by DratsInterestingly the .exe file that is produced in the application folder as a result of running the program, runs absolutely fine. The terrain is created and displayed properly. So its only when attempting to run the program that those errors are thrown up.
I bet those errors only happen on the last frame of your app - as I said above, you're probably destroying your window and then rendering.

In your window message pump, you'll get a WM_DESTROY message, which will kill your window, then on the next run through your main loop you'll call Render(), despite your window already being obliterated.

Quote:
 Original post by DratsI checked the error codes from the DirectX calls but they all return correctly.
No, Present() is failing - that's what the message says. If you're checking the return value by calling MessageBox() if it's FAILED(), then you'll never see the message box after calling PostQuitMessage, because that kills your applications modal loop (MessageBox ceases to function after you've called PostQuitMessage).

Share on other sites
Quote:
 I checked the error codes from the DirectX calls but they all return correctly.

Do you check the return codes from every DirectX call? LoadTexture? Present? etc.?

The fact that the exe runs from outside Studio indicates that you probably aren't setting the path correctly when you load something. When you run the program from within Studio, it sets up the working directory differently than when you start it from Windows. However, that may not be the problem with the code, only a result of it.

You need to find the code line where the first error occurs. Then you need to determine what's wrong with the code in that line.

You should step through the code in debugging mode to determine in which line the first error occurs.

EDIT: Evil Steve has it right. <-------

Share on other sites
Quote:
 Original post by BuckeyeThe fact that the exe runs from outside Studio indicates that you probably aren't setting the path correctly when you load something.

You were right. The images I was loading up were not in the same directory. I corrected that and the program now runs perfectly from VS.

However when I terminate the program the output in the debug window still shows the same 3 errors.
Direct3D9: (ERROR) :GetClientRect Failed ?Direct3D9: (ERROR) :GetClientRect Failed ?Direct3D9: (ERROR) :BitBlt or StretchBlt failed in PresentThe program '[3820] Terrain.exe: Native' has exited with code 0 (0x0).

any reason why that might be?

1. 1
Rutin
49
2. 2
3. 3
4. 4
5. 5

• 10
• 28
• 20
• 9
• 20
• Forum Statistics

• Total Topics
633410
• Total Posts
3011727
• Who's Online (See full list)

There are no registered users currently online

×