GlobeEngine
Engine.h
Go to the documentation of this file.
1 
9 #ifndef GlobeEngine_Engine_h
10 #define GlobeEngine_Engine_h
11 
12 #include "OpenGL_Includes.h"
13 #include "Camera.h"
14 #include "TextureHandle.h"
15 #include "Timer.h"
16 #include <vmmlib/matrix.hpp>
17 #include <vector>
18 
19 namespace ge {
20  class Engine
21  {
22  public:
24 
25  public:
26  enum PICKINGSTATE {
27  IDLE=0,
30  };
31  enum DEBUGSTATE {
34  };
39  };
40 
41  public:
42  Engine();
43  ~Engine();
44  // virtual overloads
45  virtual void clear();
46  virtual void create();
47 
48  // necessary overloads for engine classes
49  virtual void initializeScene(std::string _initFilePath=0) = 0;
50  virtual void update() = 0;
51  virtual void resize(int _w, int _h) = 0;
52  void draw();
53 
54  void initExtension();
55 
56  void setProgrammState(enum PROGRAMMSTATE state);
58  return programstate;
59  };
60 
61  void setDebugState(enum DEBUGSTATE state);
63  return debugstate;
64  };
65 
66  void enablePicking(bool _in);
67  bool isPickingEnabled();
68 
69  void enableWireframe(bool _in);
70  bool isWireframeEnabled();
71 
72  void enableAnimationLoop(bool _in);
74 
75  void setUIFramebufferID(unsigned int _id);
76  const std::shared_ptr<TextureHandle>& getUIFramebufferHandle();
77  bool isUIFramebufferActive();
78  void enableUIFramebuffer(bool _in = true);
79  void disableUIFramebuffer();
80 
81  int getCameraCount();
82  std::shared_ptr<ge::Camera> getCamera(int _index);
83  std::shared_ptr<ge::Camera> getSelectedCam();
84  int getSelectedCamID() const;
85  void setSelectedCamID(int _id);
86 
87  float getDevicePixelRatio();
88  void setDevicePixelRatio(float _in);
89 
95 
96  inline void getOpenGLError(std::string const& _input) {
97 #ifdef GENGINE_GLAPI_410_AND_LOWER
98  GLenum err;
99  err = glGetError();
100 #ifdef GENGINE_GL_ES
101  if (err != GL_NO_ERROR) {
102  printf(_input.c_str(), gluErrorString(err));
103  }
104 #endif
105 #endif
106  }
107 
108  inline void getOpenGLError(char const* _input)
109  {
110 #ifdef GENGINE_GLAPI_410_AND_LOWER
111  GLenum err;
112  err = glGetError();
113 #ifdef GENGINE_GL_ES
114  if (err != GL_NO_ERROR) {
115  printf(_input, gluErrorString(err));
116  }
117 #endif
118 #endif
119  }
120 
121  protected:
122  // draw method to override from derived engines
123  virtual void drawScene() = 0;
124  // Print out engine state
125  void printLineRenderingInfo();
126  void printTextureInfo();
127  void printFramebufferInfo();
128  void printBufferInformation();
129 
133  std::vector< std::shared_ptr<ge::Camera> > cameras;
135 
142 
148 
149  private:
154  std::shared_ptr<TextureHandle> uifboid;
155  bool uifboActive;
156  float devicePixelRatio;
157 
158  bool wireframeMode;
159 
163  ge::Timer frameTimer;
164 
165  };
166 }
167 #endif
Definition: Engine.h:23
DEBUGSTATE
Definition: Engine.h:31
int getSelectedCamID() const
Definition: Engine.cpp:109
Definition: Engine.h:23
virtual void resize(int _w, int _h)=0
void initExtension()
Definition: Engine.cpp:81
Definition: Engine.h:37
virtual void update()=0
void setDebugState(enum DEBUGSTATE state)
Definition: Engine.cpp:240
void printLineRenderingInfo()
Definition: Engine.cpp:117
Definition: Engine.h:23
const std::shared_ptr< TextureHandle > & getUIFramebufferHandle()
Definition: Engine.cpp:277
bool isUIFramebufferActive()
Definition: Engine.cpp:281
double getElapsedTimeForLastFrame()
Definition: Engine.cpp:293
Definition: Engine.h:23
~Engine()
Definition: Engine.cpp:37
void enableAnimationLoop(bool _in)
Definition: Engine.cpp:255
virtual void clear()
Definition: Engine.cpp:45
Definition: Engine.h:38
void getOpenGLError(char const *_input)
Definition: Engine.h:108
void setProgrammState(enum PROGRAMMSTATE state)
Definition: Engine.cpp:235
void getOpenGLError(std::string const &_input)
Definition: Engine.h:96
eTEXTURE_UNITS
Definition: Engine.h:23
enum PICKINGSTATE pickingState
Tells you if there is a picking event or result ongoing.
Definition: Engine.h:141
Engine()
Definition: Engine.cpp:21
Definition: Engine.h:36
enum DEBUGSTATE debugstate
Tells you if the application is running with debug output.
Definition: Engine.h:140
virtual void create()
Definition: Engine.cpp:61
void setSelectedCamID(int _id)
Definition: Engine.cpp:113
void setDevicePixelRatio(float _in)
Definition: Engine.cpp:231
bool pickingEnabled
Definition: Engine.h:146
void disableUIFramebuffer()
Definition: Engine.cpp:289
void enableUIFramebuffer(bool _in=true)
Definition: Engine.cpp:285
Definition: Engine.h:20
void printFramebufferInfo()
Definition: Engine.cpp:184
Definition: Engine.h:23
Definition: Engine.h:32
Definition: Engine.h:23
int getCameraCount()
Definition: Engine.cpp:96
void enableWireframe(bool _in)
Definition: Engine.cpp:265
Definition: Engine.h:28
PROGRAMMSTATE
Definition: Engine.h:35
enum DEBUGSTATE getDebugState()
Definition: Engine.h:62
void setUIFramebufferID(unsigned int _id)
Definition: Engine.cpp:273
int selectedCameraID
Definition: Engine.h:134
Definition: Engine.h:27
Definition: Engine.h:33
std::shared_ptr< ge::Camera > getCamera(int _index)
Definition: Engine.cpp:100
bool isPickingEnabled()
Definition: Engine.cpp:250
float getDevicePixelRatio()
Definition: Engine.cpp:227
Definition: Engine.h:23
PICKINGSTATE
Definition: Engine.h:26
virtual void initializeScene(std::string _initFilePath=0)=0
bool isWireframeEnabled()
Definition: Engine.cpp:269
Definition: AvalancheTrainingSimulationEngine.h:28
std::shared_ptr< ge::Camera > getSelectedCam()
Definition: Engine.cpp:105
Definition: Engine.h:23
std::vector< std::shared_ptr< ge::Camera > > cameras
Definition: Engine.h:133
virtual void drawScene()=0
Definition: Engine.h:29
void enablePicking(bool _in)
Definition: Engine.cpp:245
void draw()
Definition: Engine.cpp:66
void printTextureInfo()
Definition: Engine.cpp:159
Definition: Timer.h:17
void printBufferInformation()
Definition: Engine.cpp:204
bool animationsEnabled
Definition: Engine.h:147
bool isAnimationLoopEnabled()
Definition: Engine.cpp:260
enum PROGRAMMSTATE getProgrammState()
Definition: Engine.h:57
enum PROGRAMMSTATE programstate
Tells you the state of the application.
Definition: Engine.h:139