简体   繁体   English

glGenLists(1)使用wxThread在OnPaint()外面返回0

[英]glGenLists(1) return 0 outside OnPaint() with wxThread

Currently, I am trying to separate the display list from the OnPaint() , but glGenLists(1) return 0. 目前,我正在尝试将显示列表与OnPaint()分开,但glGenLists(1)返回0。

Is there any prerequisite on using display list? 使用显示列表有什么先决条件吗?
Is function glGenLists(1) only survive inside OnXxx() event thread? 函数glGenLists(1)只能在OnXxx()事件线程中存活吗?

Thank you! 谢谢!

The only requirement is having a valid OpenGL context made current. 唯一的要求是使有效的OpenGL上下文成为当前的。 You probably don't have one. 你可能没有。 If you use multiple threads, you need to use multiple GL contexts which share objects. 如果使用多个线程,则需要使用共享对象的多个GL上下文。

From what I understand, OpenGL can be used across multiple threads (with some caveats), but you should avoid doing so when possible. 根据我的理解,OpenGL可以在多个线程中使用(有一些警告),但是你应该尽可能避免这样做。 glGenLists is probably failing because, as mentioned, you are calling it in a different thread than the one you used to create your OpenGL context. glGenLists可能失败了,因为正如所提到的,你在与用于创建OpenGL上下文的线程不同的线程中调用它。 If you can, I would suggest moving something other than OpenGL calls to the second thread. 如果可以的话,我建议将除OpenGL调用之外的东西移到第二个线程。

OpenGL and threads do not mix. OpenGL和线程不混合。 If you really needs threads, call OpenGL functions only in one threads. 如果你真的需要线程,只能在一个线程中调用OpenGL函数。

As already said, the glGenLists returns 0 on errors. 如前所述,glGenLists在出错时返回0。 Check the error with glGetError function. 使用glGetError函数检查错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM