带有glut的线程:glutPostRedisplay被忽略 [英] Threading with glut: glutPostRedisplay being ignored

查看:248
本文介绍了带有glut的线程:glutPostRedisplay被忽略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序可以对其进行更新,然后程序的状态会发生变化.当发生时间滴答声(不是openGL计时器,而是在线程中实现)时,以及从glut注册键盘输入(使用glutKeyboardFunc回调)时,会发生这种情况.

I have a program which updates it the program output then the state of the program changes. This happens when a ticker of the time (not an openGL timer, one implemented in threads) happens, and when keyboard input is registered from glut (using glutKeyboardFunc callback).

这两个事件均会更新程序状态并调用glutPostRedisplay;.问题仅在于当按下键盘时它实际上会执行任何操作.当计时器打勾时,显示功能将被忽略,但是当按下键盘时,将调用显示功能.

Both of these events update the programs state and call glutPostRedisplay; the problem is only the when the keyboard is pressed does it actually do anything. When the timer ticks the display function is ignored, but when the keyboard is pressed the display function is called.

glut是否忽略其他线程?如果可以的话,有一种方法可以注册它们.

Does glut ignore other threads? And if so is there a way to get it to register them.

推荐答案

您不能从未初始化一个GLUT的线程中调用glutPostRedisplay或大多数其他GLUT函数.GLUT是 not 线程安全的.

You cannot call glutPostRedisplay or most other GLUT functions from a thread other than the one GLUT was initialized in. GLUT is not thread-safe.

这篇关于带有glut的线程:glutPostRedisplay被忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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