私はOpenGLを学んでいます。OpenGL コンテキストのセットアップを取得するために、Apple のGlEssentialsの例に従っていました。GlContext は、次のように draw メソッドでロックされています。
- (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 の例では、このタイプキャストがなくても問題なく動作します。