This site is no longer active and is available for archival purposes only. Registration and login is disabled.

GetDisplay cause a crash? Help!


GetDisplay cause a crash? Help!

Postby telamon » Mar 30, 2003 @ 10:25pm

I've been fiddling with PocketFrog over spring break, writing a little moon lander game. Overall I love the library - it's powerful and easy to use.

In my game I have a main menu screen and a game play scene and I think my state management between the two is buggy. Sometimes when the game is initializing the new level (which is randomly generated), it will crash when trying to get the display pointer. This, I don't really understand. Is there anytime after GameInit has been called that GetDisplay won't return a valid pointer? Has anyone run into similar problems? I'm hoping that a refactoring of the state management code will fix everything, but this has been one hell of a bug to track down - so any suggestions would be greatly appreciated. Thanks!!!

For reference

In my code, I'm trying to execute:
DisplayDevice* display = GetDisplay();
display->SetRenderTarget(m_landscape);
display->Clear( Color(0,0,0) );

Which sometimes will cause an exception here (and deeper in the display driver internals):
DisplayDevice* Game::GetDisplay()
{
DisplayDevice* display = m_display.get();

if (display)
display->BeginScene();

return display;
}
--------------------------------
Let be be finale of seem, seems to me.
--------------------------------
User avatar
telamon
pm Member
 
Posts: 20
Joined: Mar 30, 2003 @ 10:16pm


Postby adde » Mar 30, 2003 @ 11:02pm

You got to give us more to go on.. For instance, what sort of exception is thrown? And what line (action/function) caused this..

If I understood your post correctly, it's the display->Clear() that causes the exception, and that could be because the rendered target (m_landscape) is not valid.

I'm pretty shure it's not the GetDisplay() function that causes the error because all it does is return the pointer to the DisplayDevice object (and calls BeginScene() if the pointer is valid).
User avatar
adde
pm Member
 
Posts: 152
Joined: Oct 9, 2002 @ 1:42pm
Location: Stockholm / Sweden


ARG...

Postby telamon » Mar 31, 2003 @ 8:42am

Actually, does appear that the GetDisplay function is the thing throwing the exception (it's a "first-chance exception" - an access violation). I took another crack at it today with the debugger, and when I openned up the Game object that my game inherits from, the m_display pointer in it was invalid! (The debugger had garbage information in all the m_display fields - I set a breakpoint at the place where the program crashes (it's only invalid sometimes) and when it doesn't crash, the m_display pointer in the Game object points to a valid DisplayDevice). In fact, the entire Game object that the this pointer in my code points to is bad. So it would seem that I somehow corrupted the internal state of the Game object. How could this possibly happen?

The actual thing that it doesn't like is the if test in:
void DisplayDevice::BeginScene()
{
if (!m_bInScene)
{
Pixel* pixels = m_driver->BeginScene();

// We set the video pointer each frame. Currently, I don't know of any
// device where the pointer can change while running, but you never
// know what will appear (ex: DMA transfers with multiple buffers).
m_GAPIBuffer->SetVideo( pixels );

m_bInScene = true;
}
}
--------------------------------
Let be be finale of seem, seems to me.
--------------------------------
User avatar
telamon
pm Member
 
Posts: 20
Joined: Mar 30, 2003 @ 10:16pm


Postby adde » Mar 31, 2003 @ 12:24pm

User avatar
adde
pm Member
 
Posts: 152
Joined: Oct 9, 2002 @ 1:42pm
Location: Stockholm / Sweden


Return to PocketFrog & PocketHAL


Sort


Forum Description

SDKs for fast and robust device-independent access to Pocket PC display hardware.

Moderators:

sponge, Kzinti

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron