Tai OpenGL Framework SimpleOpenGLControl - 什么时候会重画,什么时候不会重画?
我将 C# 与 Visual Studio Express 2008 一起使用。
我还使用了 Tai Framework OpenGL dll。
当我需要 SimpleOpenGLControl 重绘时,实际上是什么导致它重绘?
当 SimpleOpenGLControl 驻留在活动窗体上时,为了重绘,我所需要做的就是调用 glFlush()
和 SimpleOpenGLControl.Invalidate()
。
但是,当控件不驻留在活动窗体上时,我根本无法重绘它。我找到了一种通过非正统手段使控件失效的方法,但这不会重绘控件的内容(3D渲染),它只是给我留下一个空白(黑色)控件。
无论哪种形式处于活动状态,我需要做什么才能让控件真正重绘?
I am using C# with Visual Studio Express 2008.
I am also using the Tao Framework OpenGL dlls.
What actually causes the SimpleOpenGLControl to redraw when I need it to redraw?
When the SimpleOpenGLControl resides on the active form, all I need to do in order to redraw is call glFlush()
and SimpleOpenGLControl.Invalidate()
.
However, when the control does not reside on the active form I can not get it to redraw, at all. I have found a way to get the control to invalidate through unorthodox means, but this does not redraw the contents of the control (the 3D rendering), it simply leaves me with a blank (black) control.
What do I need to do in order to get the control to actually redraw, regardless of which form is active?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然我的问题不在于 SimpleOpenGLControl 重绘,而在于调用函数的线程。
我的应用程序等待直到在一个线程中获取新数据,然后通过委托显示函数将数据传递回表单。
虽然没有出现错误或警告,但显然我的 OpenGL 渲染缓冲区没有被填充,因为填充它的函数是从独立线程调用的。
虽然我不完全理解线程安全函数委托,但我将程序推到了表单运行的线程下,我的 OpenGL 渲染缓冲区再次高兴起来。
所以,我的问题的答案是:
OpenGL 不会填充任何渲染缓冲区,除非它发生在初始化的同一线程上。
Apparently my problem was not in the SimpleOpenGLControl redrawing, but in the thread that the functions were being called from.
My application waits till it gets new data in one thread, then passes data back to the forms via a delegated display function.
Although no errors or warnings were raised, apparently my OpenGL rendering buffer was not getting filled because the functions that fill it were called from an independent thread.
Although I don't fully understand threadsafe function delegation, I pushed the procedures through under the thread the forms were running on, and my OpenGL rendering buffer is happy once again.
So, the answer to my question was:
OpenGL won't populate any rendering buffers unless it happens on the same thread it was initialized.