Skip to content

Commit

Permalink
Move to GLFW timer as time source.
Browse files Browse the repository at this point in the history
  • Loading branch information
elmindreda committed Dec 20, 2016
1 parent 5435f16 commit a938dd1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 26 deletions.
8 changes: 0 additions & 8 deletions include/vapp.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef __VAPP_H__
#define __VAPP_H__

#include <time.h>

#include "vgl.h"

class VermilionApplication
Expand All @@ -14,12 +12,6 @@ class VermilionApplication
static VermilionApplication * s_app;
GLFWwindow* m_pWindow;

#ifdef _WIN32
ULONGLONG m_appStartTime;
#else
struct timeval m_appStartTime;
#endif

static void window_size_callback(GLFWwindow* window, int width, int height);
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods);
static void char_callback(GLFWwindow* window, unsigned int codepoint);
Expand Down
19 changes: 1 addition & 18 deletions lib/vermilion.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#include "vapp.h"

#include <time.h>
#ifndef _WIN32
#include <sys/time.h>
#endif

void VermilionApplication::window_size_callback(GLFWwindow* window, int width, int height)
{
VermilionApplication* pThis = (VermilionApplication*)glfwGetWindowUserPointer(window);
Expand All @@ -28,23 +23,11 @@ void VermilionApplication::char_callback(GLFWwindow* window, unsigned int codepo

unsigned int VermilionApplication::app_time()
{
#ifdef _WIN32
ULONGLONG currentTime = ::GetTickCount64();

return (unsigned int)(currentTime - m_appStartTime);
#else
return 0;
#endif
return (unsigned int) (glfwGetTime() * 1000.0);
}

void VermilionApplication::Initialize(const char * title)
{
#ifdef _WIN32
m_appStartTime = ::GetTickCount64();
#else
gettimeofday(&m_appStartTime, nullptr);
#endif

glfwInit();

#ifdef _DEBUG
Expand Down

0 comments on commit a938dd1

Please sign in to comment.