summaryrefslogtreecommitdiff
path: root/wrappers/wgltrace.py
diff options
context:
space:
mode:
Diffstat (limited to 'wrappers/wgltrace.py')
-rw-r--r--wrappers/wgltrace.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/wrappers/wgltrace.py b/wrappers/wgltrace.py
index bc79d774..3d958b7c 100644
--- a/wrappers/wgltrace.py
+++ b/wrappers/wgltrace.py
@@ -97,6 +97,63 @@ class WglTracer(GlTracer):
print ' gltrace::clearContext();'
print ' }'
+ # Emit fake glBitmap calls in the trace on wglUseFontBitmapsA.
+ # This enables to capture the real bitmaps and replay them outside Windows.
+ #
+ # XXX: In spite what
+ # https://msdn.microsoft.com/en-us/library/windows/desktop/dd374392.aspx
+ # implies, GetGlyphOutline(GGO_BITMAP) does not seem to work with
+ # certain fonts. The only solution is to draw the font charactors with
+ # a HBITMAP like the old Mesa fxwgl.c code used to do. That too, seems
+ # to be the way that opengl32.dll implements wglUseFontBitmaps.
+ #
+ if function.name == 'wglUseFontBitmapsA':
+ glNewList = glapi.getFunctionByName('glNewList')
+ glBitmap = glapi.getFunctionByName('glBitmap')
+ glEndList = glapi.getFunctionByName('glEndList')
+
+ print r' bool warned = false;'
+ print r' for (DWORD i = 0; i < count; ++i) {'
+ self.fake_call(glNewList, ['listBase + i', 'GL_COMPILE'])
+
+ print r' UINT uChar = first + i;'
+ print r' GLYPHMETRICS gm;'
+ print r' ZeroMemory(&gm, sizeof gm);'
+ print r' static const MAT2 mat2 = {{0, 1}, {0, 0}, {0, 0}, {0, -1}};'
+ print r' DWORD cbBuffer = GetGlyphOutlineA(hdc, uChar, GGO_BITMAP, &gm, 0, NULL, &mat2);'
+ print r' if (cbBuffer == GDI_ERROR) {'
+ print r' if (!warned) {'
+ print r' os::log("apitrace: warning: wglUseFontBitmapsA: GetGlyphOutlineA failed\n");'
+ print r' warned = true;'
+ print r' }'
+ print r' } else {'
+ print r' LPVOID lpvBuffer = NULL;'
+ print r' if (cbBuffer) {'
+ print r' lpvBuffer = malloc(cbBuffer);'
+ print r' DWORD dwRet;'
+ print r' dwRet = GetGlyphOutlineA(hdc, uChar, GGO_BITMAP, &gm, cbBuffer, lpvBuffer, &mat2);'
+ print r' assert(dwRet != GDI_ERROR);'
+ print r' assert(dwRet > 0);'
+ print r' }'
+ print r' GLsizei width = gm.gmBlackBoxX;'
+ print r' GLfloat height = gm.gmBlackBoxY;'
+ print r' GLfloat xorig = -gm.gmptGlyphOrigin.x;'
+ print r' GLfloat yorig = gm.gmptGlyphOrigin.y;'
+ print r' GLfloat xmove = gm.gmCellIncX;'
+ print r' GLfloat ymove = gm.gmCellIncY;'
+ print r' if (cbBuffer == 0) {'
+ print r' // We still need to emit an empty glBitmap for empty characters like spaces;'
+ print r' width = height = xorig = yorig = 0;'
+ print r' }'
+ print r' const GLubyte *bitmap = (const GLubyte *)lpvBuffer;'
+
+ self.fake_call(glBitmap, ['width', 'height', 'xorig', 'yorig', 'xmove', 'ymove', 'bitmap'])
+
+ print r' free(lpvBuffer);'
+ print r' }'
+ self.fake_call(glEndList, [])
+ print r' }'
+
if __name__ == '__main__':
print