Skip to content

Commit a938dd1

Browse files
committed
Move to GLFW timer as time source.
1 parent 5435f16 commit a938dd1

File tree

2 files changed

+1
-26
lines changed

2 files changed

+1
-26
lines changed

include/vapp.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#ifndef __VAPP_H__
22
#define __VAPP_H__
33

4-
#include <time.h>
5-
64
#include "vgl.h"
75

86
class VermilionApplication
@@ -14,12 +12,6 @@ class VermilionApplication
1412
static VermilionApplication * s_app;
1513
GLFWwindow* m_pWindow;
1614

17-
#ifdef _WIN32
18-
ULONGLONG m_appStartTime;
19-
#else
20-
struct timeval m_appStartTime;
21-
#endif
22-
2315
static void window_size_callback(GLFWwindow* window, int width, int height);
2416
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods);
2517
static void char_callback(GLFWwindow* window, unsigned int codepoint);

lib/vermilion.cpp

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
#include "vapp.h"
22

3-
#include <time.h>
4-
#ifndef _WIN32
5-
#include <sys/time.h>
6-
#endif
7-
83
void VermilionApplication::window_size_callback(GLFWwindow* window, int width, int height)
94
{
105
VermilionApplication* pThis = (VermilionApplication*)glfwGetWindowUserPointer(window);
@@ -28,23 +23,11 @@ void VermilionApplication::char_callback(GLFWwindow* window, unsigned int codepo
2823

2924
unsigned int VermilionApplication::app_time()
3025
{
31-
#ifdef _WIN32
32-
ULONGLONG currentTime = ::GetTickCount64();
33-
34-
return (unsigned int)(currentTime - m_appStartTime);
35-
#else
36-
return 0;
37-
#endif
26+
return (unsigned int) (glfwGetTime() * 1000.0);
3827
}
3928

4029
void VermilionApplication::Initialize(const char * title)
4130
{
42-
#ifdef _WIN32
43-
m_appStartTime = ::GetTickCount64();
44-
#else
45-
gettimeofday(&m_appStartTime, nullptr);
46-
#endif
47-
4831
glfwInit();
4932

5033
#ifdef _DEBUG

0 commit comments

Comments
 (0)