class Application: public Msp::RegisteredApplication<T>
{
public:
+ enum Features
+ {
+ NO_FEATURES = 0,
+ VIRTUAL_REALITY = 1
+ };
+
using ResourcesType = R;
protected:
Graphics::Display display;
Graphics::Window window;
+ std::unique_ptr<VR::System> vr_system;
GL::Device gl_device;
ResourcesType resources;
Game::Director director;
GL::WindowView gl_view;
- std::unique_ptr<VR::System> vr_system;
Presenter presenter;
PlayerInput player_input;
public:
- Application();
+ Application(Features = NO_FEATURES);
+
+protected:
+ GL::DeviceOptions create_gl_device_options();
int main() override;
protected:
void tick() override;
-
- bool try_enable_vr();
};
template<typename T, typename R>
-Application<T, R>::Application():
+Application<T, R>::Application(Features features):
window(display, 1920, 1080),
- gl_device(window),
+ vr_system(features==VIRTUAL_REALITY ? VR::System::create_autodetect() : nullptr),
+ gl_device(window, create_gl_device_options()),
director(resources),
gl_view(window),
presenter(director, gl_view),
{
window.set_keyboard_autorepeat(false);
window.signal_close.connect(sigc::bind(sigc::mem_fun(this, &Application::exit), 0));
+
+ if(vr_system)
+ {
+ player_input.enable_vr(*vr_system);
+ presenter.enable_vr(*vr_system);
+ }
+}
+
+template<typename T, typename R>
+GL::DeviceOptions Application<T, R>::create_gl_device_options()
+{
+ GL::DeviceOptions opts = GL::Device::create_default_options();
+ if(vr_system)
+ vr_system->fill_gl_device_options(opts);
+ return opts;
}
template<typename T, typename R>
director.tick();
}
-template<typename T, typename R>
-bool Application<T, R>::try_enable_vr()
-{
- vr_system = VR::System::create_autodetect();
- if(vr_system)
- {
- player_input.enable_vr(*vr_system);
- presenter.enable_vr(*vr_system);
- }
- return static_cast<bool>(vr_system);
-}
-
} // namespace Msp::GameView
#endif