我正在学习OpenGL。为了获得OpenGL上下文设置,我遵循了苹果的GlEssentials示例。GlContext被锁定在绘图方法中,如下所示:
- (void) drawView
{
[[self openGLContext] makeCurrentContext];
// We draw on a secondary thread through the display link
// When resizing the view, -reshape is called automatically on the main
// thread. Add a mutex around to avoid the threads accessing the context
// simultaneously when resizing
CGLLockContext([[self openGLContext] CGLContextObj]);
[m_renderer render];
CGLFlushDrawable([[self openGLContext] CGLContextObj]);
CGLUnlockContext([[self openGLContext] CGLContextObj]);
}当我试图使用与我的视图类中的参数完全相同的参数调用CGLLockContext时,我会犯以下错误:
No matching function for call to 'CGLLockContext
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/OpenGL.framework/Headers/OpenGL.h:111:17: Candidate function not viable: cannot convert argument of incomplete type 'void *' to 'CGLContextObj' (aka '_CGLContextObject *')快速插入打字机解决了问题:
CGLLockContext((CGLContextObj)[[self openGLContext] CGLContextObj]);问题是为什么?在Apples示例中,如果没有这个类型,它就可以正常工作。
发布于 2014-01-12 11:37:35
有两个想法:
1)您是在C++或ObjC++文件中这样做吗?在我看来,整个“候选函数”听起来像C++,但我并不真正了解C++。
2)您的编译器标志(特别是警告和错误)在您的项目文件中是否与在Apple的示例项目中相同。(我快速地查看了Xcode 5的编译器设置,没有任何东西跳出我的视线。)
https://stackoverflow.com/questions/21073276
复制相似问题