首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >具有Cocoa的OpenGL :在尝试调用CGLLockContext([[self openGLContext] CGLContextObj]时没有匹配函数调用);

具有Cocoa的OpenGL :在尝试调用CGLLockContext([[self openGLContext] CGLContextObj]时没有匹配函数调用);
EN

Stack Overflow用户
提问于 2014-01-12 09:48:55
回答 1查看 826关注 0票数 1

我正在学习OpenGL。为了获得OpenGL上下文设置,我遵循了苹果的GlEssentials示例。GlContext被锁定在绘图方法中,如下所示:

代码语言:javascript
复制
- (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时,我会犯以下错误:

代码语言:javascript
复制
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 *')

快速插入打字机解决了问题:

代码语言:javascript
复制
CGLLockContext((CGLContextObj)[[self openGLContext] CGLContextObj]);

问题是为什么?在Apples示例中,如果没有这个类型,它就可以正常工作。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-01-12 11:37:35

有两个想法:

1)您是在C++或ObjC++文件中这样做吗?在我看来,整个“候选函数”听起来像C++,但我并不真正了解C++。

2)您的编译器标志(特别是警告和错误)在您的项目文件中是否与在Apple的示例项目中相同。(我快速地查看了Xcode 5的编译器设置,没有任何东西跳出我的视线。)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21073276

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档