Posted: 25th Aug 2011 2:40
how do you go to the app end or exit from the app::Loop()

i tried
app::End();
but the app does not end;

void app::End ( void )
Posted: 25th Aug 2011 3:18
how do you go to the app end or exit from the app::Loop()

i tried
End();
but the app does not end;
it goes to app::End() where I clean up a few things but the program still runs in end.

void app::End ( void )
Posted: 25th Aug 2011 3:41
The mobile devices normally wait for a home button press to signal the end of an app. On Windows you can force an exit by using the PostQuitMessage(0); command.
Posted: 25th Aug 2011 23:30
I couldn't find the ability to do it, so I added it in myself...

Within my app class, I added private var 'running' and the methods: 'Terminate' and 'IsRunning',
+ Code Snippet
class app {
public:
    unsigned int m_DeviceWidth;
    unsigned int m_DeviceHeight;
    
private:
    int running;
    
public:
    app() {
        memset(this, 0, sizeof(app));
        running = 1;
    }
    
    void Begin(void);
    void Loop(void);
    void End(void);
    
    void Terminate(void) { running = 0; }
    int IsRunning(void) { return running; }
};


Within Core.mm I modified the loop condition...
From:
+ Code Snippet
while (!done && glfwGetWindowParam(GLFW_OPENED))


To:
+ Code Snippet
while (!done && glfwGetWindowParam(GLFW_OPENED) == GL_TRUE && App.IsRunning())


Then when I wish to exit, I just call Terminate on my App
+ Code Snippet
App.Terminate();


Hope this helps,
Liam Goodacre
Posted: 1st Sep 2011 2:30
Hi,

Also if you look at the apps\interpreter source (Tier 2 C++), you will see I have an AppForceQuit call in coreforapp.h which services me very well to keeping platform specific code away from the main CPP file of my app. Adding to the core.cpp is also fine, but I find I like to keep my core.cpp generic so I can move it from one Windows project to another.