From 768198600907c473d65f97395bd53d9df2da4834 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Thu, 25 Nov 2010 19:06:00 +0000 Subject: [PATCH] More debugging output. --- log.cpp | 6 +----- opengl32.py | 8 +++++++- os.hpp | 5 ++++- os_posix.cpp | 7 +++++-- os_win32.cpp | 14 +++++++++++--- wglapi.py | 4 ++++ 6 files changed, 32 insertions(+), 12 deletions(-) diff --git a/log.cpp b/log.cpp index 23a3393..719666f 100644 --- a/log.cpp +++ b/log.cpp @@ -86,11 +86,7 @@ static void _Open(const char *szExtension) { } } - { - char szMessage[PATH_MAX]; - snprintf(szMessage, PATH_MAX, "Tracing to %s\n", szFileName); - OS::DebugMessage(szMessage); - } + OS::DebugMessage("apitrace: tracing to %s\n", szFileName); g_gzFile = gzopen(szFileName, "wb"); } diff --git a/opengl32.py b/opengl32.py index cf1dc2a..b5f94f3 100644 --- a/opengl32.py +++ b/opengl32.py @@ -410,13 +410,18 @@ class WglTracer(Tracer): def wrap_ret(self, function, instance): if function.name == "wglGetProcAddress": print ' if (%s) {' % instance + else_ = '' for f in wglapi.functions: ptype = self.function_pointer_type(f) pvalue = self.function_pointer_value(f) - print ' if (!strcmp("%s", lpszProc)) {' % f.name + print ' %sif (!strcmp("%s", lpszProc)) {' % (else_, f.name) print ' %s = (%s)%s;' % (pvalue, ptype, instance) print ' %s = (%s)&%s;' % (instance, function.type, f.name); print ' }' + else_ = 'else ' + print ' %s{' % (else_,) + print ' OS::DebugMessage("apitrace: unknown function \\"%s\\"\\n", lpszProc);' + print ' }' print ' }' @@ -427,6 +432,7 @@ if __name__ == '__main__': print '#include "glimports.hpp"' print print '#include "log.hpp"' + print '#include "os.hpp"' print '#include "glsize.hpp"' print print '#ifndef PFD_SUPPORT_DIRECTDRAW' diff --git a/os.hpp b/os.hpp index 94d0cf3..52f70eb 100644 --- a/os.hpp +++ b/os.hpp @@ -26,6 +26,9 @@ #ifndef _OS_HPP_ #define _OS_HPP_ +#include +#include + #ifdef WIN32 #ifndef snprintf #define snprintf _snprintf @@ -51,7 +54,7 @@ void ReleaseMutex(void); bool GetProcessName(char *str, size_t size); bool GetCurrentDir(char *str, size_t size); -void DebugMessage(const char *str); +void DebugMessage(const char *format, ...); void Abort(void); diff --git a/os_posix.cpp b/os_posix.cpp index 3f423fe..590738f 100644 --- a/os_posix.cpp +++ b/os_posix.cpp @@ -88,10 +88,13 @@ GetCurrentDir(char *str, size_t size) } void -DebugMessage(const char *message) +DebugMessage(const char *format, ...) { + va_list ap; + va_start(ap, format); fflush(stdout); - fputs(message, stderr); + vfprintf(stderr, format, ap); + va_end(ap); } void diff --git a/os_win32.cpp b/os_win32.cpp index 0849ab0..5f8dddf 100644 --- a/os_win32.cpp +++ b/os_win32.cpp @@ -89,12 +89,20 @@ GetCurrentDir(char *str, size_t size) } void -DebugMessage(const char *message) +DebugMessage(const char *format, ...) { - OutputDebugStringA(message); + char buf[4096]; + + va_list ap; + va_start(ap, format); + fflush(stdout); + vsnprintf(buf, sizeof buf, format, ap); + va_end(ap); + + OutputDebugStringA(buf); if (!IsDebuggerPresent()) { fflush(stdout); - fputs(message, stderr); + fputs(buf, stderr); fflush(stderr); } } diff --git a/wglapi.py b/wglapi.py index e5611b2..481a4fe 100644 --- a/wglapi.py +++ b/wglapi.py @@ -261,6 +261,10 @@ wglapi.add_functions([ StdFunction(BOOL, "wglSwapIntervalEXT", [(Int, "interval")]), StdFunction(Int, "wglGetSwapIntervalEXT", [], sideeffects=False), + # WGL_NV_vertex_array_range + StdFunction(OpaquePointer(Void), "wglAllocateMemoryNV", [(GLsizei, "size"), (GLfloat, "readfreq"), (GLfloat, "writefreq"), (GLfloat, "priority")]), + StdFunction(Void, "wglFreeMemoryNV", [(OpaquePointer(Void), "pointer")]), + # must be last StdFunction(PROC, "wglGetProcAddress", [(LPCSTR, "lpszProc")]), ]) -- 2.45.2