From 400365d8317128f6096dd7cab3f55e94ca97fe45 Mon Sep 17 00:00:00 2001 From: Grigori Goronzy Date: Sun, 27 Sep 2009 04:15:41 +0000 Subject: [PATCH] Move OpenGL code down into Platform as it's portable now Originally committed to SVN as r3592. --- aegisub/reporter/include/platform.h | 18 ++++++++--- aegisub/reporter/platform.cpp | 49 +++++++++++++++++++++++++++++ aegisub/reporter/platform_unix.cpp | 47 --------------------------- aegisub/reporter/platform_unix.h | 12 +------ 4 files changed, 64 insertions(+), 62 deletions(-) diff --git a/aegisub/reporter/include/platform.h b/aegisub/reporter/include/platform.h index c6a28aa82..4c92e4a9d 100644 --- a/aegisub/reporter/include/platform.h +++ b/aegisub/reporter/include/platform.h @@ -181,22 +181,22 @@ public: /// Video card /// @return Video card description /// @retval Any - virtual wxString Video()=0; + virtual wxString Video(); /// Video card /// @return Video card vendor /// @retval Any - virtual wxString VideoVendor()=0; + virtual wxString VideoVendor(); /// Video card renderer /// @return Video card renderer name /// @retval Any - virtual wxString VideoRenderer()=0; + virtual wxString VideoRenderer(); /// Video card version /// @return Video card renderer version /// @retval Any - virtual wxString VideoVersion()=0; + virtual wxString VideoVersion(); //@} /// @name Windows @@ -294,10 +294,20 @@ public: private: void Init(); + void GetVideoInfo(); /// wxPlatformInfo struct. const wxPlatformInfo plat; /// wxLocale instance. wxLocale *locale; + + /// Video vendor + wxString vendor; + + /// Video renderer + wxString renderer; + + /// Video API/driver version + wxString version; }; diff --git a/aegisub/reporter/platform.cpp b/aegisub/reporter/platform.cpp index 78e123076..1b194614c 100644 --- a/aegisub/reporter/platform.cpp +++ b/aegisub/reporter/platform.cpp @@ -19,9 +19,12 @@ /// @ingroup base #ifndef R_PRECOMP +#include +#include #include // Display* functions. #include // Version info. #include // Locale info. +#include #endif #include "include/platform.h" @@ -30,6 +33,16 @@ #include "platform_unix_linux.h" #include "platform_unix_osx.h" +extern "C" { +#ifdef __WXMAC__ +#include "OpenGL/glu.h" +#include "OpenGL/gl.h" +#else +#include +#include +#endif +} + /// @brief Constructor. Platform* Platform::GetPlatform() { @@ -52,6 +65,26 @@ Platform* Platform::GetPlatform() { void Platform::Init() { locale = new wxLocale(); locale->Init(); + GetVideoInfo(); +} + +/** + * @brief Gather video adapter information via OpenGL + * + */ +void Platform::GetVideoInfo() { + int attList[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, 0 }; + wxGLCanvas *glc = new wxGLCanvas(wxTheApp->GetTopWindow(), wxID_ANY, attList, wxDefaultPosition, wxDefaultSize); + wxGLContext *ctx = new wxGLContext(glc, 0); + wxGLCanvas &cr = *glc; + ctx->SetCurrent(cr); + + vendor = wxString(glGetString(GL_VENDOR)); + renderer = wxString(glGetString(GL_RENDERER)); + version = wxString(glGetString(GL_VERSION)); + + delete ctx; + delete glc; } wxString Platform::ArchName() { @@ -118,6 +151,22 @@ wxString Platform::DesktopEnvironment() { return ""; } +wxString Platform::Video() { + return wxString::Format("%s %s (%s)", vendor, renderer, version); +} + +wxString Platform::VideoVendor() { + return vendor; +} + +wxString Platform::VideoRenderer() { + return renderer; +} + +wxString Platform::VideoVersion() { + return version; +} + #ifdef __APPLE__ wxString Platform::PatchLevel() { diff --git a/aegisub/reporter/platform_unix.cpp b/aegisub/reporter/platform_unix.cpp index dbabdcd10..fd4278686 100644 --- a/aegisub/reporter/platform_unix.cpp +++ b/aegisub/reporter/platform_unix.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #endif #include "include/platform.h" @@ -30,39 +29,9 @@ extern "C" { #include -#ifdef __WXMAC__ -#include "OpenGL/glu.h" -#include "OpenGL/gl.h" -#else -#include -#include -#endif } - -PlatformUnix::PlatformUnix() { - GetVideoInfo(); -} - -/** - * @brief Gather video adapter information via OpenGL - * - */ -void PlatformUnix::GetVideoInfo() { - int attList[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, 0 }; - wxGLCanvas *glc = new wxGLCanvas(wxTheApp->GetTopWindow(), wxID_ANY, attList, wxDefaultPosition, wxDefaultSize); - wxGLContext *ctx = new wxGLContext(glc, 0); - ctx->SetCurrent(glc); - - vendor = wxString(glGetString(GL_VENDOR)); - renderer = wxString(glGetString(GL_RENDERER)); - version = wxString(glGetString(GL_VERSION)); - - delete ctx; - delete glc; -} - wxString PlatformUnix::OSVersion() { struct utsname name; if (uname(&name) != -1) { @@ -103,22 +72,6 @@ wxString PlatformUnix::Memory() { return ""; }; -wxString PlatformUnix::Video() { - return wxString::Format("%s %s (%s)", vendor, renderer, version); -} - -wxString PlatformUnix::VideoVendor() { - return vendor; -}; - -wxString PlatformUnix::VideoRenderer() { - return renderer; -}; - -wxString PlatformUnix::VideoVersion() { - return version; -}; - wxString PlatformUnix::UnixLibraries() { return ""; }; diff --git a/aegisub/reporter/platform_unix.h b/aegisub/reporter/platform_unix.h index f85ef9d9f..7cf2329da 100644 --- a/aegisub/reporter/platform_unix.h +++ b/aegisub/reporter/platform_unix.h @@ -23,7 +23,7 @@ class Platform; /// @brief General Unix functions. class PlatformUnix : public Platform { public: - PlatformUnix(); + PlatformUnix() {}; virtual ~PlatformUnix() {}; wxString OSVersion(); wxString DesktopEnvironment(); @@ -36,17 +36,7 @@ public: virtual wxString CPUFeatures(); virtual wxString CPUFeatures2(); virtual wxString Memory(); - virtual wxString Video(); - virtual wxString VideoVendor(); - virtual wxString VideoRenderer(); - virtual wxString VideoVersion(); // Unix Specific virtual wxString UnixLibraries(); - -private: - virtual void GetVideoInfo(); - wxString vendor; - wxString renderer; - wxString version; };