Tissue Forge C++ 0.2.1
Interactive, particle-based physics, chemistry and biology modeling and simulation environment
Loading...
Searching...
No Matches
tfGlfwApplication.h
1/*******************************************************************************
2 * This file is part of Tissue Forge.
3 * Copyright (c) 2022-2024 T.J. Sego
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published
7 * by the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 ******************************************************************************/
19
20#ifndef _SOURCE_RENDERING_TFGLFWAPPLICATION_H_
21#define _SOURCE_RENDERING_TFGLFWAPPLICATION_H_
22
23#include <TissueForge_private.h>
24#include "tfApplication.h"
25#include <tfSimulator.h>
26#include <Magnum/Platform/GlfwApplication.h>
27
28#include "tfGlfwWindow.h"
29#include "tfUniverseRenderer.h"
30
31
32using namespace Magnum;
33
34
35namespace TissueForge::rendering {
36
37
39 public Application,
40 public Magnum::Platform::GlfwApplication {
41
42 public:
43
44 typedef Magnum::Platform::GlfwApplication::Arguments Arguments;
45
46
47
51 GlfwApplication(const Arguments &args);
52
53
54 HRESULT createContext(const Simulator::Config &conf) override;
55
66 HRESULT pollEvents () override;
67
84 HRESULT waitEvents () override;
85
106 HRESULT waitEventsTimeout(double timeout) override;
107
108
114
115
116 HRESULT setSwapInterval(int si) override;
117
118 void drawEvent() override;
119
120 GlfwWindow *getWindow() override;
121
122 UniverseRenderer *getRenderer() override;
123
124 HRESULT redraw() override;
125
126 Magnum::GL::AbstractFramebuffer& framebuffer() override;
127
128 GlfwWindow *_win;
129
130 // TODO implement events and move these to simulator.
131 UniverseRenderer *_ren;
132
133 Int _substeps = 1;
134 bool _pausedSimulation = false;
135 bool _mousePressed = false;
136
137 /* Timeline to adjust number of simulation steps per frame */
138 Timeline _timeline;
139
140 HRESULT mainLoopIteration(double timeout) override;
141
142
143 void viewportEvent(ViewportEvent& event) override;
144 void keyPressEvent(KeyEvent& event) override;
145 void mousePressEvent(MouseEvent& event) override;
146 void mouseReleaseEvent(MouseEvent& event) override;
147 void mouseMoveEvent(MouseMoveEvent& event) override;
148 void mouseScrollEvent(MouseScrollEvent& event) override;
149 void exitEvent(ExitEvent& event) override;
150
151 int windowAttribute(WindowAttributes attr) override;
152
153 HRESULT setWindowAttribute(WindowAttributes attr, int val) override;
154
155 HRESULT destroy() override;
156
157 HRESULT close() override;
158
159 HRESULT show() override;
160
161 HRESULT messageLoop(double et) override;
162
163 HRESULT showWindow();
164
165 bool contextMakeCurrent() override;
166
167 bool contextHasCurrent() override;
168
169 bool contextRelease() override;
170 };
171
172}
173
174#endif /* _SOURCE_RENDERING_TFGLFWAPPLICATION_H_ */
Definition tfGlfwApplication.h:40
HRESULT waitEventsTimeout(double timeout) override
GlfwApplication(const Arguments &args)
Tissue Forge rendering and visualization.
Definition tfAngle.h:38
Definition tfSimulator.h:368
Definition tfApplication.h:189
Definition tfGlfwWindow.h:38
Definition tfUniverseRenderer.h:115
int32_t HRESULT
Definition tf_port.h:255