Jump to content
  • Advertisement
Sign in to follow this  
Drats

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.

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

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 this post


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


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 problem

hr = 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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by Drats
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 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 Drats
I 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 this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by Buckeye

The 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 Present
The program '[3820] Terrain.exe: Native' has exited with code 0 (0x0).


any reason why that might be?

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!