diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp b/tools/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp index 8ff8faee2..492589d8a 100644 --- a/tools/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp +++ b/tools/emulator/opengl/host/libs/Translator/EGL/EglMacApi.cpp @@ -117,7 +117,7 @@ bool validNativePixmap(EGLNativeDisplayType dpy, EGLNativePixmapType pix) { bool checkWindowPixelFormatMatch(EGLNativeDisplayType dpy,EGLNativeWindowType win,EglConfig* cfg,unsigned int* width,unsigned int* height) { int r,g,b; bool ret = nsGetWinDims(win,width,height); - + cfg->getConfAttrib(EGL_RED_SIZE,&r); cfg->getConfAttrib(EGL_GREEN_SIZE,&g); cfg->getConfAttrib(EGL_BLUE_SIZE,&b); @@ -156,6 +156,17 @@ bool destroyContext(EGLNativeDisplayType dpy,EGLNativeContextType ctx) { } bool makeCurrent(EGLNativeDisplayType dpy,EglSurface* read,EglSurface* draw,EGLNativeContextType ctx){ + + // check for unbind + if (ctx == NULL && read == NULL && draw == NULL) { + nsWindowMakeCurrent(NULL, NULL); + return true; + } + else if (ctx == NULL || read == NULL || draw == NULL) { + // error ! + return false; + } + //dont supporting diffrent read & draw surfaces on Mac if(read->native() != draw->native()) return false; switch(draw->type()){ diff --git a/tools/emulator/opengl/host/libs/Translator/EGL/MacNative.m b/tools/emulator/opengl/host/libs/Translator/EGL/MacNative.m index e240bc12a..225a79fe7 100644 --- a/tools/emulator/opengl/host/libs/Translator/EGL/MacNative.m +++ b/tools/emulator/opengl/host/libs/Translator/EGL/MacNative.m @@ -33,7 +33,7 @@ void* getPixelFormat(int i){ void getPixelFormatAttrib(void* pixelFormat,int attrib,int* val){ NSOpenGLPixelFormat *frmt = (NSOpenGLPixelFormat *)pixelFormat; - [frmt getValues:val forAttribute:attrib forVirtualScreen:0]; + [frmt getValues:val forAttribute:attrib forVirtualScreen:0]; } void* nsCreateContext(void* format,void* share){ @@ -60,12 +60,9 @@ void nsWindowMakeCurrent(void* context,void* nativeWin){ NSView* win = (NSView *)nativeWin; if(ctx == nil){ [NSOpenGLContext clearCurrentContext]; - } else { - if(win != nil){ - [ctx clearDrawable]; - [ctx setView: win]; - [ctx makeCurrentContext]; - } + } else if (win != nil) { + [ctx setView: win]; + [ctx makeCurrentContext]; } } @@ -93,11 +90,11 @@ void nsDestroyContext(void* context){ void* nsCreatePBuffer(GLenum target,GLenum format,int maxMip,int width,int height){ - return [[NSOpenGLPixelBuffer alloc] initWithTextureTarget:target - textureInternalFormat:format - textureMaxMipMapLevel:maxMip + return [[NSOpenGLPixelBuffer alloc] initWithTextureTarget:target + textureInternalFormat:format + textureMaxMipMapLevel:maxMip pixelsWide:width pixelsHigh:height]; - + } void nsDestroyPBuffer(void* pbuffer){ @@ -129,7 +126,7 @@ bool nsCheckColor(void* win,int colorSize){ int depth = (limit != 0) ? NSBitsPerPixelFromDepth(limit): NSBitsPerPixelFromDepth(defaultLimit); return depth >= colorSize; - + } } return false;