|
|
下面的程序可以运行但怎么检测不到esc键呢?目的是按esc退出。
#include "ExampleApplication.h"
#include "ExampleFrameListener.h"
class myListener: public ExampleFrameListener {
public:
myListener (RenderWindow* win, Camera* cam)
:ExampleFrameListener (win, cam, false, false) {}
bool frameStarted (const FrameEvent& evt)
{
//if (!mKeyboard->buffered())
if (processUnbufferedKeyInput (evt) == false)
return false;
return true;
}
bool processUnbufferedKeyInput(const FrameEvent& evt)
{
if (mKeyboard->isKeyDown (OIS::KC_Q))
return false;
return true;
}
};
class myExample: public ExampleApplication {
void createScene () {}
#if 1
void createFrameListener ()
{
mFrameListener = new myListener (mWindow, mCamera);
mRoot->addFrameListener (mFrameListener);
}
#endif
};
#include "windows.h"
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, int)
{
myExample app;
try {
app.go();
} catch( Exception& e ) {
MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!",
MB_OK | MB_ICONERROR | MB_TASKMODAL);
}
return 0;
}
|
|