12-22-2025, 11:35 PM
Save this as "GDK_PC_Info.h" in youre Qb64 folder
and then run this to see what (and to what degree) your system supports GL/Dx/Vulkan
This is a "Dumbed down" rendition of how GDK gets the info to set it rendering mode.
Unseen
Code: (Select All)
#ifndef GDK_PC_INFO_H
#define GDK_PC_INFO_H
#include <windows.h>
// Function signatures for Dynamic Loading
typedef HRESULT (WINAPI* PFN_D3D11_CREATE_DEVICE)(void*, int, void*, UINT, void*, UINT, UINT, void**, void*, void**);
typedef HRESULT (WINAPI* PFN_D3D12_CREATE_DEVICE)(void*, int, const GUID&, void**);
typedef const unsigned char* (WINAPI* PFN_GL_GET_STRING)(unsigned int);
#define DLLEXPORT extern "C" __declspec(dllexport)
static int g_modes[10];
static int g_versions[10];
// Internal helper for OpenGL
void CheckOpenGL(int* major, int* minor) {
HMODULE hGL = LoadLibraryA("opengl32.dll");
if (!hGL) return;
auto pglGetString = (PFN_GL_GET_STRING)GetProcAddress(hGL, "glGetString");
auto pwglCreateContext = (void* (WINAPI*)(void*))GetProcAddress(hGL, "wglCreateContext");
auto pwglMakeCurrent = (int (WINAPI*)(void*, void*))GetProcAddress(hGL, "wglMakeCurrent");
auto pwglDeleteContext = (int (WINAPI*)(void*))GetProcAddress(hGL, "wglDeleteContext");
// Create a dummy window to initialize a context
HWND dummyW = CreateWindowA("STATIC", "GDK_GL_PROBE", 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
HDC hdc = GetDC(dummyW);
PIXELFORMATDESCRIPTOR pfd = { sizeof(pfd), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, 32 };
SetPixelFormat(hdc, ChoosePixelFormat(hdc, &pfd), &pfd);
void* hrc = pwglCreateContext(hdc);
if (hrc) {
pwglMakeCurrent(hdc, hrc);
const char* verStr = (const char*)pglGetString(0x1F02); // 0x1F02 = GL_VERSION
if (verStr) {
sscanf(verStr, "%d.%d", major, minor);
}
pwglMakeCurrent(NULL, NULL);
pwglDeleteContext(hrc);
}
ReleaseDC(dummyW, hdc);
DestroyWindow(dummyW);
FreeLibrary(hGL);
}
DLLEXPORT void GDK_Scan_System() {
for(int i=0; i<10; i++) { g_modes[i] = 0; g_versions[i] = 0; }
// --- Index 0: OpenGL ---
int glMaj = 0, glMin = 0;
CheckOpenGL(&glMaj, &glMin);
if (glMaj > 0) {
g_modes[0] = 1;
g_versions[0] = (glMaj * 100) + (glMin * 10); // e.g., 4.6 becomes 460
}
// --- Index 1: DX11 ---
HMODULE hD3D11 = LoadLibraryA("d3d11.dll");
if (hD3D11) {
auto pD3D11CreateDevice = (PFN_D3D11_CREATE_DEVICE)GetProcAddress(hD3D11, "D3D11CreateDevice");
void* device = nullptr; int fl = 0;
if (pD3D11CreateDevice && SUCCEEDED(pD3D11CreateDevice(NULL, 1, NULL, 0, NULL, 0, 7, &device, &fl, NULL))) {
g_modes[1] = 1;
g_versions[1] = fl;
}
FreeLibrary(hD3D11);
}
// --- Index 2: DX12 ---
HMODULE hD3D12 = LoadLibraryA("d3d12.dll");
if (hD3D12) {
auto pD3D12CreateDevice = (PFN_D3D12_CREATE_DEVICE)GetProcAddress(hD3D12, "D3D12CreateDevice");
void* device = nullptr;
GUID iid_dx12 = {0x189819f1, 0x1db6, 0x4b5e, {0x85, 0x46, 0x7b, 0x8d, 0x1d, 0x6e, 0x8a, 0x1f}};
if (pD3D12CreateDevice && SUCCEEDED(pD3D12CreateDevice(NULL, 0x3000, iid_dx12, &device))) {
g_modes[2] = 1;
}
FreeLibrary(hD3D12);
}
// --- Index 3: Vulkan ---
HMODULE hVK = LoadLibraryA("vulkan-1.dll");
if (hVK) { g_modes[3] = 1; FreeLibrary(hVK); }
}
DLLEXPORT int GDK_Get_Mode_Supported(int index) {
return (index >= 0 && index < 10) ? g_modes[index] : 0;
}
DLLEXPORT int GDK_Get_Version_Data(int index) {
return (index >= 0 && index < 10) ? g_versions[index] : 0;
}
#endif
and then run this to see what (and to what degree) your system supports GL/Dx/Vulkan
Code: (Select All)
' Note the casing matches the file on disk exactly
DECLARE LIBRARY "GDK_PC_Info"
SUB GDK_Scan_System ()
FUNCTION GDK_Get_Mode_Supported% (BYVAL index AS LONG)
FUNCTION GDK_Get_Version_Data% (BYVAL index AS LONG)
END DECLARE
CLS
PRINT "Scanning ATI/AMD Hardware..."
GDK_Scan_System
' Display Results
IF GDK_Get_Mode_Supported%(0) THEN
PRINT "OpenGL: Supported (Version Data: "; GDK_Get_Version_Data%(0); ")"
END IF
IF GDK_Get_Mode_Supported%(1) THEN PRINT "DirectX 11: Supported"
IF GDK_Get_Mode_Supported%(2) THEN PRINT "DirectX 12: Supported"
IF GDK_Get_Mode_Supported%(5) THEN PRINT " -> Hardware RayTracing: ENABLED"
IF GDK_Get_Mode_Supported%(3) THEN PRINT "Vulkan: Supported (Driver Found)"
PRINT: PRINT "Scan Complete."
This is a "Dumbed down" rendition of how GDK gets the info to set it rendering mode.
Unseen

