Only support GLVideoView when building with wxWidgets >= 3.1.0.
[dcpomatic.git] / src / wx / system_information_dialog.cc
1 /*
2     Copyright (C) 2019-2021 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21
22 #include "film_viewer.h"
23 #include "gl_video_view.h"
24 #include "system_information_dialog.h"
25 #include "wx_util.h"
26
27
28 #ifdef DCPOMATIC_OSX
29 #include <OpenGL/glu.h>
30 #include <OpenGL/glext.h>
31 #else
32 #include <GL/glu.h>
33 #include <GL/glext.h>
34 #endif
35
36
37 using std::string;
38 using std::weak_ptr;
39 using std::shared_ptr;
40
41
42 #if wxCHECK_VERSION(3, 1, 0)
43
44 SystemInformationDialog::SystemInformationDialog (wxWindow* parent, weak_ptr<FilmViewer> weak_viewer)
45         : TableDialog (parent, _("System information"), 2, 1, false)
46 {
47         auto viewer = weak_viewer.lock ();
48         shared_ptr<const GLVideoView> gl;
49         if (viewer) {
50                 gl = std::dynamic_pointer_cast<const GLVideoView>(viewer->video_view());
51         }
52
53         if (!gl) {
54                 add (_("OpenGL version"), true);
55                 add (_("unknown (OpenGL not enabled in DCP-o-matic)"), false);
56         } else {
57
58                 auto information = gl->information();
59                 auto add_string = [this, &information](GLenum name, wxString label) {
60                         add (label, true);
61                         auto i = information.find(name);
62                         if (i != information.end()) {
63                                 add (std_to_wx(i->second), false);
64                         } else {
65                                 add (_("unknown"), false);
66                         }
67                 };
68
69                 add_string (GL_VENDOR, _("Vendor"));
70                 add_string (GL_RENDERER, _("Renderer"));
71                 add_string (GL_VERSION, _("Version"));
72                 add_string (GL_SHADING_LANGUAGE_VERSION, _("Shading language version"));
73
74                 add (_("vsync"), true);
75                 add (gl->vsync_enabled() ? _("enabled") : _("not enabled"), false);
76         }
77
78         layout ();
79 }
80
81 #else
82
83 SystemInformationDialog::SystemInformationDialog (wxWindow* parent, weak_ptr<FilmViewer>)
84         : TableDialog (parent, _("System information"), 2, 1, false)
85 {
86         add (_("OpenGL version"), true);
87         add (_("OpenGL renderer not supported by this DCP-o-matic version"), false);
88 }
89
90 #endif