]> git.tdb.fi Git - libs/gl.git/commitdiff
Create default context options in the device backend
authorMikko Rasa <tdb@tdb.fi>
Wed, 17 Nov 2021 19:31:30 +0000 (21:31 +0200)
committerMikko Rasa <tdb@tdb.fi>
Wed, 17 Nov 2021 19:31:30 +0000 (21:31 +0200)
demos/desertpillars/source/desertpillars.cpp
demos/desertpillars/source/desertpillars.h
source/backends/opengl/device_backend.cpp
source/backends/opengl/device_backend.h
source/core/device.cpp
source/core/device.h
tools/viewer.cpp

index 62a4455896300b22c9f77a3b8452ac6bf4eb26a6..1afd57b8d1a41cc50798976213680061ab15628d 100644 (file)
@@ -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),
index 352b8c2c0b2b09fdaa496e7191bcf6d1cefc80cb..7aae1c2d903dbc52e0593950861b14152a5f94e0 100644 (file)
@@ -27,7 +27,6 @@ private:
        struct Options
        {
                Msp::Graphics::WindowOptions wnd_opts;
-               Msp::Graphics::GLOptions gl_opts;
 
                Options();
        };
index 1c51b132ca48500a26f5b78841bbb2e99c855cd3..35c0ca5c244d71573979171a1d2de85b2ccad55d 100644 (file)
@@ -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<Device *>(this)->info;
index f3a8e48029b0b807e7484a6a5a9ab4b9c0130298..dfa16653167d979d40279026fb743c57a0f75a3b 100644 (file)
@@ -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; }
index e3b43e2db2cf3ad45feb8396f7e890d7605c24c6..3186015c73ebb9c887119ffdd618a2339804fe09 100644 (file)
@@ -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)
 {
index 2b75e4c81a9d9613ee478fc64ac1e99c4aac3517..97a28e73f6307b852c9305808be39e7cb08a3b48 100644 (file)
@@ -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;
index 830caa77b81527799f66a2d70737316bd231787d..36a5dc9bc13e3a2af70daf93d32e2234e781b04d 100644 (file)
@@ -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<unsigned>(m[1].str);
                wnd_opts.height = lexical_cast<unsigned>(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),