DXGL r849 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r848‎ | r849 | r850 >
Date:18:14, 1 September 2018
Author:admin
Status:new
Tags:
Comment:
Add functions to DXGLTimer to set and compare times.
Modified paths:
  • /ddraw/struct.h (modified) (history)
  • /ddraw/timer.c (modified) (history)
  • /ddraw/timer.h (modified) (history)

Diff [purge]

Index: ddraw/struct.h
@@ -47,6 +47,7 @@
4848 double monitor_period;
4949 double timer_frequency;
5050 LARGE_INTEGER timer_base;
 51+ LARGE_INTEGER lastdraw;
5152 } DXGLTimer;
5253
5354 // OpenGL Extensions structure
Index: ddraw/timer.c
@@ -73,4 +73,23 @@
7474 sync_pos /= timer->monitor_period;
7575 sync_pos *= (double)timer->lines;
7676 return (unsigned int)sync_pos;
 77+}
 78+
 79+void DXGLTimer_SetLastDraw(DXGLTimer *timer)
 80+{
 81+ if (timer->timertype == 1) QueryPerformanceCounter(&timer->lastdraw);
 82+ else timer->lastdraw.QuadPart = timeGetTime();
 83+}
 84+
 85+BOOL DXGLTimer_CheckLastDraw(DXGLTimer *timer, DWORD ms)
 86+{
 87+ LARGE_INTEGER timerpos;
 88+ double milliseconds;
 89+ if (timer->timertype == 1) QueryPerformanceCounter(&timerpos);
 90+ else timerpos.QuadPart = timeGetTime();
 91+ timerpos.QuadPart -= timer->timer_base.QuadPart;
 92+ if (timer->timertype == 1) milliseconds = ((double)timerpos.QuadPart / (double)timer->timer_frequency) * 1000.0;
 93+ else milliseconds = (double)timerpos.QuadPart;
 94+ if (milliseconds < ms) return FALSE;
 95+ else return TRUE;
7796 }
\ No newline at end of file
Index: ddraw/timer.h
@@ -26,6 +26,8 @@
2727 void DXGLTimer_Init(DXGLTimer *timer);
2828 void DXGLTimer_Calibrate(DXGLTimer *timer, unsigned int lines, unsigned int frequency);
2929 unsigned int DXGLTimer_GetScanLine(DXGLTimer *timer);
 30+void DXGLTimer_SetLastDraw(DXGLTimer *timer);
 31+BOOL DXGLTimer_CheckLastDraw(DXGLTimer *timer, DWORD ms);
3032
3133 #ifdef __cplusplus
3234 }