2009-09-03 08:53:55 +02:00
|
|
|
// Copyright (c) 2009, Amar Takhar <verm@aegisub.org>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice appear in all copies.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
2009-09-26 11:22:54 +02:00
|
|
|
/// @file platform.cpp
|
2009-09-03 08:53:55 +02:00
|
|
|
/// @brief Base functions for the Platform class.
|
2009-09-26 11:38:17 +02:00
|
|
|
/// @ingroup base
|
2009-09-03 08:53:55 +02:00
|
|
|
|
|
|
|
#ifndef R_PRECOMP
|
2009-09-27 06:15:41 +02:00
|
|
|
#include <wx/string.h>
|
|
|
|
#include <wx/app.h>
|
2009-09-03 08:53:55 +02:00
|
|
|
#include <wx/gdicmn.h> // Display* functions.
|
|
|
|
#include <wx/version.h> // Version info.
|
|
|
|
#include <wx/intl.h> // Locale info.
|
2009-09-27 06:15:41 +02:00
|
|
|
#include <wx/glcanvas.h>
|
2009-09-03 08:53:55 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "include/platform.h"
|
2009-10-03 19:45:34 +02:00
|
|
|
#include "platform_windows.h"
|
2009-09-03 08:53:55 +02:00
|
|
|
#include "platform_unix.h"
|
|
|
|
#include "platform_unix_bsd.h"
|
2009-09-26 18:44:36 +02:00
|
|
|
#include "platform_unix_linux.h"
|
2009-09-27 03:47:11 +02:00
|
|
|
#include "platform_unix_osx.h"
|
2009-09-03 08:53:55 +02:00
|
|
|
|
2009-09-27 06:15:41 +02:00
|
|
|
extern "C" {
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
#include "OpenGL/glu.h"
|
|
|
|
#include "OpenGL/gl.h"
|
|
|
|
#else
|
|
|
|
#include <GL/glu.h>
|
|
|
|
#include <GL/gl.h>
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-09-03 08:53:55 +02:00
|
|
|
/// @brief Constructor.
|
|
|
|
Platform* Platform::GetPlatform() {
|
2009-10-03 19:45:34 +02:00
|
|
|
#if defined(__WINDOWS__)
|
|
|
|
Platform *p = new PlatformWindows;
|
|
|
|
#elif defined(__UNIX__)
|
2009-09-26 22:05:54 +02:00
|
|
|
# if defined(__FREEBSD__)
|
2009-09-03 08:53:55 +02:00
|
|
|
Platform *p = new PlatformUnixBSD;
|
2009-09-26 22:05:54 +02:00
|
|
|
# elif defined(__LINUX__)
|
2009-09-26 18:44:36 +02:00
|
|
|
Platform *p = new PlatformUnixLinux;
|
2009-09-27 03:47:11 +02:00
|
|
|
# elif defined(__APPLE__)
|
|
|
|
Platform *p = new PlatformUnixOSX;
|
2009-09-26 22:05:54 +02:00
|
|
|
# else
|
2009-09-03 08:53:55 +02:00
|
|
|
Platform *p = new PlatformUnix;
|
|
|
|
# endif
|
2009-10-03 19:16:52 +02:00
|
|
|
#else
|
|
|
|
Platform *p = NULL;
|
2009-09-03 08:53:55 +02:00
|
|
|
#endif // __UNIX__
|
|
|
|
p->Init();
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// @brief Init variables to avoid duplicate instantiations.
|
|
|
|
void Platform::Init() {
|
|
|
|
locale = new wxLocale();
|
|
|
|
locale->Init();
|
2009-09-27 06:15:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Gather video adapter information via OpenGL
|
|
|
|
*
|
|
|
|
*/
|
2009-09-27 11:50:04 +02:00
|
|
|
wxString Platform::GetVideoInfo(enum Platform::VideoInfo which) {
|
2009-09-27 06:15:41 +02:00
|
|
|
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);
|
|
|
|
|
2009-09-27 11:50:04 +02:00
|
|
|
wxString value;
|
|
|
|
|
|
|
|
switch (which) {
|
2009-09-27 15:26:23 +02:00
|
|
|
case VIDEO_EXT:
|
|
|
|
value = wxString(glGetString(GL_EXTENSIONS));
|
|
|
|
break;
|
2009-09-27 11:50:04 +02:00
|
|
|
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));
|
|
|
|
}
|
2009-09-27 06:15:41 +02:00
|
|
|
|
|
|
|
delete ctx;
|
|
|
|
delete glc;
|
2009-09-27 11:50:04 +02:00
|
|
|
|
|
|
|
return value;
|
2009-09-03 08:53:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
wxString Platform::ArchName() {
|
|
|
|
return plat.GetArchName();
|
|
|
|
};
|
|
|
|
|
|
|
|
wxString Platform::OSFamily() {
|
|
|
|
return plat.GetOperatingSystemFamilyName();
|
|
|
|
};
|
|
|
|
|
|
|
|
wxString Platform::OSName() {
|
|
|
|
return plat.GetOperatingSystemIdName();
|
|
|
|
};
|
|
|
|
|
|
|
|
wxString Platform::Endian() {
|
|
|
|
return plat.GetEndiannessName();
|
|
|
|
};
|
|
|
|
|
|
|
|
wxString Platform::DisplayColour() {
|
|
|
|
return wxString::Format(L"%d", wxColourDisplay());
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString Platform::DisplayDepth() {
|
|
|
|
return wxString::Format(L"%d", wxDisplayDepth());
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString Platform::DisplaySize() {
|
|
|
|
int x, y;
|
|
|
|
wxDisplaySize(&x, &y);
|
|
|
|
return wxString::Format(L"%d %d", x, y);
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString Platform::DisplayPPI() {
|
|
|
|
return wxString::Format(L"%d %d", wxGetDisplayPPI().GetWidth(), wxGetDisplayPPI().GetHeight());
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString Platform::wxVersion() {
|
|
|
|
return wxString::Format(L"%d.%d.%d.%d", wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER, wxSUBRELEASE_NUMBER);
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString Platform::Locale() {
|
|
|
|
return wxLocale().GetSysName();
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString Platform::Language() {
|
|
|
|
const wxLanguageInfo *info = locale->GetLanguageInfo(locale->GetLanguage());
|
|
|
|
return info->CanonicalName;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString Platform::SystemLanguage() {
|
|
|
|
const wxLanguageInfo *info = locale->GetLanguageInfo(locale->GetSystemLanguage());
|
|
|
|
return info->CanonicalName;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString Platform::Date() {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString Platform::Signature() {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2009-10-03 19:16:52 +02:00
|
|
|
#ifdef __UNIX__
|
2009-09-03 08:53:55 +02:00
|
|
|
wxString Platform::DesktopEnvironment() {
|
|
|
|
return "";
|
|
|
|
}
|
2009-10-03 19:16:52 +02:00
|
|
|
#endif
|
2009-09-27 03:47:11 +02:00
|
|
|
|
2009-09-28 10:08:16 +02:00
|
|
|
wxString Platform::OpenGLVendor() {
|
2009-09-27 11:50:04 +02:00
|
|
|
return GetVideoInfo(VIDEO_VENDOR);
|
2009-09-27 06:15:41 +02:00
|
|
|
}
|
|
|
|
|
2009-09-28 10:08:16 +02:00
|
|
|
wxString Platform::OpenGLRenderer() {
|
2009-09-27 11:50:04 +02:00
|
|
|
return GetVideoInfo(VIDEO_RENDERER);
|
2009-09-27 06:15:41 +02:00
|
|
|
}
|
|
|
|
|
2009-09-28 10:08:16 +02:00
|
|
|
wxString Platform::OpenGLVersion() {
|
2009-09-27 11:50:04 +02:00
|
|
|
return GetVideoInfo(VIDEO_VERSION);
|
2009-09-27 06:15:41 +02:00
|
|
|
}
|
|
|
|
|
2009-09-28 10:08:16 +02:00
|
|
|
wxString Platform::OpenGLExt() {
|
2009-09-27 15:26:23 +02:00
|
|
|
return GetVideoInfo(VIDEO_EXT);
|
|
|
|
}
|
|
|
|
|
2009-09-27 04:18:09 +02:00
|
|
|
#ifdef __APPLE__
|
|
|
|
|
2009-09-27 03:47:11 +02:00
|
|
|
wxString Platform::PatchLevel() {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString Platform::QuickTimeExt() {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString Platform::HardwareModel() {
|
|
|
|
return "";
|
|
|
|
}
|
2009-09-27 04:18:09 +02:00
|
|
|
|
|
|
|
#endif
|