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
//@}
// Available video information.
enum VideoInfo {
VIDEO_RENDERER, ///< Renderer
VIDEO_VENDOR, ///< Vendor
VIDEO_VERSION ///< Version
};
private:
void Init();
void GetVideoInfo();
wxString GetVideoInfo(enum Platform::VideoInfo which);
/// wxPlatformInfo struct.
const wxPlatformInfo plat;
/// wxLocale instance.
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() {
locale = new wxLocale();
locale->Init();
GetVideoInfo();
}
/**
* @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 };
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));
wxString value;
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 glc;
return value;
}
wxString Platform::ArchName() {
@ -152,15 +162,15 @@ wxString Platform::DesktopEnvironment() {
}
wxString Platform::VideoVendor() {
return vendor;
return GetVideoInfo(VIDEO_VENDOR);
}
wxString Platform::VideoRenderer() {
return renderer;
return GetVideoInfo(VIDEO_RENDERER);
}
wxString Platform::VideoVersion() {
return version;
return GetVideoInfo(VIDEO_VERSION);
}
#ifdef __APPLE__