GLUT Warning and GLUT Fatal Error in a Python code that runs in another machine

雨燕双飞 提交于 2019-12-25 10:03:06

问题


I have to make some modifications in the following code as homework, however the professor shown the code running in class, but even after installing the packages it didn't run on my Mac machine, the error says to update my code, however it's supposed to run on his Windows machine also, so the ideal would be to fix the error and not the code.

def main():

    glutInit(sys.argv)                        #initial the system
    glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB)

    glutInitWindowSize(int(window_width), int(window_hight))          #initial window size
    glutInitWindowPosition(100, 100)          #initial window position

    glutCreateWindow("ICSI 422 Demo")        #assign a title for the window


    initGL()
    # drawpoints()                           #call funtion drawpoints
    # drawlines()
    # drawSquares()

    glutMainLoop()

And when I try running the code, it outputs on my terminal:

Python[1547:103885] GLUT Warning: The following is a new check for GLUT 3.0; update your code.
Python[1547:103885] GLUT Fatal Error: redisplay needed for window 1, but no display callback.

As you can guess, I'm new to OpenGL and somehow new to Python, so what can I do?


回答1:


You need to call tell GLUT what function to call when it is time to draw by passing a function pointer to glutDisplayFunc() before you kick off the main loop with glutMainLoop(). See the documentation here:

https://www.opengl.org/documentation/specs/glut/spec3/node46.html

In C, that would look like this:

void myDisplayFunc() {
  // gfx fun
}

int main() {
   // boring init
   glutDisplayFunc(myDisplayFunc);
   glutMainLoop();
}

I don't know exactly how that works using the Python bindings, but that is what is causing your error. GLUT needs a function to call when it is time to draw to the screen and since you haven't given it one it just bails out and quits.

Note that other useful callbacks are defined the same way (see glutKeyboardFunc() and glutMouseFunc()).



来源:https://stackoverflow.com/questions/35302800/glut-warning-and-glut-fatal-error-in-a-python-code-that-runs-in-another-machine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!