]> git.cworth.org Git - apitrace/blobdiff - cli/cli_trace.cpp
retrace: Implement glxCopySubBufferMESA
[apitrace] / cli / cli_trace.cpp
index 5903bdc5f7865cd7327a71b9b14f50d97a567e37..078739ddc57918e969f6500577f4576e6256a2ab 100644 (file)
@@ -133,7 +133,26 @@ traceProgram(trace::API api,
     }
 
 #if defined(_WIN32)
-    useInject = true;
+    /*
+     * Use DLL injection method on Windows, even for APIs that don't stricly
+     * need it.  Except when tracing OpenGL on Windows 8, as the injection
+     * method seems to have troubles tracing the internal
+     * gdi32.dll!SwapBuffers -> opengl32.dll!wglSwapBuffer calls, per github
+     * issue #172.
+     */
+    {
+        OSVERSIONINFO osvi;
+        ZeroMemory(&osvi, sizeof osvi);
+        osvi.dwOSVersionInfoSize = sizeof osvi;
+        GetVersionEx(&osvi);
+        BOOL bIsWindows8orLater =
+            osvi.dwMajorVersion > 6 ||
+            (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion >= 2);
+        if (api != trace::API_GL || !bIsWindows8orLater) {
+            useInject = true;
+        }
+    }
+
     if (useInject) {
         args.push_back("inject");
         args.push_back(wrapperPath);
@@ -304,7 +323,7 @@ command(int argc, char *argv[])
             output = optarg;
             break;
         default:
-            std::cerr << "error: unexpected option `" << opt << "`\n";
+            std::cerr << "error: unexpected option `" << (char)opt << "`\n";
             usage();
             return 1;
         }