X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=wgltrace.py;h=4dfd0f4e32d2b865a43207a7abf7ac4dd242e0d5;hb=4644dc65e83c56ba0bb577f57cd20e7419f3ade4;hp=a1c66bb69b8fb0e989d6de0964eee7729d1f1ff2;hpb=669b12259dfb0c4beaca39f8fe0402ab18a72464;p=apitrace diff --git a/wgltrace.py b/wgltrace.py index a1c66bb..4dfd0f4 100644 --- a/wgltrace.py +++ b/wgltrace.py @@ -27,398 +27,33 @@ """WGL tracing code generator.""" -from stdapi import API -from glapi import glapi -from wglapi import wglapi +from specs.stdapi import API +from specs.glapi import glapi +from specs.wglapi import wglapi +from dispatch import function_pointer_type, function_pointer_value from gltrace import GlTracer from codegen import * -public_symbols = set([ - "glAccum", - "glAlphaFunc", - "glAreTexturesResident", - "glArrayElement", - "glBegin", - "glBindTexture", - "glBitmap", - "glBlendFunc", - "glCallList", - "glCallLists", - "glClear", - "glClearAccum", - "glClearColor", - "glClearDepth", - "glClearIndex", - "glClearStencil", - "glClipPlane", - "glColor3b", - "glColor3bv", - "glColor3d", - "glColor3dv", - "glColor3f", - "glColor3fv", - "glColor3i", - "glColor3iv", - "glColor3s", - "glColor3sv", - "glColor3ub", - "glColor3ubv", - "glColor3ui", - "glColor3uiv", - "glColor3us", - "glColor3usv", - "glColor4b", - "glColor4bv", - "glColor4d", - "glColor4dv", - "glColor4f", - "glColor4fv", - "glColor4i", - "glColor4iv", - "glColor4s", - "glColor4sv", - "glColor4ub", - "glColor4ubv", - "glColor4ui", - "glColor4uiv", - "glColor4us", - "glColor4usv", - "glColorMask", - "glColorMaterial", - "glColorPointer", - "glCopyPixels", - "glCopyTexImage1D", - "glCopyTexImage2D", - "glCopyTexSubImage1D", - "glCopyTexSubImage2D", - "glCullFace", -# "glDebugEntry", - "glDeleteLists", - "glDeleteTextures", - "glDepthFunc", - "glDepthMask", - "glDepthRange", - "glDisable", - "glDisableClientState", - "glDrawArrays", - "glDrawBuffer", - "glDrawElements", - "glDrawPixels", - "glEdgeFlag", - "glEdgeFlagPointer", - "glEdgeFlagv", - "glEnable", - "glEnableClientState", - "glEnd", - "glEndList", - "glEvalCoord1d", - "glEvalCoord1dv", - "glEvalCoord1f", - "glEvalCoord1fv", - "glEvalCoord2d", - "glEvalCoord2dv", - "glEvalCoord2f", - "glEvalCoord2fv", - "glEvalMesh1", - "glEvalMesh2", - "glEvalPoint1", - "glEvalPoint2", - "glFeedbackBuffer", - "glFinish", - "glFlush", - "glFogf", - "glFogfv", - "glFogi", - "glFogiv", - "glFrontFace", - "glFrustum", - "glGenLists", - "glGenTextures", - "glGetBooleanv", - "glGetClipPlane", - "glGetDoublev", - "glGetError", - "glGetFloatv", - "glGetIntegerv", - "glGetLightfv", - "glGetLightiv", - "glGetMapdv", - "glGetMapfv", - "glGetMapiv", - "glGetMaterialfv", - "glGetMaterialiv", - "glGetPixelMapfv", - "glGetPixelMapuiv", - "glGetPixelMapusv", - "glGetPointerv", - "glGetPolygonStipple", - "glGetString", - "glGetTexEnvfv", - "glGetTexEnviv", - "glGetTexGendv", - "glGetTexGenfv", - "glGetTexGeniv", - "glGetTexImage", - "glGetTexLevelParameterfv", - "glGetTexLevelParameteriv", - "glGetTexParameterfv", - "glGetTexParameteriv", - "glHint", - "glIndexMask", - "glIndexPointer", - "glIndexd", - "glIndexdv", - "glIndexf", - "glIndexfv", - "glIndexi", - "glIndexiv", - "glIndexs", - "glIndexsv", - "glIndexub", - "glIndexubv", - "glInitNames", - "glInterleavedArrays", - "glIsEnabled", - "glIsList", - "glIsTexture", - "glLightModelf", - "glLightModelfv", - "glLightModeli", - "glLightModeliv", - "glLightf", - "glLightfv", - "glLighti", - "glLightiv", - "glLineStipple", - "glLineWidth", - "glListBase", - "glLoadIdentity", - "glLoadMatrixd", - "glLoadMatrixf", - "glLoadName", - "glLogicOp", - "glMap1d", - "glMap1f", - "glMap2d", - "glMap2f", - "glMapGrid1d", - "glMapGrid1f", - "glMapGrid2d", - "glMapGrid2f", - "glMaterialf", - "glMaterialfv", - "glMateriali", - "glMaterialiv", - "glMatrixMode", - "glMultMatrixd", - "glMultMatrixf", - "glNewList", - "glNormal3b", - "glNormal3bv", - "glNormal3d", - "glNormal3dv", - "glNormal3f", - "glNormal3fv", - "glNormal3i", - "glNormal3iv", - "glNormal3s", - "glNormal3sv", - "glNormalPointer", - "glOrtho", - "glPassThrough", - "glPixelMapfv", - "glPixelMapuiv", - "glPixelMapusv", - "glPixelStoref", - "glPixelStorei", - "glPixelTransferf", - "glPixelTransferi", - "glPixelZoom", - "glPointSize", - "glPolygonMode", - "glPolygonOffset", - "glPolygonStipple", - "glPopAttrib", - "glPopClientAttrib", - "glPopMatrix", - "glPopName", - "glPrioritizeTextures", - "glPushAttrib", - "glPushClientAttrib", - "glPushMatrix", - "glPushName", - "glRasterPos2d", - "glRasterPos2dv", - "glRasterPos2f", - "glRasterPos2fv", - "glRasterPos2i", - "glRasterPos2iv", - "glRasterPos2s", - "glRasterPos2sv", - "glRasterPos3d", - "glRasterPos3dv", - "glRasterPos3f", - "glRasterPos3fv", - "glRasterPos3i", - "glRasterPos3iv", - "glRasterPos3s", - "glRasterPos3sv", - "glRasterPos4d", - "glRasterPos4dv", - "glRasterPos4f", - "glRasterPos4fv", - "glRasterPos4i", - "glRasterPos4iv", - "glRasterPos4s", - "glRasterPos4sv", - "glReadBuffer", - "glReadPixels", - "glRectd", - "glRectdv", - "glRectf", - "glRectfv", - "glRecti", - "glRectiv", - "glRects", - "glRectsv", - "glRenderMode", - "glRotated", - "glRotatef", - "glScaled", - "glScalef", - "glScissor", - "glSelectBuffer", - "glShadeModel", - "glStencilFunc", - "glStencilMask", - "glStencilOp", - "glTexCoord1d", - "glTexCoord1dv", - "glTexCoord1f", - "glTexCoord1fv", - "glTexCoord1i", - "glTexCoord1iv", - "glTexCoord1s", - "glTexCoord1sv", - "glTexCoord2d", - "glTexCoord2dv", - "glTexCoord2f", - "glTexCoord2fv", - "glTexCoord2i", - "glTexCoord2iv", - "glTexCoord2s", - "glTexCoord2sv", - "glTexCoord3d", - "glTexCoord3dv", - "glTexCoord3f", - "glTexCoord3fv", - "glTexCoord3i", - "glTexCoord3iv", - "glTexCoord3s", - "glTexCoord3sv", - "glTexCoord4d", - "glTexCoord4dv", - "glTexCoord4f", - "glTexCoord4fv", - "glTexCoord4i", - "glTexCoord4iv", - "glTexCoord4s", - "glTexCoord4sv", - "glTexCoordPointer", - "glTexEnvf", - "glTexEnvfv", - "glTexEnvi", - "glTexEnviv", - "glTexGend", - "glTexGendv", - "glTexGenf", - "glTexGenfv", - "glTexGeni", - "glTexGeniv", - "glTexImage1D", - "glTexImage2D", - "glTexParameterf", - "glTexParameterfv", - "glTexParameteri", - "glTexParameteriv", - "glTexSubImage1D", - "glTexSubImage2D", - "glTranslated", - "glTranslatef", - "glVertex2d", - "glVertex2dv", - "glVertex2f", - "glVertex2fv", - "glVertex2i", - "glVertex2iv", - "glVertex2s", - "glVertex2sv", - "glVertex3d", - "glVertex3dv", - "glVertex3f", - "glVertex3fv", - "glVertex3i", - "glVertex3iv", - "glVertex3s", - "glVertex3sv", - "glVertex4d", - "glVertex4dv", - "glVertex4f", - "glVertex4fv", - "glVertex4i", - "glVertex4iv", - "glVertex4s", - "glVertex4sv", - "glVertexPointer", - "glViewport", - "wglChoosePixelFormat", - "wglCopyContext", - "wglCreateContext", - "wglCreateLayerContext", - "wglDeleteContext", - "wglDescribeLayerPlane", - "wglDescribePixelFormat", - "wglGetCurrentContext", - "wglGetCurrentDC", - "wglGetDefaultProcAddress", - "wglGetLayerPaletteEntries", - "wglGetPixelFormat", - "wglGetProcAddress", - "wglMakeCurrent", - "wglRealizeLayerPalette", - "wglSetLayerPaletteEntries", - "wglSetPixelFormat", - "wglShareLists", - "wglSwapBuffers", - "wglSwapLayerBuffers", - "wglSwapMultipleBuffers", - "wglUseFontBitmapsA", - "wglUseFontBitmapsW", - "wglUseFontOutlinesA", - "wglUseFontOutlinesW", -]) - class WglTracer(GlTracer): - def get_function_address(self, function): - return '__%s' % (function.name,) + def wrapRet(self, function, instance): + GlTracer.wrapRet(self, function, instance) - def wrap_ret(self, function, instance): if function.name == "wglGetProcAddress": print ' if (%s) {' % instance - func_dict = dict([(f.name, f) for f in wglapi.functions]) + func_dict = dict([(f.name, f) for f in glapi.functions + wglapi.functions]) def handle_case(function_name): f = func_dict[function_name] - ptype = self.function_pointer_type(f) - pvalue = self.function_pointer_value(f) + ptype = function_pointer_type(f) + pvalue = function_pointer_value(f) print ' %s = (%s)%s;' % (pvalue, ptype, instance) print ' %s = (%s)&%s;' % (instance, function.type, f.name); def handle_default(): - print ' OS::DebugMessage("apitrace: unknown function \\"%s\\"\\n", lpszProc);' + print ' os::log("apitrace: warning: unknown function \\"%s\\"\\n", lpszProc);' string_switch('lpszProc', func_dict.keys(), handle_case, handle_default) print ' }' @@ -431,43 +66,18 @@ if __name__ == '__main__': print '#include ' print '#include ' print - print '#include "trace_write.hpp"' + print '#include "trace_writer_local.hpp"' print '#include "os.hpp"' print - print ''' -static HINSTANCE g_hDll = NULL; - -static PROC -__getPublicProcAddress(LPCSTR lpProcName) -{ - if (!g_hDll) { - char szDll[MAX_PATH] = {0}; - - if (!GetSystemDirectoryA(szDll, MAX_PATH)) { - return NULL; - } - - strcat(szDll, "\\\\opengl32.dll"); - - g_hDll = LoadLibraryA(szDll); - if (!g_hDll) { - return NULL; - } - } - - return GetProcAddress(g_hDll, lpProcName); -} - - ''' + print '// To validate our prototypes' + print '#define GL_GLEXT_PROTOTYPES' + print '#define WGL_GLXEXT_PROTOTYPES' + print print '#include "glproc.hpp"' print '#include "glsize.hpp"' print - print 'extern "C" {' - print api = API() - api.add_api(wglapi) - api.add_api(glapi) + api.addApi(glapi) + api.addApi(wglapi) tracer = WglTracer() tracer.trace_api(api) - print - print '} /* extern "C" */'