aboutsummaryrefslogtreecommitdiffstats
path: root/emulator/opengl/host/libs
diff options
context:
space:
mode:
Diffstat (limited to 'emulator/opengl/host/libs')
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp10
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/MacNative.h1
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/MacNative.m28
3 files changed, 38 insertions, 1 deletions
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp b/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp
index 31527af..eeaa25c 100644
--- a/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp
+++ b/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp
@@ -68,7 +68,15 @@ static EglConfig* pixelFormatToConfig(int index,int renderableType,EGLNativePixe
getPixelFormatAttrib(*frmt,MAC_SAMPLES_PER_PIXEL,&samples);
getPixelFormatAttrib(*frmt,MAC_COLOR_SIZE,&colorSize);
- getPixelFormatAttrib(*frmt,MAC_ALPHA_SIZE,&alpha);
+ /* All configs can end up having an alpha channel even if none was requested.
+ * The default config chooser in GLSurfaceView will therefore not find any
+ * matching config. Thus, make sure alpha is zero (or at least signalled as
+ * zero to the calling EGL layer) for the configs where it was intended to
+ * be zero. */
+ if (getPixelFormatDefinitionAlpha(index) == 0)
+ alpha = 0;
+ else
+ getPixelFormatAttrib(*frmt,MAC_ALPHA_SIZE,&alpha);
getPixelFormatAttrib(*frmt,MAC_DEPTH_SIZE,&depth);
getPixelFormatAttrib(*frmt,MAC_STENCIL_SIZE,&stencil);
diff --git a/emulator/opengl/host/libs/Translator/EGL/MacNative.h b/emulator/opengl/host/libs/Translator/EGL/MacNative.h
index 82ab667..c8a1df2 100644
--- a/emulator/opengl/host/libs/Translator/EGL/MacNative.h
+++ b/emulator/opengl/host/libs/Translator/EGL/MacNative.h
@@ -33,6 +33,7 @@ extern "C"{
int getNumPixelFormats();
void* getPixelFormat(int i);
+int getPixelFormatDefinitionAlpha(int i);
void getPixelFormatAttrib(void* pixelFormat,int attrib,int* val);
void* nsCreateContext(void* format,void* share);
void nsWindowMakeCurrent(void* context,void* nativeWin);
diff --git a/emulator/opengl/host/libs/Translator/EGL/MacNative.m b/emulator/opengl/host/libs/Translator/EGL/MacNative.m
index 6828655..a2cea93 100644
--- a/emulator/opengl/host/libs/Translator/EGL/MacNative.m
+++ b/emulator/opengl/host/libs/Translator/EGL/MacNative.m
@@ -75,6 +75,34 @@ void* getPixelFormat(int i){
return [[NSOpenGLPixelFormat alloc] initWithAttributes:attrib_lists[i]];
}
+int getPixelFormatDefinitionAlpha(int i) {
+ int size;
+ NSOpenGLPixelFormatAttribute** attrib_lists = getPixelFormatsAttributes(&size);
+ NSOpenGLPixelFormatAttribute* attribs = attrib_lists[i];
+ while (*attribs) {
+ switch (*attribs) {
+ // These are the ones that take a value, according to the current
+ // NSOpenGLPixelFormat docs
+ case NSOpenGLPFAAuxBuffers:
+ case NSOpenGLPFAColorSize:
+ case NSOpenGLPFADepthSize:
+ case NSOpenGLPFAStencilSize:
+ case NSOpenGLPFAAccumSize:
+ case NSOpenGLPFARendererID:
+ case NSOpenGLPFAScreenMask:
+ attribs += 2;
+ break;
+ case NSOpenGLPFAAlphaSize:
+ return attribs[1];
+ break;
+ // All other attributes are boolean attributes that don't take a value
+ default:
+ attribs++;
+ }
+ }
+ return 0;
+}
+
void getPixelFormatAttrib(void* pixelFormat,int attrib,int* val){
NSOpenGLPixelFormat *frmt = (NSOpenGLPixelFormat *)pixelFormat;
[frmt getValues:val forAttribute:attrib forVirtualScreen:0];