init log before everything else, use WMI to read machine and system info, rtt fixed on Samsung A3, try to create different EGL context config
This commit is contained in:
117
engine/main.cpp
117
engine/main.cpp
@@ -262,8 +262,8 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime
|
||||
}
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)notification
|
||||
{
|
||||
auto& app = App::I;
|
||||
app.create();
|
||||
App::I.initLog();
|
||||
App::I.create();
|
||||
NSRect r = NSMakeRect(0, 0, app.width, app.height);
|
||||
|
||||
view = [[View alloc] initWithFrame:r];
|
||||
@@ -308,6 +308,7 @@ int main(int argc, const char * argv[])
|
||||
|
||||
#pragma comment (lib, "opengl32.lib")
|
||||
#pragma comment (lib, "glew32.lib")
|
||||
#pragma comment(lib, "wbemuuid.lib")
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp);
|
||||
HINSTANCE hInst;
|
||||
@@ -317,11 +318,123 @@ HGLRC hRC;
|
||||
wchar_t* className;
|
||||
bool keys[256];
|
||||
|
||||
#include <WbemCli.h>
|
||||
|
||||
int read_WMI_info()
|
||||
{
|
||||
// see: http://win32easy.blogspot.co.uk/2011/03/wmi-in-c-query-everyting-from-your-os.html
|
||||
|
||||
HRESULT hRes = CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
||||
if (FAILED(hRes))
|
||||
{
|
||||
LOG("Unable to launch COM: %x", hRes);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((FAILED(hRes = CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_CONNECT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, 0))))
|
||||
{
|
||||
LOG("Unable to initialize security: %x", hRes);
|
||||
return 1;
|
||||
}
|
||||
|
||||
IWbemLocator* pLocator = NULL;
|
||||
if (FAILED(hRes = CoCreateInstance(CLSID_WbemLocator, NULL, CLSCTX_ALL, IID_PPV_ARGS(&pLocator))))
|
||||
{
|
||||
LOG("Unable to create a WbemLocator: %x", hRes);
|
||||
return 1;
|
||||
}
|
||||
|
||||
IWbemServices* pService = NULL;
|
||||
if (FAILED(hRes = pLocator->ConnectServer(L"root\\CIMV2", NULL, NULL, NULL, WBEM_FLAG_CONNECT_USE_MAX_WAIT, NULL, NULL, &pService)))
|
||||
{
|
||||
pLocator->Release();
|
||||
LOG("Unable to connect to \"CIMV2\": %x", hRes);
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto log_field = [](const wchar_t* section, IWbemClassObject* clsObj, const wchar_t* field) {
|
||||
VARIANT vRet;
|
||||
VariantInit(&vRet);
|
||||
if (SUCCEEDED(clsObj->Get(field, 0, &vRet, NULL, NULL)) && vRet.vt == VT_BSTR)
|
||||
{
|
||||
LOGW(L"%s %s: %s", section, field, vRet.bstrVal);
|
||||
VariantClear(&vRet);
|
||||
}
|
||||
};
|
||||
|
||||
// GET DEVICE INFO
|
||||
{
|
||||
IEnumWbemClassObject* pEnumerator = NULL;
|
||||
if (FAILED(hRes = pService->ExecQuery(L"WQL", L"SELECT * FROM Win32_ComputerSystem", WBEM_FLAG_FORWARD_ONLY, NULL, &pEnumerator)))
|
||||
{
|
||||
pLocator->Release();
|
||||
pService->Release();
|
||||
LOG("Unable to retrive desktop monitors: %x", hRes);
|
||||
return 1;
|
||||
}
|
||||
|
||||
IWbemClassObject* clsObj = NULL;
|
||||
int numElems;
|
||||
while ((hRes = pEnumerator->Next(WBEM_INFINITE, 1, &clsObj, (ULONG*)&numElems)) != WBEM_S_FALSE)
|
||||
{
|
||||
if (FAILED(hRes))
|
||||
break;
|
||||
|
||||
log_field(L"Machine", clsObj, L"Name");
|
||||
log_field(L"Machine", clsObj, L"Model");
|
||||
log_field(L"Machine", clsObj, L"Manufacturer");
|
||||
|
||||
clsObj->Release();
|
||||
}
|
||||
pEnumerator->Release();
|
||||
}
|
||||
|
||||
// GET OS INFO
|
||||
{
|
||||
IEnumWbemClassObject* pEnumerator = NULL;
|
||||
if (FAILED(hRes = pService->ExecQuery(L"WQL", L"SELECT * FROM Win32_OperatingSystem", WBEM_FLAG_FORWARD_ONLY, NULL, &pEnumerator)))
|
||||
{
|
||||
pLocator->Release();
|
||||
pService->Release();
|
||||
LOG("Unable to retrive desktop monitors: %x", hRes);
|
||||
return 1;
|
||||
}
|
||||
|
||||
IWbemClassObject* clsObj = NULL;
|
||||
int numElems;
|
||||
while ((hRes = pEnumerator->Next(WBEM_INFINITE, 1, &clsObj, (ULONG*)&numElems)) != WBEM_S_FALSE)
|
||||
{
|
||||
if (FAILED(hRes))
|
||||
break;
|
||||
|
||||
log_field(L"OS", clsObj, L"Name");
|
||||
log_field(L"OS", clsObj, L"Version");
|
||||
log_field(L"OS", clsObj, L"Locale");
|
||||
log_field(L"OS", clsObj, L"OSProductSuite");
|
||||
log_field(L"OS", clsObj, L"Manufacturer");
|
||||
log_field(L"OS", clsObj, L"Description");
|
||||
|
||||
clsObj->Release();
|
||||
}
|
||||
pEnumerator->Release();
|
||||
}
|
||||
|
||||
pService->Release();
|
||||
pLocator->Release();
|
||||
CoUninitialize();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
WNDCLASS wc;
|
||||
PIXELFORMATDESCRIPTOR pfd;
|
||||
|
||||
App::I.initLog();
|
||||
|
||||
read_WMI_info();
|
||||
|
||||
App::I.create();
|
||||
RECT clientRect = { 0, 0, (int)App::I.width, (int)App::I.height };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user