while(msg.message != WM_QUIT)
{
if(::PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
else
{
app.Render();
}
}
🔒 Locked
Direct3D9: (ERROR) :GetClientRect Failed
Advertisement
Original Post
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 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?
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(); } }
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]
EDIT: Err, ignore that last bit; I'm talking bollocks [smile]
[Edited by - Evil Steve on July 21, 2008 5:46:36 AM]
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]
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.
I checked the error codes from the DirectX calls but they all return correctly.
Quote: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.
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.
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: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).
Original post by Drats
I checked the error codes from the DirectX calls but they all return correctly.
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. <-------
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 PresentThe program '[3820] Terrain.exe: Native' has exited with code 0 (0x0).any reason why that might be?
Quote:
Original post by Drats
However when I terminate the program the output in the debug window still shows the same 3 errors.
*** Source Snippet Removed ***
any reason why that might be?
Quote:
Original post by Evil Steve Quote: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.
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.
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: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).
Original post by Drats
I checked the error codes from the DirectX calls but they all return correctly.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement