diff options
author | Mikkel Krautz <mikkel@krautz.dk> | 2010-03-31 16:39:42 +0400 |
---|---|---|
committer | Mikkel Krautz <mikkel@krautz.dk> | 2010-03-31 16:40:01 +0400 |
commit | 335ab7b0f994f185917f55210c9ae794d61b43cb (patch) | |
tree | 5f73308afa898b4ecfd74bfdad68b92c3120a476 /macx | |
parent | 9b296bcc42a8117da9b7bf110cc2c1b3925c2fcf (diff) |
Add GL symbol availability checking to OSX overlay.
Diffstat (limited to 'macx')
-rw-r--r-- | macx/overlay/avail.h | 49 | ||||
-rw-r--r-- | macx/overlay/avail.pl | 18 | ||||
-rw-r--r-- | macx/overlay/overlay.m | 20 |
3 files changed, 74 insertions, 13 deletions
diff --git a/macx/overlay/avail.h b/macx/overlay/avail.h new file mode 100644 index 000000000..1f2444ae4 --- /dev/null +++ b/macx/overlay/avail.h @@ -0,0 +1,49 @@ +#define AVAIL_ALL_GLSYM ( \ + AVAIL(glTexImage2D) && \ + AVAIL(glCreateShader) && \ + AVAIL(glLinkProgram) && \ + AVAIL(glActiveTexture) && \ + AVAIL(glViewport) && \ + AVAIL(glEnableClientState) && \ + AVAIL(glOrtho) && \ + AVAIL(glGetIntegerv) && \ + AVAIL(glCompileShader) && \ + AVAIL(glGetString) && \ + AVAIL(glPopAttrib) && \ + AVAIL(glPushClientAttrib) && \ + AVAIL(glAttachShader) && \ + AVAIL(glEnd) && \ + AVAIL(glDisableClientState) && \ + AVAIL(glUniform1i) && \ + AVAIL(glRenderMode) && \ + AVAIL(glIsTexture) && \ + AVAIL(glTexEnvi) && \ + AVAIL(glGetTexParameterfv) && \ + AVAIL(glPopMatrix) && \ + AVAIL(glDisable) && \ + AVAIL(glBindTexture) && \ + AVAIL(glPushAttrib) && \ + AVAIL(glUseProgram) && \ + AVAIL(glCreateProgram) && \ + AVAIL(glDeleteTextures) && \ + AVAIL(glBegin) && \ + AVAIL(glVertex2f) && \ + AVAIL(glMatrixMode) && \ + AVAIL(glGenTextures) && \ + AVAIL(glGetError) && \ + AVAIL(glBlendFunc) && \ + AVAIL(glPopClientAttrib) && \ + AVAIL(glBindBuffer) && \ + AVAIL(glShaderSource) && \ + AVAIL(glEnable) && \ + AVAIL(glGetShaderInfoLog) && \ + AVAIL(glPixelStorei) && \ + AVAIL(glTexParameterfv) && \ + AVAIL(glTexSubImage2D) && \ + AVAIL(glTexCoord2f) && \ + AVAIL(glGetUniformLocation) && \ + AVAIL(glColorMaterial) && \ + AVAIL(glPushMatrix) && \ + AVAIL(glTexParameteri) && \ + AVAIL(glLoadIdentity) && \ + 1) diff --git a/macx/overlay/avail.pl b/macx/overlay/avail.pl new file mode 100644 index 000000000..abdbac5ce --- /dev/null +++ b/macx/overlay/avail.pl @@ -0,0 +1,18 @@ +#!/usr/bin/perl +# perl avail.pl < overlay.m > avail.h + +%funcs = (); +while (<STDIN>) { + foreach (split(/([ \t])/, $_)) { + @glfunc = ($_ =~ /(gl[A-Z0-9][a-zA-Z0-9]+)/); + foreach $func(@glfunc) { + $funcs{$func} = 1; + } + } +} + +print "#define AVAIL_ALL_GLSYM ( \\\n"; +foreach my $key (keys %funcs) { + print "\tAVAIL($key) && \\\n"; +} +print "\t1)\n"; diff --git a/macx/overlay/overlay.m b/macx/overlay/overlay.m index bd434fe73..e4ccb9dd4 100644 --- a/macx/overlay/overlay.m +++ b/macx/overlay/overlay.m @@ -52,9 +52,9 @@ #include <AGL/AGL.h> #include "mach_override.h" -#include <objc/objc-runtime.h> #include "../../overlay/overlay.h" +#include "avail.h" static bool bDebug = false; @@ -91,6 +91,7 @@ const GLfloat fBorder[] = {0.125f, 0.250f, 0.5f, 0.75f}; static Context *contexts = NULL; +#define AVAIL(name) dlsym(RTLD_DEFAULT,#name) #define FDEF(name) static __typeof__(&name) o##name = NULL FDEF(CGLFlushDrawable); @@ -552,25 +553,18 @@ void CGLFlushDrawableOverride(CGLContextObj ctx) { oCGLFlushDrawable(ctx); } - __attribute__ ((visibility("default"))) __attribute__((constructor)) void MumbleOverlayEntryPoint() { - if (getenv("MUMBLE_OVERLAY_DEBUG")) - bDebug = true; - else - bDebug = false; + bDebug = getenv("MUMBLE_OVERLAY_DEBUG"); - void *cglAvailable = dlsym(RTLD_DEFAULT, "CGLFlushDrawable"); - if (cglAvailable) { + if (AVAIL(CGLFlushDrawable) && AVAIL_ALL_GLSYM) { ods("Attempting to hook CGL"); if (mach_override("_CGLFlushDrawable", NULL, CGLFlushDrawableOverride, (void **) &oCGLFlushDrawable) != 0) { ods("CGLFlushDrawable override failed."); - } + } else + ods("Up running."); } else { - ods("Unable to hook CGL"); - return; + ods("Required entry points not available in process. Not hooking up overlay."); } - - ods("Up running."); } |