/**************************************************************************** REMARKS: Main program entry point ****************************************************************************/ int main(void) { event_t evt; ibool done = false; PM_HWND hwndConsole; hwndConsole = PM_openConsole(0,0,0,0,0,true); EVT_init(&moveMouse); EVT_setMouseRange(1024,768); CalibrateJoy(); do { EVT_pollJoystick(); if (EVT_getNext(&evt,EVT_EVERYEVT)) { switch (evt.what) { case EVT_KEYDOWN: DisplayKey("EVT_KEYDOWN ", &evt); if (EVT_scanCode(evt.message) == KB_esc) done = true; break; case EVT_KEYREPEAT: DisplayKey("EVT_KEYREPEAT", &evt); break; case EVT_KEYUP: DisplayKey("EVT_KEYUP ", &evt); break; case EVT_MOUSEDOWN: DisplayMouse("EVT_MOUSEDOWN", &evt); break; case EVT_MOUSEAUTO: DisplayMouse("EVT_MOUSEAUTO", &evt); break; case EVT_MOUSEUP: DisplayMouse("EVT_MOUSEUP ", &evt); break; case EVT_MOUSEMOVE: DisplayMouse("EVT_MOUSEMOVE", &evt); break; case EVT_JOYCLICK: DisplayJoy("EVT_JOYCLICK ", &evt); break; case EVT_JOYMOVE: DisplayJoy("EVT_JOYMOVE ", &evt); break; } } } while (!done); EVT_exit(); PM_closeConsole(hwndConsole); return 0; }
int mechTest( GA_HGLRC glrc, int width, int height) { ibool done = false; int initPageCount = 5; int fpsRate = 0,key = 0,waitVRT = gaWaitVRT,pageCount = initPageCount; ulong lastCount = 0,newCount; event_t evt; myinit(); myReshape(width,height); LZTimerOn(); while (!done) { animation(); display(); gmoveto(0,0); gprintf("%d x %d %d bit %s (%d.%d fps)",(int)maxX+1,(int)maxY+1, (int)modeInfo.BitsPerPixel, (cntMode & gaLinearBuffer) ? "Linear" : "Banked", fpsRate / 10, fpsRate % 10); if (softwareOnly) gprintf("Rendering to system memory back buffer"); switch (waitVRT) { case gaTripleBuffer: gprintf("Triple buffering - should be no flicker"); gprintf("Frame rate *must* max at refresh rate"); break; case gaWaitVRT: gprintf("Double buffering - should be no flicker"); gprintf("Frame rate *must* lock to multiple of refresh"); break; default: gprintf("Page flipping (no wait) - may flicker"); gprintf("Frame rate *must* max at hardware limit"); break; } glFuncs.SwapBuffers(glrc,waitVRT); if (EVT_kbhit()) { EVT_getNext(&evt,EVT_KEYDOWN | EVT_KEYREPEAT); EVT_flush(EVT_KEYREPEAT); key = EVT_asciiCode(evt.message); if (key == 'v' || key == 'V') { waitVRT -= 1; if (modeInfo.Attributes & gaHaveTripleBuffer) { if (waitVRT < gaTripleBuffer) waitVRT = gaDontWait; } else { if (waitVRT < gaWaitVRT) waitVRT = gaDontWait; } } else if (key == 0x1B || key == 0x0D || key == ' ') { done = true; } else { handleASCIICode(key); handleScanCode(EVT_scanCode(evt.message)); } } /* Compute the frames per second rate after going through a large * number of pages. */ if (--pageCount == 0) { newCount = LZTimerLap(); fpsRate = (int)(10000000L / (newCount - lastCount)) * initPageCount; lastCount = newCount; pageCount = initPageCount; } } LZTimerOff(); if (quadObj) { gluDeleteQuadric(quadObj); quadObj = NULL; } return key; }
// Obtain the next event ibool getNext(MVEvent& event,ulong mask = evAll) { return EVT_getNext((event_t*)&event,mask); };