From: Mikko Rasa Date: Wed, 17 Nov 2021 19:31:30 +0000 (+0200) Subject: Create default context options in the device backend X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=5d9ecb00aea134fa082a0fa6b9c82c643a884a32;p=libs%2Fgl.git Create default context options in the device backend --- diff --git a/demos/desertpillars/source/desertpillars.cpp b/demos/desertpillars/source/desertpillars.cpp index 62a44558..1afd57b8 100644 --- a/demos/desertpillars/source/desertpillars.cpp +++ b/demos/desertpillars/source/desertpillars.cpp @@ -15,14 +15,12 @@ DesertPillars::Options::Options() { wnd_opts.width = 1920; wnd_opts.height = 1080; - gl_opts.gl_version_major = Graphics::GLOptions::LATEST_VERSION; - gl_opts.core_profile = true; } DesertPillars::DesertPillars(int, char **): window(display, opts.wnd_opts), - gl_device(window, opts.gl_opts), + gl_device(window), keyboard(window), resources(&res_mgr), view(window), diff --git a/demos/desertpillars/source/desertpillars.h b/demos/desertpillars/source/desertpillars.h index 352b8c2c..7aae1c2d 100644 --- a/demos/desertpillars/source/desertpillars.h +++ b/demos/desertpillars/source/desertpillars.h @@ -27,7 +27,6 @@ private: struct Options { Msp::Graphics::WindowOptions wnd_opts; - Msp::Graphics::GLOptions gl_opts; Options(); }; diff --git a/source/backends/opengl/device_backend.cpp b/source/backends/opengl/device_backend.cpp index 1c51b132..35c0ca5c 100644 --- a/source/backends/opengl/device_backend.cpp +++ b/source/backends/opengl/device_backend.cpp @@ -25,6 +25,14 @@ OpenGLDevice::OpenGLDevice(Graphics::Window &wnd, const Graphics::GLOptions &opt context(wnd, opts) { } +Graphics::GLOptions OpenGLDevice::create_default_options() +{ + Graphics::GLOptions opts; + opts.gl_version_major = Graphics::GLOptions::LATEST_VERSION; + opts.core_profile = true; + return opts; +} + void OpenGLDevice::fill_info() { DeviceInfo &info = static_cast(this)->info; diff --git a/source/backends/opengl/device_backend.h b/source/backends/opengl/device_backend.h index f3a8e480..dfa16653 100644 --- a/source/backends/opengl/device_backend.h +++ b/source/backends/opengl/device_backend.h @@ -14,6 +14,8 @@ protected: OpenGLDevice(Graphics::Window &, const Graphics::GLOptions &); + static Graphics::GLOptions create_default_options(); + void fill_info(); Graphics::GLContext &get_context() { return context; } diff --git a/source/core/device.cpp b/source/core/device.cpp index e3b43e2d..3186015c 100644 --- a/source/core/device.cpp +++ b/source/core/device.cpp @@ -6,6 +6,10 @@ namespace GL { Device *Device::current = 0; +Device::Device(Graphics::Window &w): + Device(w, create_default_options()) +{ } + Device::Device(Graphics::Window &w, const DeviceOptions &o): DeviceBackend(w, o) { diff --git a/source/core/device.h b/source/core/device.h index 2b75e4c8..97a28e73 100644 --- a/source/core/device.h +++ b/source/core/device.h @@ -48,7 +48,8 @@ private: static Device *current; public: - Device(Graphics::Window &, const DeviceOptions & = DeviceOptions()); + Device(Graphics::Window &); + Device(Graphics::Window &, const DeviceOptions &); ~Device(); using DeviceBackend::get_context; diff --git a/tools/viewer.cpp b/tools/viewer.cpp index 830caa77..36a5dc9b 100644 --- a/tools/viewer.cpp +++ b/tools/viewer.cpp @@ -44,7 +44,6 @@ private: string animation_name; string renderable_name; Graphics::WindowOptions wnd_opts; - Graphics::GLOptions gl_opts; Options(int, char **); }; @@ -127,14 +126,12 @@ Viewer::Options::Options(int argc, char **argv) wnd_opts.width = lexical_cast(m[1].str); wnd_opts.height = lexical_cast(m[2].str); } - gl_opts.gl_version_major = Graphics::GLOptions::LATEST_VERSION; - gl_opts.core_profile = true; } Viewer::Viewer(int argc, char **argv): opts(argc, argv), window(display, opts.wnd_opts), - gl_device(window, opts.gl_opts), + gl_device(window), mouse(window), view(window), sequence(0),