Tissue Forge C++ 0.2.1
Interactive, particle-based physics, chemistry and biology modeling and simulation environment
Loading...
Searching...
No Matches
tfWindowlessApplication.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_TFWINDOWLESSAPPLICATION_H_
21#define _SOURCE_RENDERING_TFWINDOWLESSAPPLICATION_H_
22
23#include <tf_config.h>
24#include <TissueForge.h>
25#include "tfApplication.h"
26#include <Magnum/GL/Context.h>
27
28#include <Magnum/GL/Buffer.h>
29#include <Magnum/GL/Framebuffer.h>
30#include <Magnum/GL/Mesh.h>
31#include <Magnum/GL/Renderbuffer.h>
32#include <Magnum/GL/RenderbufferFormat.h>
33
34
35#if defined(TF_APPLE)
36 #include "Magnum/Platform/WindowlessCglApplication.h"
37#elif defined(TF_LINUX)
38 #include "Magnum/Platform/WindowlessEglApplication.h"
39
40 // Freaking xlib.h defines these, and the wreak havoc with everythign...
41 #undef Button
42 #undef Button1
43 #undef Button2
44 #undef Button3
45 #undef Button4
46 #undef Button5
47
48#elif defined(TF_WINDOWS)
49#include "Magnum/Platform/WindowlessWglApplication.h"
50#else
51#error no windowless application available on this platform
52#endif
53
54
55namespace TissueForge {
56
57
58 namespace rendering {
59
60
61 struct WindowlessApplication :
62 public Application,
63 private Magnum::Platform::WindowlessApplication
64 {
65 public:
66
67 typedef Magnum::Platform::WindowlessApplication::Arguments Arguments;
68
69 typedef Magnum::Platform::WindowlessApplication::Configuration Configuration;
70
71 WindowlessApplication() = delete;
72
76 WindowlessApplication(const Arguments &args);
77
78 ~WindowlessApplication();
79
80 UniverseRenderer *getRenderer() override;
81
82
83 HRESULT createContext(const Simulator::Config &conf) override;
84
95 HRESULT pollEvents () override;
96
113 HRESULT waitEvents () override;
114
134
135 HRESULT waitEventsTimeout(double timeout) override;
136
137
143
144 HRESULT setSwapInterval(int si) override { return E_NOTIMPL;};
145
146 HRESULT mainLoopIteration(double timeout) override;
147
148 struct GlfwWindow *getWindow() override;
149
150 int windowAttribute(WindowAttributes attr) override;
151
152 HRESULT setWindowAttribute(WindowAttributes attr, int val) override;
153
154 HRESULT redraw() override;
155
156 HRESULT close() override;
157
158 HRESULT destroy() override;
159
160 HRESULT show() override;
161
162 HRESULT messageLoop(double et) override;
163
164 Magnum::GL::AbstractFramebuffer& framebuffer() override;
165
166
167 bool contextMakeCurrent() override;
168
169 bool contextHasCurrent() override;
170
171 bool contextRelease() override;
172
173
174 private:
175 virtual int exec() override { return 0; };
176
177 Magnum::GL::Context* _context;
178
179 // the drawing buffer
180 Magnum::GL::Renderbuffer renderBuffer;
181
182 // attach render / stencil buffer to the framebuffer
183 Magnum::GL::Renderbuffer depthStencil;
184
185 Magnum::GL::Framebuffer frameBuffer;
186
187
188 struct WindowlessWindow *window;
189 struct UniverseRenderer *renderer;
190
191 friend struct WindowlessWindow;
192
193 };
194
195}}
196
197#endif // _SOURCE_RENDERING_TFWINDOWLESSAPPLICATION_H_
Tissue Forge rendering and visualization.
Definition tfAngle.h:38
Include Python header, disable linking to pythonX_d.lib on Windows in debug mode.
Definition tfAngleConfig.h:26
Definition tfSimulator.h:368
Definition tfApplication.h:189
Definition tfGlfwWindow.h:38
Definition tfUniverseRenderer.h:115
HRESULT waitEventsTimeout(double timeout) override
int32_t HRESULT
Definition tf_port.h:255