Re: [AD] get_milliseconds function |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
wtimer.diff joined do the following:
* adding tim_win32_get_milliseconds
* setting the timeGetTime granularity to 1 ms in the corresponding win32 timer init & exit proc.
Let me know it something is not good from your point of view.
I am OK for more test.
From: gullradriel@xxxxxxxxxx
To: alleg-developers@xxxxxxxxxx
Date: Mon, 28 May 2007 09:09:06 +0000
Subject: Re: [AD] get_milliseconds function
tim_win32_get_milliseconds was not added in the high nor low performance driver list.
Doing so solves the problem.
I got it working (as told in your a.cc thread ).
From: gullradriel@xxxxxxxxxx
To: alleg-developers@xxxxxxxxxx
Date: Mon, 28 May 2007 07:31:19 +0000
Subject: Re: [AD] get_milliseconds function
Compiled fine, but when testing extimer said that 0 ms were consumed.
I am searching why.
> Date: Sat, 26 May 2007 21:10:31 -0400
> From: cgamesplay@xxxxxxxxxx
> To: alleg-developers@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Subject: [AD] get_milliseconds function
>
> Because it is so trivial (on Linux and Windows), I've written a
> get_milliseconds function for Allegro, which returns the number of
> milliseconds elapsed since some arbitrary time. It actually brings
> Allegro timers into this century in terms of popular timing methods,
> with millisecond accuracy. I've written ports for Windows and Linux..
> the other drivers are simply set to NULL (which causes the function to
> return 0).
>
> *I have NOT compiled the patch on Windows!* I need someone to compile
> it on Windows and run extimer to verify that the changes work.
>
> --
> Regards,
> Ryan Patterson <mailto:cgamesplay@xxxxxxxxxx>
Essayez Live.com, votre nouvelle page d'accueil ! Personnalisez-la en quelques clics pour retrouver tout ce qui vous intéresse au même endroit. au même endroit.
Essayez Live.com, votre nouvelle page d'accueil ! Personnalisez-la en quelques clics pour retrouver tout ce qui vous intéresse au même endroit. au même endroit.
Avec Windows Live Spaces, publiez directement des messages électroniques sur votre blog ou ajoutez-y des photos, des blagues et d'autres infos. C'est gratuit !
*** wtimer_ori.c Mon May 28 11:57:43 2007
--- wtimer.c Mon May 28 11:15:53 2007
*************** static int tim_win32_high_perf_init(void
*** 56,61 ****
--- 56,62 ----
static int tim_win32_low_perf_init(void);
static void tim_win32_exit(void);
static void tim_win32_rest(unsigned int time, AL_METHOD(void, callback, (void)));
+ static unsigned int tim_win32_get_milliseconds();
static TIMER_DRIVER timer_win32_high_perf =
*************** static TIMER_DRIVER timer_win32_high_per
*** 67,73 ****
tim_win32_high_perf_init,
tim_win32_exit,
NULL, NULL, NULL, NULL, NULL, NULL,
! tim_win32_rest
};
--- 68,75 ----
tim_win32_high_perf_init,
tim_win32_exit,
NULL, NULL, NULL, NULL, NULL, NULL,
! tim_win32_rest,
! tim_win32_get_milliseconds
};
*************** static TIMER_DRIVER timer_win32_low_perf
*** 80,86 ****
tim_win32_low_perf_init,
tim_win32_exit,
NULL, NULL, NULL, NULL, NULL, NULL,
! tim_win32_rest
};
--- 82,89 ----
tim_win32_low_perf_init,
tim_win32_exit,
NULL, NULL, NULL, NULL, NULL, NULL,
! tim_win32_rest,
! tim_win32_get_milliseconds
};
*************** static void tim_win32_low_perf_thread(vo
*** 199,204 ****
--- 202,209 ----
*/
static int tim_win32_high_perf_init(void)
{
+ timeBeginPeriod( 1 ); /* 1 ms granularity */
+
if (!QueryPerformanceFrequency(&counter_freq)) {
_TRACE(PREFIX_W "High performance timer not supported\n");
return -1;
*************** static int tim_win32_high_perf_init(void
*** 226,231 ****
--- 231,238 ----
*/
static int tim_win32_low_perf_init(void)
{
+ timeBeginPeriod( 1 ); /* 1 ms granularity */
+
/* create thread termination event */
timer_stop_event = CreateEvent(NULL, FALSE, FALSE, NULL);
*************** static void tim_win32_exit(void)
*** 253,258 ****
--- 260,267 ----
/* thread has ended, now we can release all resources */
CloseHandle(timer_stop_event);
+
+ timeEndPeriod( 1 ); /* 1 ms granularity */
}
*************** static void tim_win32_rest(unsigned int
*** 274,276 ****
--- 283,295 ----
Sleep(ms);
}
}
+
+
+
+ /* tim_win32_get_milliseconds:
+ * Returns the number of milliseconds elapsed since the system was started.
+ */
+ static unsigned int tim_win32_get_milliseconds()
+ {
+ return timeGetTime();
+ }