Prevent OpenGL.framework from Loading in Cocoa App

笑着哭i 提交于 2020-01-02 19:46:32

问题


My application links against these Frameworks:

Cocoa.Framework
AppKit.Framework
CoreData.Framework
Foundation.Framework

Note that OpenGL.Framework is NOT linked. However, after setting DYLD_PRINT_LIBRARIES=1, I note that:

...

dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL

dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/...

dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/...

dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/...

dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/...

dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/...

...

This is a huge problem because, as noted on the [cocoa-dev list][1], the OpenGL framework causes the NVidia graphics card to power on for the newer MacBook Pros.

As expected, my application causes the NVidia card to power on. What's worse, is that the framework does not unload when the window is closed.

The only non-standard graphic elements I have are some custom NSBezierPath drawings and a shadow.

Essentially, when my app starts integrated graphics are used UNTIL the window is shown, and then discrete graphics are powered on and remain on regardless of the window state.


ANSWER

For an NSView with NSBezierPaths OR clear backgrounds, make sure to set: [myView setWantsLayer:NO]


回答1:


I'd say you user a feature that requires Cocoa to load OpenGL. Like CoreAnimation, or any fancy UI stuff. Are you showing videos in your app? Might be the reason.

Does the same thing happen on a brand-new example project that links to the same frameworks?




回答2:


Also - it seems that Apple has added support for allowing your app to try to run on the integrated graphics card.

NSSupportsAutomaticGraphicsSwitching to true will help for 2011 (and later?) macbooks.

http://developer.apple.com/library/mac/#qa/qa1734/_index.html%23//apple_ref/doc/uid/DTS40010791

You have to test your app with this setting.



来源:https://stackoverflow.com/questions/4054788/prevent-opengl-framework-from-loading-in-cocoa-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!