]> git.cworth.org Git - apitrace/blobdiff - os_win32.cpp
Handle vertex attriv locations correctly.
[apitrace] / os_win32.cpp
old mode 100755 (executable)
new mode 100644 (file)
index 98e397b..f220ae5
@@ -25,6 +25,7 @@
 
 #include <windows.h>
 #include <string.h>
+#include <stdio.h>
 
 #include "os.hpp"
 
@@ -69,7 +70,7 @@ GetProcessName(char *str, size_t size)
 
     lpProcessExt = strrchr(lpProcessName, '.');
     if (lpProcessExt) {
-       *lpProcessExt = '\0';
+        *lpProcessExt = '\0';
     }
 
     strncpy(str, lpProcessName, size);
@@ -77,5 +78,59 @@ GetProcessName(char *str, size_t size)
     return true;
 }
 
+bool
+GetCurrentDir(char *str, size_t size)
+{
+    DWORD ret;
+    ret = GetCurrentDirectoryA(size, str);
+    str[size - 1] = 0;
+    return ret == 0 ? false : true;
+}
+
+void
+DebugMessage(const char *format, ...)
+{
+    char buf[4096];
+
+    va_list ap;
+    va_start(ap, format);
+    fflush(stdout);
+    vsnprintf(buf, sizeof buf, format, ap);
+    va_end(ap);
+
+    OutputDebugStringA(buf);
+
+    /*
+     * Also write the message to stderr, when a debugger is not present (to
+     * avoid duplicate messages in command line debuggers).
+     */
+#if _WIN32_WINNT > 0x0400
+    if (!IsDebuggerPresent()) {
+        fflush(stdout);
+        fputs(buf, stderr);
+        fflush(stderr);
+    }
+#endif
+}
+
+long long GetTime(void)
+{
+    static LARGE_INTEGER frequency;
+    LARGE_INTEGER counter;
+    if (!frequency.QuadPart)
+        QueryPerformanceFrequency(&frequency);
+    QueryPerformanceCounter(&counter);
+    return counter.QuadPart*1000000LL/frequency.QuadPart;
+}
+
+void
+Abort(void)
+{
+#ifndef NDEBUG
+    DebugBreak();
+#else
+    ExitProcess(0);
+#endif
+}
 
 } /* namespace OS */