From 0f355bdade1f72ec3b4759504e1fe42e01022089 Mon Sep 17 00:00:00 2001 From: Mikkel Krautz Date: Mon, 6 Sep 2010 23:24:10 +0200 Subject: [PATCH] Only disable GL_TEXTURE_GEN_* if they're already enabled. Fixes black screen issue with EVE on OSX (via Cider) --- macx/overlay/avail.h | 1 + macx/overlay/overlay.m | 81 +++++++++++++++++++++++++------------- overlay_gl/overlay.c | 21 +++++++--- src/mumble/Overlay_macx.mm | 4 +- 4 files changed, 72 insertions(+), 35 deletions(-) diff --git a/macx/overlay/avail.h b/macx/overlay/avail.h index 1f2444ae4..6406f0db1 100644 --- a/macx/overlay/avail.h +++ b/macx/overlay/avail.h @@ -13,6 +13,7 @@ AVAIL(glPushClientAttrib) && \ AVAIL(glAttachShader) && \ AVAIL(glEnd) && \ + AVAIL(glGetBooleanv) && \ AVAIL(glDisableClientState) && \ AVAIL(glUniform1i) && \ AVAIL(glRenderMode) && \ diff --git a/macx/overlay/overlay.m b/macx/overlay/overlay.m index 99eca02c7..d3ebb25b2 100644 --- a/macx/overlay/overlay.m +++ b/macx/overlay/overlay.m @@ -245,7 +245,7 @@ static void drawOverlay(Context *ctx, unsigned int width, unsigned int height) { } if ((ctx->uiWidth != width) || (ctx->uiHeight != height)) { - ods("Sent init"); + ods("Sent init %i %i", width, height); releaseMem(ctx); ctx->uiWidth = width; @@ -460,7 +460,6 @@ static void drawContext(Context * ctx, int width, int height) { glPushMatrix(); glLoadIdentity(); - glDisable(GL_ALPHA_TEST); glDisable(GL_AUTO_NORMAL); // Skip clip planes, there are thousands of them. @@ -483,10 +482,20 @@ static void drawContext(Context * ctx, int width, int height) { glDisable(GL_SEPARABLE_2D); glDisable(GL_SCISSOR_TEST); glDisable(GL_STENCIL_TEST); - glDisable(GL_TEXTURE_GEN_Q); - glDisable(GL_TEXTURE_GEN_R); - glDisable(GL_TEXTURE_GEN_S); - glDisable(GL_TEXTURE_GEN_T); + + GLboolean b = 0; + glGetBooleanv(GL_TEXTURE_GEN_Q, &b); + if (b) + glDisable(GL_TEXTURE_GEN_Q); + glGetBooleanv(GL_TEXTURE_GEN_R, &b); + if (b) + glDisable(GL_TEXTURE_GEN_R); + glGetBooleanv(GL_TEXTURE_GEN_S, &b); + if (b) + glDisable(GL_TEXTURE_GEN_S); + glGetBooleanv(GL_TEXTURE_GEN_T, &b); + if (b) + glDisable(GL_TEXTURE_GEN_T); glRenderMode(GL_RENDER); @@ -566,7 +575,7 @@ static void drawContext(Context * ctx, int width, int height) { @implementation NSOpenGLContext (MumbleOverlay) - (void) overlayFlushBuffer { - ods("[NSOpenGLContext flushBuffer] %p", self); + ods("[NSOpenGLContext flushBuffer] %p %p", self, [self CGLContextObj]); Context *c = contexts; while (c) { @@ -590,14 +599,25 @@ static void drawContext(Context * ctx, int width, int height) { } NSView *v = [c->nsctx view]; - NSRect r = [v bounds]; - int width = (int)r.size.width; - int height = (int)r.size.height; - if (!(width > 0 && height > 0)) { - GLint viewport[4]; - glGetIntegerv(GL_VIEWPORT, viewport); - width = viewport[2]; - height = viewport[3]; + int width = 0, height = 0; + if (v) { + NSRect r = [v bounds]; + width = (int)r.size.width; + height = (int)r.size.height; + } else { + if (AVAIL(CGMainDisplayID)) { + CGDirectDisplayID md = CGMainDisplayID(); + if (CGDisplayIsCaptured(md)) { + width = CGDisplayPixelsWide(md); + height = CGDisplayPixelsHigh(md); + } + } + if (!width && !height) { + GLint viewport[4]; + glGetIntegerv(GL_VIEWPORT, viewport); + width = viewport[2]; + height = viewport[3]; + } } drawContext(c, width, height); @@ -606,8 +626,7 @@ static void drawContext(Context * ctx, int width, int height) { @end void CGLFlushDrawableOverride(CGLContextObj ctx) { - ods("CGLFlushDrawable() %p", ctx); - + ods("CGLFlushDrawableOverride %p", ctx); Context *c = contexts; /* Sometimes, we can get a FlushDrawable where the current context is NULL. @@ -621,16 +640,6 @@ void CGLFlushDrawableOverride(CGLContextObj ctx) { if (current == NULL || ctx != current) goto skip; - GLint viewport[4]; - glGetIntegerv(GL_VIEWPORT, viewport); - - int width = viewport[2]; - int height = viewport[3]; - - /* Are the viewport values crazy? Skip them in that case. */ - if (height < 0 || width < 0 || height > 5000 || width > 5000) - goto skip; - while (c) { if (c->cglctx == ctx) { /* There is no NSOpenGLContext for this CGLContext, so we should draw. */ @@ -659,6 +668,24 @@ void CGLFlushDrawableOverride(CGLContextObj ctx) { newContext(c); } + int width = 0, height = 0; + if (AVAIL(CGMainDisplayID)) { + CGDirectDisplayID md = CGMainDisplayID(); + if (CGDisplayIsCaptured(md)) { + width = CGDisplayPixelsWide(md); + height = CGDisplayPixelsHigh(md); + } + } + if (!width && !height) { + GLint viewport[4]; + glGetIntegerv(GL_VIEWPORT, viewport); + width = viewport[2]; + height = viewport[3]; + /* Are the viewport values crazy? Skip them in that case. */ + if (height < 0 || width < 0 || height > 5000 || width > 5000) + goto skip; + } + drawContext(c, width, height); skip: diff --git a/overlay_gl/overlay.c b/overlay_gl/overlay.c index e522c3e34..dba340d3c 100644 --- a/overlay_gl/overlay.c +++ b/overlay_gl/overlay.c @@ -262,7 +262,7 @@ static void drawOverlay(Context *ctx, unsigned int width, unsigned int height) { } if ((ctx->uiWidth != width) || (ctx->uiHeight != height)) { - ods("Sent init"); + ods("Sent init %i %i", width, height); releaseMem(ctx); ctx->uiWidth = width; @@ -470,7 +470,6 @@ static void drawContext(Context * ctx, int width, int height) { glPushMatrix(); glLoadIdentity(); - glDisable(GL_ALPHA_TEST); glDisable(GL_AUTO_NORMAL); // Skip clip planes, there are thousands of them. @@ -493,10 +492,20 @@ static void drawContext(Context * ctx, int width, int height) { glDisable(GL_SEPARABLE_2D); glDisable(GL_SCISSOR_TEST); glDisable(GL_STENCIL_TEST); - glDisable(GL_TEXTURE_GEN_Q); - glDisable(GL_TEXTURE_GEN_R); - glDisable(GL_TEXTURE_GEN_S); - glDisable(GL_TEXTURE_GEN_T); + + GLboolean b = 0; + glGetBooleanv(GL_TEXTURE_GEN_Q, &b); + if (b) + glDisable(GL_TEXTURE_GEN_Q); + glGetBooleanv(GL_TEXTURE_GEN_R, &b); + if (b) + glDisable(GL_TEXTURE_GEN_R); + glGetBooleanv(GL_TEXTURE_GEN_S, &b); + if (b) + glDisable(GL_TEXTURE_GEN_S); + glGetBooleanv(GL_TEXTURE_GEN_T, &b); + if (b) + glDisable(GL_TEXTURE_GEN_T); glRenderMode(GL_RENDER); diff --git a/src/mumble/Overlay_macx.mm b/src/mumble/Overlay_macx.mm index 8ec0dacbc..6e9037eae 100644 --- a/src/mumble/Overlay_macx.mm +++ b/src/mumble/Overlay_macx.mm @@ -553,8 +553,8 @@ bool validateInstaller(const char *path) { goto err; } - // Good documentation on the values of SecTrustResultType: - // http://lists.apple.com/archives/apple-cdsa/2006/Apr/msg00013.html + // Good documentation on the values of SecTrustResultType: + // http://lists.apple.com/archives/apple-cdsa/2006/Apr/msg00013.html switch (result) { case kSecTrustResultProceed: // User trusts this certificate (as well as the system) case kSecTrustResultConfirm: // Check with the user before proceeding (which we're already doing by giving them a choice).