Switch GetVideoInfo to use an enum and return a single value rather than use private member variables. There are a few reasons for this:

* Over time too many private member variables will be hard to look at.
 * Speed isn't a concern, but code managability is.
 * I opted to create a custom enum rather than use GLenum to avoid polluting platform.h with OpenGL headers.

Originally committed to SVN as r3594.
This commit is contained in:
Amar Takhar 2009-09-27 09:50:04 +00:00
parent c32899df9a
commit b2a7247d01
2 changed files with 26 additions and 18 deletions

View file

@ -287,22 +287,20 @@ public:
#endif #endif
//@} //@}
// Available video information.
enum VideoInfo {
VIDEO_RENDERER, ///< Renderer
VIDEO_VENDOR, ///< Vendor
VIDEO_VERSION ///< Version
};
private: private:
void Init(); void Init();
void GetVideoInfo(); wxString GetVideoInfo(enum Platform::VideoInfo which);
/// wxPlatformInfo struct. /// wxPlatformInfo struct.
const wxPlatformInfo plat; const wxPlatformInfo plat;
/// wxLocale instance. /// wxLocale instance.
wxLocale *locale; wxLocale *locale;
/// Video vendor
wxString vendor;
/// Video renderer
wxString renderer;
/// Video API/driver version
wxString version;
}; };

View file

@ -65,26 +65,36 @@ Platform* Platform::GetPlatform() {
void Platform::Init() { void Platform::Init() {
locale = new wxLocale(); locale = new wxLocale();
locale->Init(); locale->Init();
GetVideoInfo();
} }
/** /**
* @brief Gather video adapter information via OpenGL * @brief Gather video adapter information via OpenGL
* *
*/ */
void Platform::GetVideoInfo() { wxString Platform::GetVideoInfo(enum Platform::VideoInfo which) {
int attList[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, 0 }; int attList[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, 0 };
wxGLCanvas *glc = new wxGLCanvas(wxTheApp->GetTopWindow(), wxID_ANY, attList, wxDefaultPosition, wxDefaultSize); wxGLCanvas *glc = new wxGLCanvas(wxTheApp->GetTopWindow(), wxID_ANY, attList, wxDefaultPosition, wxDefaultSize);
wxGLContext *ctx = new wxGLContext(glc, 0); wxGLContext *ctx = new wxGLContext(glc, 0);
wxGLCanvas &cr = *glc; wxGLCanvas &cr = *glc;
ctx->SetCurrent(cr); ctx->SetCurrent(cr);
vendor = wxString(glGetString(GL_VENDOR)); wxString value;
renderer = wxString(glGetString(GL_RENDERER));
version = wxString(glGetString(GL_VERSION)); switch (which) {
case VIDEO_RENDERER:
value = wxString(glGetString(GL_RENDERER));
break;
case VIDEO_VENDOR:
value = wxString(glGetString(GL_VENDOR));
break;
case VIDEO_VERSION:
value = wxString(glGetString(GL_VERSION));
}
delete ctx; delete ctx;
delete glc; delete glc;
return value;
} }
wxString Platform::ArchName() { wxString Platform::ArchName() {
@ -152,15 +162,15 @@ wxString Platform::DesktopEnvironment() {
} }
wxString Platform::VideoVendor() { wxString Platform::VideoVendor() {
return vendor; return GetVideoInfo(VIDEO_VENDOR);
} }
wxString Platform::VideoRenderer() { wxString Platform::VideoRenderer() {
return renderer; return GetVideoInfo(VIDEO_RENDERER);
} }
wxString Platform::VideoVersion() { wxString Platform::VideoVersion() {
return version; return GetVideoInfo(VIDEO_VERSION);
} }
#ifdef __APPLE__ #ifdef __APPLE__