本文整理汇总了C++中WindowApplication::OnTerminate方法的典型用法代码示例。如果您正苦于以下问题:C++ WindowApplication::OnTerminate方法的具体用法?C++ WindowApplication::OnTerminate怎么用?C++ WindowApplication::OnTerminate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WindowApplication
的用法示例。
在下文中一共展示了WindowApplication::OnTerminate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Terminate
//----------------------------------------------------------------------------
static void Terminate ()
{
WindowApplication* theApp =
(WindowApplication*)Application::TheApplication;
if (theApp)
{
theApp->OnTerminate();
glutDestroyWindow(theApp->GetWindowID());
Renderer* renderer = (Renderer*)theApp->GetRenderer();
delete0(renderer);
}
}
示例2: Main
//.........这里部分代码省略.........
EventTypeSpec eventType;
eventType.eventClass = kEventClassWindow;
eventType.eventKind = kEventWindowClose;
EventHandlerUPP handlerUPP = NewEventHandlerUPP(ProcessWindowClose);
InstallWindowEventHandler(window, handlerUPP, 1, &eventType, 0, 0);
// Install window bounds change handler.
eventType.eventKind = kEventWindowBoundsChanged;
handlerUPP = NewEventHandlerUPP(ProcessWindowBoundsChange);
InstallWindowEventHandler(window, handlerUPP, 1, &eventType, 0, 0);
// Install window zoomed handler.
eventType.eventKind = kEventWindowZoomed;
handlerUPP = NewEventHandlerUPP(ProcessWindowZoomed);
InstallWindowEventHandler(window, handlerUPP, 1, &eventType, 0, 0);
// Install window redraw handler.
eventType.eventKind = kEventWindowDrawContent;
handlerUPP = NewEventHandlerUPP(ProcessWindowRedraw);
InstallWindowEventHandler(window, handlerUPP, 1, &eventType, 0, 0);
// Install key down handler.
EventTypeSpec eventTypes[2];
eventTypes[0].eventClass = kEventClassKeyboard;
eventTypes[0].eventKind = kEventRawKeyDown;
eventTypes[1].eventClass = kEventClassKeyboard;
eventTypes[1].eventKind = kEventRawKeyRepeat;
handlerUPP = NewEventHandlerUPP(ProcessKeyDown);
InstallWindowEventHandler(window, handlerUPP, 2, eventTypes, 0, 0);
// Install key up handler.
eventTypes[0].eventClass = kEventClassKeyboard;
eventTypes[0].eventKind = kEventRawKeyUp;
handlerUPP = NewEventHandlerUPP(ProcessKeyUp);
InstallWindowEventHandler(window, handlerUPP, 1, eventTypes, 0, 0);
// Install key-modifier-changed handler.
eventTypes[0].eventClass = kEventClassKeyboard;
eventTypes[0].eventKind = kEventRawKeyModifiersChanged;
handlerUPP = NewEventHandlerUPP(ProcessKeyModifierChanged);
InstallWindowEventHandler(window, handlerUPP, 1, eventTypes, 0, 0);
// Install mouse down handler.
eventType.eventClass = kEventClassMouse;
eventType.eventKind = kEventMouseDown;
handlerUPP = NewEventHandlerUPP(ProcessMouseDown);
InstallWindowEventHandler(window, handlerUPP, 1, &eventType, 0, 0);
// Install mouse up handler.
eventType.eventKind = kEventMouseUp;
handlerUPP = NewEventHandlerUPP(ProcessMouseUp);
InstallWindowEventHandler(window, handlerUPP, 1, &eventType, 0, 0);
// Install mouse drag handler.
eventType.eventKind = kEventMouseDragged;
handlerUPP = NewEventHandlerUPP(ProcessMouseDragged);
InstallWindowEventHandler(window, handlerUPP, 1, &eventType, 0, 0);
// Install mouse move handler.
eventType.eventKind = kEventMouseMoved;
handlerUPP = NewEventHandlerUPP(ProcessMouseMoved);
InstallWindowEventHandler(window, handlerUPP, 1, &eventType, 0, 0);
// Create timer.
EventLoopTimerRef timer;
InstallEventLoopTimer(GetMainEventLoop(), 0, kEventDurationMillisecond,
NewEventLoopTimerUPP(ProcessTimer), 0, &timer);
if (!theApp->OnInitialize())
{
return -4;
}
// Set auto-repeat key timing.
short keyRepeatThresh = LMGetKeyRepThresh();
short keyThresh = LMGetKeyThresh();
LMSetKeyRepThresh(1);
LMSetKeyThresh(30);
// The default OnPreidle() clears the buffers. Allow the application to
// fill them before the window is shown and before the event loop starts.
theApp->OnPreidle();
// Display the window.
ShowWindow(window);
// Run event loop.
RunApplicationEventLoop();
// Reset auto-repeat key timing to initial value.
LMSetKeyRepThresh(keyRepeatThresh);
LMSetKeyThresh(keyThresh);
theApp->OnTerminate();
delete0(mRenderer);
RemoveEventLoopTimer(timer);
DisposeMenu(menu);
return 0;
}
示例3: Main
//.........这里部分代码省略.........
else if (key == 0x63)
{
// keypad Insert
key = 0x9e;
}
else if (key == 0xFF)
{
// keypad Delete
key = 0x9f;
}
else if (key == 0xE1 || key == 0xE2)
{
// L-shift or R-shift
key = KEY_SHIFT;
state = (evt.type == KeyPress);
SetExtraData(GLXAPP_SHIFTDOWN, sizeof(bool), &state);
}
else if (key == 0xE3 || key == 0xE4)
{
// L-ctrl or R-ctrl
key = KEY_CONTROL;
}
else if (key == 0xE9 || key == 0xEA)
{
// L-alt or R-alt
key = KEY_ALT;
}
else if (key == 0xEB || key == 0xEC)
{
key = KEY_COMMAND;
}
}
if ((KEY_HOME <= key && key <= KEY_END)
|| (KEY_F1 <= key && key <= KEY_F12)
|| (KEY_SHIFT <= key && key <= KEY_COMMAND))
{
if (evt.type == KeyPress)
{
theApp->OnSpecialKeyDown(key, evt.xbutton.x,
evt.xbutton.y);
}
else
{
theApp->OnSpecialKeyUp(key, evt.xbutton.x,
evt.xbutton.y);
}
}
else
{
// Get key-modifier state. Adjust for shift state.
unsigned char ucKey = (unsigned char)key;
GetExtraData(GLXAPP_SHIFTDOWN, sizeof(bool), &state);
if (state && 'a' <= ucKey && ucKey <= 'z')
{
ucKey = (unsigned char)(key - 32);
}
if (evt.type == KeyPress)
{
theApp->OnKeyDown(ucKey, evt.xbutton.x,
evt.xbutton.y);
}
else
{
theApp->OnKeyUp(ucKey, evt.xbutton.x,
evt.xbutton.y);
}
}
continue;
}
if (evt.type == Expose)
{
theApp->OnDisplay();
continue;
}
if (evt.type == ConfigureNotify)
{
theApp->OnMove(evt.xconfigure.x, evt.xconfigure.y);
theApp->OnResize(evt.xconfigure.width,
evt.xconfigure.height);
continue;
}
if (evt.type == ClientMessage
&& evt.xclient.data.l[0] == wmDelete)
{
XDestroyWindow(display, window);
applicationRunning = false;
continue;
}
}
}
theApp->OnTerminate();
XCloseDisplay(display);
return 0;
}
示例4: Main
//.........这里部分代码省略.........
attributes[pos++] = 1;
attributes[pos++] = WGL_DRAW_TO_WINDOW_ARB;
attributes[pos++] = 1;
attributes[pos++] = WGL_ACCELERATION_ARB;
attributes[pos++] = WGL_FULL_ACCELERATION_ARB;
attributes[pos++] = WGL_PIXEL_TYPE_ARB;
attributes[pos++] = WGL_TYPE_RGBA_ARB;
attributes[pos++] = WGL_RED_BITS_ARB;
attributes[pos++] = 8;
attributes[pos++] = WGL_GREEN_BITS_ARB;
attributes[pos++] = 8;
attributes[pos++] = WGL_BLUE_BITS_ARB;
attributes[pos++] = 8;
attributes[pos++] = WGL_ALPHA_BITS_ARB;
attributes[pos++] = 8;
attributes[pos++] = WGL_DEPTH_BITS_ARB;
attributes[pos++] = 24;
attributes[pos++] = WGL_STENCIL_BITS_ARB;
attributes[pos++] = 8;
attributes[pos++] = WGL_DOUBLE_BUFFER_ARB;
attributes[pos++] = 1;
attributes[pos++] = WGL_SAMPLE_BUFFERS_ARB;
attributes[pos++] = 1;
attributes[pos++] = WGL_SAMPLES_ARB;
attributes[pos++] = numMultisamples;
attributes[pos++] = 0; // list is zero-terminated
unsigned int numFormats = 0;
BOOL successful = wglChoosePixelFormatARB(input.mRendererDC,
attributes, 0, 1, &input.mPixelFormat, &numFormats);
if (successful && numFormats > 0)
{
// The card supports multisampling with the requested number of
// samples. Recreate the window and renderer.
delete0(mRenderer);
gsIgnoreWindowDestroy = true;
DestroyWindow(handle);
handle = CreateWindow(sWindowClass, theApp->GetWindowTitle(),
WS_OVERLAPPEDWINDOW, theApp->GetXPosition(),
theApp->GetYPosition(), rect.right - rect.left + 1,
rect.bottom - rect.top + 1, 0, 0, 0, 0);
theApp->SetWindowID(PtrToInt(handle));
input.mWindowHandle = handle;
mRenderer = new0 Renderer(input, theApp->GetWidth(),
theApp->GetHeight(), mColorFormat, mDepthStencilFormat,
mNumMultisamples);
}
}
#endif
if (theApp->OnInitialize())
{
// The default OnPreidle() clears the buffers. Allow the application
// to fill them before the window is shown and before the event loop
// starts.
theApp->OnPreidle();
// Display the window.
ShowWindow(handle, SW_SHOW);
UpdateWindow(handle);
// Start the message pump.
bool applicationRunning = true;
while (applicationRunning)
{
MSG msg;
if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
{
applicationRunning = false;
continue;
}
HACCEL accel = 0;
if (!TranslateAccelerator(handle, accel, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
else
{
theApp->OnIdle();
}
}
}
theApp->OnTerminate();
delete0(mRenderer);
#ifdef WM5_USE_DX9
input.mDriver->Release();
#endif
return 0;
}