2
* Copyright 2010 Inalogic Inc.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License version 3, as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranties of
10
* MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11
* PURPOSE. See the applicable version of the GNU Lesser General Public
12
* License for more details.
14
* You should have received a copy of both the GNU Lesser General Public
15
* License version 3 along with this program. If not, see
16
* <http://www.gnu.org/licenses/>
18
* Authored by: Jay Taoko <jay.taoko_AT_gmail_DOT_com>
23
#include "NuxCore/NKernel.h"
24
#include "GLResource.h"
30
#if defined(INL_OS_WINDOWS)
32
QueryPerformanceFrequency(&freq);
33
QueryPerformanceCounter(&now);
34
res = (float) (1.0f / (double) freq.QuadPart);
35
#elif defined(INL_OS_LINUX)
36
gettimeofday(&m_last_time, NULL);
44
void GLTimer::Reset(void)
46
#if defined(INL_OS_WINDOWS)
47
QueryPerformanceCounter(&now);
48
#elif defined(INL_OS_LINUX)
49
gettimeofday(&m_last_time, NULL);
53
float GLTimer::PassedMilliseconds(void)
55
#if defined(INL_OS_WINDOWS)
57
QueryPerformanceCounter(&temp);
58
double elapsedTime = (temp.QuadPart - now.QuadPart) * res * 1000.0f;
59
//now.QuadPart = temp.QuadPart;
62
#elif defined(INL_OS_LINUX)
66
gettimeofday(¤t_time, NULL);
68
elapsedTime = (current_time.tv_sec - m_last_time.tv_sec) * 1000.0f; // seconds to millisecond
69
elapsedTime += (current_time.tv_usec - m_last_time.tv_usec) / 1000.0f; // micro seconds to millisecond
74
// float GLTimer::PassedFrac(void)
76
// LARGE_INTEGER temp;
77
// QueryPerformanceCounter(&temp);
78
// return (temp.QuadPart - now.QuadPart) * res;