GlobeEngine
Timer.h
Go to the documentation of this file.
1 //
2 // DebugLogger.h
3 //
4 // Created by Mathias Thöny on 27.12.11.
5 // Copyright (c) 2011 University of Zurich. All rights reserved.
6 //
7 
8 #ifndef GlobeEngine_Timer_h
9 #define GlobeEngine_Timer_h
10 
11 
12 #include "OpenGL_Includes.h"
13 #include <string>
14 #include <ctime>
15 
16 namespace ge {
17  class Timer
18  {
19  public:
20  public:
21  Timer();
22  ~Timer();
23  void clear();
24  void create(bool _showAsFPS = false);
25 
26  // Simple c timer
27  void start();
28  void start(std::string _inTitle);
29  void stop();
30  void stop(std::string _outTitle);
31  void stopAndRestart(std::string _outTitle);
32  double getElapsedTime();
33  bool isRunning();
34 
35  // Simple gpu timer
36  void startGPUClock();
37  void stopGPUClock();
38  GLint64 stopAndShowGPUClock(std::string _outTitle = "");
39 
40 #ifndef __APPLE__
41 
42  // single asynchronous query handling
46 
47  // multipe asynchronous queries with timestamps
48  GLuint64 getResult(int _id);
49  const GLuint64* getAllResults(int _id);
50 
51  int getQueryCount();
52  void generateTimerQuery(int _count);
53  void setTimestampForQuery(int _id);
54 #endif
55  private:
56  // multiple asynchronous queries
57  GLuint* timerQuery;
58  GLuint64* timerResult;
59  int queryCount;
60 
61  // single asynchronous query
62  GLuint singleAsyncQuery;
63  GLuint64 singleAsyncResult;
64 
65  // simple timer
66  GLint64 startTime;
67  GLint64 endTime;
68 
69  // simple c timer
70  clock_t startCTimer;
71  clock_t finishCTimer;
72  double elapsedTimeCTimer;
73  bool running;
74  bool fpsViewer;
75  };
76 }
77 #endif
void startGPUClock()
Definition: Timer.cpp:87
void setTimestampForQuery(int _id)
Definition: Timer.cpp:124
void start()
Definition: Timer.cpp:35
GLint64 stopAndShowGPUClock(std::string _outTitle="")
Definition: Timer.cpp:97
double getElapsedTime()
Definition: Timer.cpp:66
~Timer()
Definition: Timer.cpp:15
const GLuint64 * getAllResults(int _id)
Definition: Timer.cpp:141
void stopGPUClock()
Definition: Timer.cpp:92
void clear()
Definition: Timer.cpp:21
void create(bool _showAsFPS=false)
Definition: Timer.cpp:30
void generateTimerQuery(int _count)
Definition: Timer.cpp:115
void stopSingleAsynchronousQuery()
Definition: Timer.cpp:163
GLuint64 getResult(int _id)
Definition: Timer.cpp:134
Definition: AvalancheTrainingSimulationEngine.h:28
void stopAndRestart(std::string _outTitle)
Definition: Timer.cpp:70
GLint64 getSingleAsynchronousQueryResult()
Definition: Timer.cpp:168
bool isRunning()
Definition: Timer.cpp:78
int getQueryCount()
Definition: Timer.cpp:151
Timer()
Definition: Timer.cpp:8
void stop()
Definition: Timer.cpp:41
Definition: Timer.h:17
void startSingleAsynchronousQuery()
Definition: Timer.cpp:157