使用OpenGL和Python3.4无法显示窗口

时间:2015-08-22 10:23:37

标签: python opengl

我试图用练习写Snake Game: http://noobtuts.com/python/snake-game

必需:

Python - check
Python OpenGL - check

我使用了一些现成的代码,显示一个窗口,游戏将在哪里。

示例:

from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *

window = 0                                             # glut window number
width, height = 500, 400                               # window size

def draw():                                            # ondraw is called all the time
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) # clear the screen
    glLoadIdentity()                                   # reset position

    # TODO draw rectangle

    glutSwapBuffers()                                  # important for double buffering


# initialization
glutInit()                                             # initialize glut
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH)
glutInitWindowSize(width, height)                      # set window size
glutInitWindowPosition(0, 0)                           # set window position
window = glutCreateWindow(b"noobtuts.com")              # create window with title
glutDisplayFunc(draw)                                  # set draw function callback
glutIdleFunc(draw)                                     # draw all the time
glutMainLoop()                                         # start everything

我得到的结果是:

Process started >>>

不显示任何窗口。

我尝试更新我的图形驱动程序,但这不起作用。

要检查是否显示了我使用的窗口:

print(window != 0)

返回True。

0 个答案:

没有答案