本文整理汇总了C++中CStopWatch::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ CStopWatch::Init方法的具体用法?C++ CStopWatch::Init怎么用?C++ CStopWatch::Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStopWatch
的用法示例。
在下文中一共展示了CStopWatch::Init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawGLScene
void DrawGLScene(GLvoid) // Here's Where We Do All The Drawing
{
#ifdef _DEBUG
// DEBUG: FPS
static CStopWatch w;
static int nFrames = 0;
if (nFrames == 0)
{
w.Init();
w.Start();
}
if (++nFrames == 500)
{
FILE *f = fopen("cuckoo.debug.log", "a");
fprintf(f, "FPS: %.2f\n", nFrames/w.GetElapsed());
fclose(f);
Beep(5000, 100);
}
// DEBUG: Gestion d'erreurs
GLenum error = glGetError();
if (error != GL_NO_ERROR)
{
FILE *f = fopen("cuckoo.debug.log", "a");
fprintf(f, "Error: %s\n", gluErrorString(error));
fclose(f);
Beep(3000, 1000);
}
#endif
glLoadIdentity(); // Reset The View
// Affiche l'horloge
g_pClock->Render(g_swTimer.GetElapsed());
/* glAccum(GL_MULT, 0.5f);
glAccum(GL_ACCUM, 0.5f);
glAccum(GL_RETURN, 1.0f);
glFlush();*/
return;
}
示例2: DefScreenSaverProc
EXTERN_C LONG WINAPI ScreenSaverProc(
HWND hWnd, // Handle For This Window
UINT uMsg, // Message For This Window
WPARAM wParam, // Additional Message Information
LPARAM lParam) // Additional Message Information
{
static HDC hDC = NULL; // Private GDI Device Context
static HGLRC hRC = NULL; // Permanent Rendering Context
static int nState;
static int nFrames;
switch (uMsg) // Check For Windows Messages
{
case WM_CREATE:
{
// Load settings
CCuckooSettings settings;
settings.Load();
// Load clock
switch (settings.GetClockType())
{
case 2: // Mickey
g_pClock = new CClockMickey;
break;
case 1: // Wesminster
g_pClock = new CClockWestminster;
break;
case 0: // Cuckoo
g_pClock = new CClockCuckoo;
break;
default: // Error
MessageBox(hWnd, _T("Unknown clock: Please configure the screen saver.\n\nHorloge inconnue: Veuillez reconfigurer l'écran de veille."), _T("Cuckoo"), MB_ICONEXCLAMATION);
return -1;
}
if (g_pClock == NULL)
{
MessageBox(hWnd, _T("Not enought memory to load the clock."), _T("Cuckoo"), MB_ICONERROR);
return -1;
}
// Initialize OpenGL on hWnd.
if (!CreateGLWindow(hWnd, &hDC, &hRC))
return -1;
// Starting state
nState = STATE_SWAP_TEST;
// Set timers
SetTimer(hWnd, 1, 10, NULL);
return 0;
}
case WM_DESTROY:
// Timers
KillTimer(hWnd, 1);
// Clock
if (g_pClock != NULL)
{
delete g_pClock;
g_pClock = NULL;
}
// OpenGL
KillGLWindow(hWnd, hDC, hRC);
return 0;
case WM_TIMER:
switch (nState)
{
case STATE_SWAP_TEST:
// Check if SwapBuffers() swap or copy back to front
if (IsSwapBufferCopyingBackToFront(hDC))
g_pClock->SetSwapBufferMode(CClock::COPY_BACK_TO_FRONT);
else
g_pClock->SetSwapBufferMode(CClock::SWAP_BACK_AND_FRONT);
nState++;
break;
case STATE_INIT_CLOCK:
{
// Load settings
CCuckooSettings settings;
settings.Load();
// Clock
g_pClock->EnableSounds(settings.HasTicTacSound(), settings.BellsOnHours(), settings.BellsOnHalfHours(), settings.BellsOnQuartHours());
g_pClock->Init();
// Precise timing
g_swTimer.Init();
g_swTimer.Start();
// Frame counter
nFrames = 0;
nState++;
break;
}
case STATE_RENDER:
//.........这里部分代码省略.........