Number5
Visualisierung 2 Project - Florian Schober (0828151, f.schober@live.com), Andreas Walch (0926780, walch.andreas89@gmail.com)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Application.cpp
Go to the documentation of this file.
1 #include "Application.hpp"
2 
3 
5  : m_window(this)
6  , m_sceneGraph(this)
7  , m_simpleMeshes(this)
8  , m_scenes(this)
9  , m_camera(this)
10  , m_sprites(this)
11  , m_text(this)
12  , m_picker(this)
13  , m_fbo(this, m_window.getSize())
14  , m_hud(this)
15  , m_gameLogic(this)
16  , m_backColor(0,0,0,0)
17  , m_ownCursor(this)
18  , m_tasks(this)
19 {
20 }
21 
22 
24 {
25  double time = glfwGetTime();
26  double timeDelta = 0;
27 
28  glEnable(GL_DEPTH_TEST);
29 
30  while(m_window.doEvents())
31  {
32  {
33  auto temp = glfwGetTime();
34  timeDelta = temp-time;
35  time = temp;
36  }
37 
38  update(time, timeDelta);
39 
40  glClearColor(m_backColor.r,m_backColor.g,m_backColor.b,m_backColor.a);
41  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
42 
43  render(time, timeDelta);
44 
46  }
47 }
48 void Application::update(double time, double timeDelta)
49 {
50  m_picker.update(time, timeDelta);
51  m_camera.update(time, timeDelta);
52  m_sceneGraph.update(time, timeDelta);
53 
54  m_hud.update(time, timeDelta);
55 
56  m_window.update(time, timeDelta);
57 
58  m_gameLogic.update(time, timeDelta);
59 
60  m_ownCursor.update(time, timeDelta);
61 
62  if (m_window.keyDown(GLFW_KEY_ESCAPE))
63  m_window.close();
64 }
65 void Application::render(double time, double timeDelta)
66 {
67  m_fbo.draw(time, timeDelta);
68 
69  m_picker.draw(time, timeDelta);
70 
71  m_hud.draw(time, timeDelta);
72 
73  m_ownCursor.draw(time, timeDelta);
74 }
75 void Application::onWindowSizeChanged(vec2 const & size)
76 {
78 
79  m_fbo.resize(size);
80 }
81 void Application::onKeyStateChanged(int key, bool pressed)
82 {
83  m_picker.onKeyStateChanged(key, pressed);
84  m_camera.onKeyStateChanged(key, pressed);
85  m_gameLogic.onKeyStateChanged(key, pressed);
86  m_hud.onKeyStateChanged(key, pressed);
87  m_ownCursor.onKeyStateChanged(key, pressed);
88 }
void close()
Definition: Window.cpp:252
GameLogic m_gameLogic
Definition: Application.hpp:25
Picker m_picker
Definition: Application.hpp:23
void onKeyStateChanged(int key, bool pressed)
Definition: GameLogic.cpp:230
void update(double time, double timeDelta)
Definition: SceneGraph.cpp:31
bool keyDown(int key)
Definition: Window.cpp:243
void onKeyStateChanged(int key, bool pressed)
Definition: Application.cpp:81
void update(double time, double timeDelta)
Definition: HUD.cpp:12
void onKeyStateChanged(int key, bool pressed)
Definition: Picker.cpp:99
void swapBuffers()
Definition: Window.cpp:209
void update(double time, double timeDelta)
Definition: Application.cpp:48
void onWindowSizeChanged(vec2 const &size)
Definition: Picker.cpp:92
bool doEvents()
Definition: Window.cpp:213
Camera m_camera
Definition: Application.hpp:20
void update(double time, double timeDelta)
Definition: Window.cpp:258
void draw(double time, double timeDelta)
Definition: HUD.cpp:22
void update(double time, double timeDelta)
Definition: Picker.cpp:42
SceneFBO m_fbo
Definition: Application.hpp:16
void render(double time, double timeDelta)
Definition: Application.cpp:65
void update(double time, double timeDelta)
Definition: OwnCursor.cpp:106
void update(double time, double timeDelta)
Definition: Camera.cpp:11
void onWindowSizeChanged(vec2 const &size)
Definition: Application.cpp:75
Window m_window
Definition: Application.hpp:13
void resize(vec2 const &size)
Definition: SceneFBO.cpp:73
OwnCursor m_ownCursor
Definition: Application.hpp:27
SceneGraph m_sceneGraph
Definition: Application.hpp:17
void draw(double time, double timeDelta)
Definition: Picker.cpp:106
vec4 m_backColor
Definition: Application.hpp:26
void draw(double time, double timeDelta)
Definition: SceneFBO.cpp:56
void onKeyStateChanged(int key, bool pressed)
Definition: OwnCursor.cpp:34
void onKeyStateChanged(int key, bool pressed)
Definition: Camera.cpp:49
void draw(double time, double timeDelta)
Definition: OwnCursor.cpp:118
void onKeyStateChanged(int key, bool pressed)
Definition: HUD.cpp:358
void update(double time, double timeDelta)
Definition: GameLogic.cpp:27