/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2009.
     ssss    gggg x   x         Steven Goodwin. All Rights Reserved.
    
This version has been released under the GNU Public License v2.0.

Please see the license files for details.

File: sgx/src/skeleton/wintel32/game/wintel32gameskeleton.cpp

*/

#include "drivers/wintel32/graphics/graphics.hpp"
#include "skeleton/game/game.hpp"


class CloseDownHandler : public sgxGraphicsEngineCallbackHandler {
public:
	virtual tBOOL onGraphicsEngineClosed() {
		//CSGXManagementEngine::get()->release();
		exit(0);
		return TRUE;
	}
};
static CloseDownHandler *pHandler;

void exit_game() {
	CWin32OpenGLEngine::getOpenGL()->stopEngine();
}

void run_game(cb_pUpdateFunction *pUpdate, tMEM_SIZE param)
{
	cb_pOpenGLIdleFunction *cb = (cb_pOpenGLIdleFunction *)pUpdate;

	CSGXGraphicsEngine::get()->setCallbackHandler(pHandler = new CloseDownHandler());

	CWin32OpenGLEngine::getOpenGL()->runEngine(cb, param);
}
