函数CGLGetCurrentContext什么时候应该返回NULL,什么时候不应该返回NULL? [英] When should the function CGLGetCurrentContext return NULL and when it shouldn't?

查看:177
本文介绍了函数CGLGetCurrentContext什么时候应该返回NULL,什么时候不应该返回NULL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用需要获取OpenGL低级上下文的API编写程序,但是我无法理解函数CGLGetCurrentContext何时应返回值(代表上下文的整数),以及何时返回不应该.

I am writing a program using an API that needs to get an OpenGL low-level context, but I am unable to understand when does the function CGLGetCurrentContext should return a value (an integer representing the context), and when it shouldn't.

现在,函数CGLGetCurrentContext()返回NULL,这破坏了我的程序.我该如何解决?

Right now, the function CGLGetCurrentContext() is returning NULL, and this is breaking my program. How can I fix this?

此功能的目的是什么? OpenGL上下文如何建模?

What is the purpose of this function? How are OpenGL contexts modeled?

推荐答案

OpenGL具有绑定到工作线程的活动渲染上下文的概念.这样您就可以认为CGLGetCurrentContext()返回了一些线程局部变量.如果满足以下条件,则预计会返回一些值:

OpenGL has a conception of an active rendering context bound to the working thread. So that you may consider CGLGetCurrentContext() as returning some thread-local variable. It is expected to return some value if:

  • 某些代码创建了OpenGL上下文.
  • 某些代码在当前工作线程中激活了OpenGL上下文.
  • 您在同一工作线程中调用CGLGetCurrentContext(),并且之前的代码没有将其停用.
  • Some code created an OpenGL context.
  • Some code activated OpenGL context within current working thread.
  • You call CGLGetCurrentContext() within the same working thread, and the code before didn't deactivated it.

由于您尚未指定代码的详细信息,因此我可能认为OpenGL是由非您编写的代码管理的,这使得很难说明为什么CGLGetCurrentContext()可能为NULL.

As you have not specified details of your code, I may consider that OpenGL is managed by code not written by you, which makes it difficult to suggest why CGLGetCurrentContext() might be NULL.

我只能说我的macOS应用程序使用CGLGetCurrentContext()并且可以按预期工作.

I may only say that my macOS application uses CGLGetCurrentContext() and it works as expected.

这篇关于函数CGLGetCurrentContext什么时候应该返回NULL,什么时候不应该返回NULL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆