PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Why cannot re-initialize in same session?

I have the following init code and shutdown code for my project and if I shutdown I cannot re-init right after, If I exit my program and go back in, it works:

Code:
bool gapi_Init (HWND hWnd, LPVOID DrawFrame, int orientation, bool fullscreen)
{
if (fullscreen)
{
app *a = NULL;
windows *w = SearchWindow(hWnd, a);
SHSipPreference(hWnd, SIP_FORCEDOWN);
if (w->m != NULL)
ShowWindow(w->m, SW_HIDE);

dwWidth = 240;
dwHeight = 320;
if (orientation == Frog::ORIENTATION_WEST || orientation == Frog::ORIENTATION_EAST)
{
dwWidth = 320;
dwHeight = 240;
}

SetForegroundWindow(hWnd);
MoveWindow(hWnd, 0, 0, dwWidth, dwHeight, false);

SHFullScreen(hWnd, SHFS_HIDETASKBAR);
SHFullScreen(hWnd, SHFS_HIDESIPBUTTON);
SHFullScreen(hWnd, SHFS_HIDESTARTICON);
}

// Init Display
m_display.reset(Frog::PocketPC::CreateDisplay(hWnd, (Frog::Orientation)orientation, 0));
if (!m_display.get())
return false;

m_display->SetDithering(Frog::DisplayDevice::DITHER_FAST );

if (m_rast == NULL)
m_rast = m_display->CreateRasterizer(m_display->GetBackBuffer());

// Init input
m_input.reset(Frog::PocketPC::CreateInput(hWnd, (Frog::Orientation)orientation));
if (!m_input.get())
return false;

gapi_wnd = hWnd;
_DrawFrame = DrawFrame;
FPSLastTime = Frog::PocketPC::GetTickCount();
FPSCounter = 0;
SetTimer(hWnd, GAPI_TIMER, 0, NULL);

return true;
}

void gapi_Shut (HWND hWnd)
{
ClearS();
m_input.reset();
m_display.reset();

gapi_wnd = 0;
_DrawFrame = NULL;
KillTimer(hWnd, GAPI_TIMER);

SHFullScreen(hWnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON);
app *a = NULL;
windows *w = SearchWindow(hWnd, a);
if (w->m != NULL)
ShowWindow(w->m, SW_SHOW);
}



Anybody know why?

Regards,
Kornalius
Anyone have this problem of not being able to re-initialize the PocketFrog display?

Regards,
Kornalius
Thierry maybe you can help me?

Regards,
Kornalius
Sorry to bump this again, but I really to get this fixed for my next version of PPL. Maybe somebody can tell me how to delete and re-initialize these objects:

Frog::scoped_ptr<Frog::DisplayDevice> m_display;
Frog::scoped_ptr<Frog::InputDevice> m_input;
Frog::Rasterizer *m_rast = NULL;


I tried:

delete m_display

But this doesn't work, I get a compiler error.

m_display.reset() works but I cannot re-initialize the m_rast after. Kinda weird. The error is here:

m_rast = m_display->CreateRasterizer(m_display->GetBackBuffer());

It crashes in the GetBackBuffer(). It tries to do a GXBeginDraw() in BeginScene().

Regards,
Kornalius
Anyone?
If I remember correctly, you have two things to do:

1) Call PocketPC::Shutdown() or something similar. Look up how the framework shuts down.

2) Modify PocketPC. There is a problem with pointers not being reset to 0 for the display and input drivers.

Someone already discussed this a few months ago and got it working.

BTW, posting tons of replies won't get you help any faster.
Thanks Thierry,

I don't see a PocketPC::ShutDown() anywhere Thierry. Can you tell me maybe how I can delete the objects m_display ...

I checked the Game.cpp Shutdown() and all it does is:

m_input.reset();
m_display.reset();

But then when I try to create a rasterizer on the GetBackBuffer it crashes.

Sorry about the multiple replies but I really need to get this thing fixed ASAP. It seems like this topic is scaring everybody. I have seen other posts about this with 0 replies, so I figured I had to push to get some answers.

Sorry again,
Kornalius
Oh sorry you are right, there is no PocketPC::Shutdown. I guess you will need to add it.

The problem is with the two following variables (in PocketPC.cpp):

Code:

DisplayDriver* l_displayDriver; //fixme: leak at exit
InputDriver* l_inputDriver; //fixme: leak at exit


See the comments? =) You will have to create a Shutdown() function in PPC that destroy these two objects and set them back to NULL.

In Game::Shutdown() after the two pointer resets(), you want to call PocketPC::Shutdown(). This should do it. After that you can reinitialize everything.
Thanks Thierry, I will try it out and let you know the results.

Regards,
Kornalius
Just out of curiosity, what circumstances are causing you to want to re-init these in the first place?
PocketFrog is used within my PPL language. And the language comes with a main program that allow you to run other ppl files from there. Now running a (ppl) game once is perfect but then running it a second time it crash. Users should not have to exit PPL.exe in order to run there game twice (testing and debugging that is).


Btw, I made to changes to PocketPC.h and PocketPC.cpp but how do I rebuild the libraries? I see no workspace included with the PocketFrog archive.

Regards,
Kornalius.
Look again, the workspace/project files are there.
Ah, I see. Very interesting!
Damn it, I just saw them, IN THE MAKE DIRECTORY! :? Sorry about that! :D

I am using stlport 4.5.3 but I get the following error:

C:\PPL\STLPORT-4.5.3\STLPORT\stl/_auto_ptr.h(60) : error C2059: syntax error : 'end of file'

Line is:

Code:
_Tp* get() const { return __REINTERPRET_CAST(_Tp*,__CONST_CAST(void*,_M_p));}


Anybody has seen this error before "end of file" ???

Regards,
Kornalius
Hi,

I am still getting this error ^^^. I did everything from the FAQ's and I obviously searched here. I get the same error in STL 4.0 but here:

C:\STLPORT-4.0\STLPORT\memory(92) : error C2059: syntax error : 'end of file'

I am using eVc++ 3. It is a fresh copy of eVc 3 and a fresh copy of both STL 4.0 and STL 4.5.3.

I am really desperate now, it's been 2 weeks and I cannot get PF to build properly. Am I missing something in my eVc setup?

Regards,
Kornalius