|
@@ -35,6 +35,7 @@
|
|
|
|
|
|
#include "core/string/print_string.h"
|
|
#include "core/string/print_string.h"
|
|
#include "core/string/ustring.h"
|
|
#include "core/string/ustring.h"
|
|
|
|
+#include "core/variant/dictionary.h"
|
|
|
|
|
|
#include <windows.h>
|
|
#include <windows.h>
|
|
|
|
|
|
@@ -64,9 +65,11 @@ typedef HGLRC(APIENTRY *PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC, HGLRC, const int
|
|
typedef void *(APIENTRY *PFNWGLGETPROCADDRESS)(LPCSTR);
|
|
typedef void *(APIENTRY *PFNWGLGETPROCADDRESS)(LPCSTR);
|
|
typedef const char *(APIENTRY *PFNWGLGETSTRINGPROC)(unsigned int);
|
|
typedef const char *(APIENTRY *PFNWGLGETSTRINGPROC)(unsigned int);
|
|
|
|
|
|
-int detect_wgl_version() {
|
|
|
|
- int major = 0;
|
|
|
|
- int minor = 0;
|
|
|
|
|
|
+Dictionary detect_wgl() {
|
|
|
|
+ Dictionary gl_info;
|
|
|
|
+ gl_info["version"] = 0;
|
|
|
|
+ gl_info["vendor"] = String();
|
|
|
|
+ gl_info["name"] = String();
|
|
|
|
|
|
PFNWGLCREATECONTEXT gd_wglCreateContext;
|
|
PFNWGLCREATECONTEXT gd_wglCreateContext;
|
|
PFNWGLMAKECURRENT gd_wglMakeCurrent;
|
|
PFNWGLMAKECURRENT gd_wglMakeCurrent;
|
|
@@ -75,14 +78,14 @@ int detect_wgl_version() {
|
|
|
|
|
|
HMODULE module = LoadLibraryW(L"opengl32.dll");
|
|
HMODULE module = LoadLibraryW(L"opengl32.dll");
|
|
if (!module) {
|
|
if (!module) {
|
|
- return 0;
|
|
|
|
|
|
+ return gl_info;
|
|
}
|
|
}
|
|
gd_wglCreateContext = (PFNWGLCREATECONTEXT)GetProcAddress(module, "wglCreateContext");
|
|
gd_wglCreateContext = (PFNWGLCREATECONTEXT)GetProcAddress(module, "wglCreateContext");
|
|
gd_wglMakeCurrent = (PFNWGLMAKECURRENT)GetProcAddress(module, "wglMakeCurrent");
|
|
gd_wglMakeCurrent = (PFNWGLMAKECURRENT)GetProcAddress(module, "wglMakeCurrent");
|
|
gd_wglDeleteContext = (PFNWGLDELETECONTEXT)GetProcAddress(module, "wglDeleteContext");
|
|
gd_wglDeleteContext = (PFNWGLDELETECONTEXT)GetProcAddress(module, "wglDeleteContext");
|
|
gd_wglGetProcAddress = (PFNWGLGETPROCADDRESS)GetProcAddress(module, "wglGetProcAddress");
|
|
gd_wglGetProcAddress = (PFNWGLGETPROCADDRESS)GetProcAddress(module, "wglGetProcAddress");
|
|
if (!gd_wglCreateContext || !gd_wglMakeCurrent || !gd_wglDeleteContext || !gd_wglGetProcAddress) {
|
|
if (!gd_wglCreateContext || !gd_wglMakeCurrent || !gd_wglDeleteContext || !gd_wglGetProcAddress) {
|
|
- return 0;
|
|
|
|
|
|
+ return gl_info;
|
|
}
|
|
}
|
|
|
|
|
|
LPCWSTR class_name = L"EngineWGLDetect";
|
|
LPCWSTR class_name = L"EngineWGLDetect";
|
|
@@ -151,8 +154,8 @@ int detect_wgl_version() {
|
|
};
|
|
};
|
|
const char *version = (const char *)gd_wglGetString(WGL_VERSION);
|
|
const char *version = (const char *)gd_wglGetString(WGL_VERSION);
|
|
if (version) {
|
|
if (version) {
|
|
- const String device_vendor = String::utf8((const char *)gd_wglGetString(WGL_VENDOR)).strip_edges();
|
|
|
|
- const String device_name = String::utf8((const char *)gd_wglGetString(WGL_RENDERER)).strip_edges();
|
|
|
|
|
|
+ const String device_vendor = String::utf8((const char *)gd_wglGetString(WGL_VENDOR)).strip_edges().trim_suffix(" Corporation");
|
|
|
|
+ const String device_name = String::utf8((const char *)gd_wglGetString(WGL_RENDERER)).strip_edges().trim_suffix("/PCIe/SSE2");
|
|
for (int i = 0; prefixes[i]; i++) {
|
|
for (int i = 0; prefixes[i]; i++) {
|
|
size_t length = strlen(prefixes[i]);
|
|
size_t length = strlen(prefixes[i]);
|
|
if (strncmp(version, prefixes[i], length) == 0) {
|
|
if (strncmp(version, prefixes[i], length) == 0) {
|
|
@@ -160,12 +163,17 @@ int detect_wgl_version() {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ int major = 0;
|
|
|
|
+ int minor = 0;
|
|
#ifdef _MSC_VER
|
|
#ifdef _MSC_VER
|
|
sscanf_s(version, "%d.%d", &major, &minor);
|
|
sscanf_s(version, "%d.%d", &major, &minor);
|
|
#else
|
|
#else
|
|
sscanf(version, "%d.%d", &major, &minor);
|
|
sscanf(version, "%d.%d", &major, &minor);
|
|
#endif
|
|
#endif
|
|
print_verbose(vformat("Native OpenGL API detected: %d.%d: %s - %s", major, minor, device_vendor, device_name));
|
|
print_verbose(vformat("Native OpenGL API detected: %d.%d: %s - %s", major, minor, device_vendor, device_name));
|
|
|
|
+ gl_info["vendor"] = device_vendor;
|
|
|
|
+ gl_info["name"] = device_name;
|
|
|
|
+ gl_info["version"] = major * 10000 + minor;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -183,7 +191,7 @@ int detect_wgl_version() {
|
|
}
|
|
}
|
|
UnregisterClassW(class_name, hInstance);
|
|
UnregisterClassW(class_name, hInstance);
|
|
|
|
|
|
- return major * 10000 + minor;
|
|
|
|
|
|
+ return gl_info;
|
|
}
|
|
}
|
|
|
|
|
|
#endif // WINDOWS_ENABLED && GLES3_ENABLED
|
|
#endif // WINDOWS_ENABLED && GLES3_ENABLED
|