如何使用pyglet创建3D?

问题描述 投票:0回答:1

我试图在pyglet中创建一个多维数据集:

import pyglet
from pyglet.gl import *

window = pyglet.window.Window(400,400,"Paka Paka",True)
@window.event
def on_draw():
    window.clear()
    glBegin(GL_QUADS)
    glVertex3f(0,40,0)
    glColor3f(1,0,0)
    glVertex3f(100,40,0)
    glColor3f(0,1,0)
    glVertex3f(100,140,0)
    glColor3f(0,0,1)
    glVertex3f(100,40,100)
    glColor3f(1,1,0)
    glVertex3f(100,140,100)
    glColor3f(1,0,1)
    glVertex3f(0,140,100)
    glColor3f(0,1,1)
    glVertex3f(0,40,100)
    glColor3f(2,0,0)
    glVertex3f(0,140,0)
    glColor3f(0,0,2)
    glEnd()
pyglet.app.run()

and when I run the program, I saw a black screen.(向上除外)我是否需要更改顶点种类或其他内容?

python opengl python-3.7
1个回答
0
投票

几何图形的语义被(默认)orthographic projection的近远平面裁剪。

我建议通过glOrtho设置投影矩阵。例如:

glOrtho

分别

glOrtho(-200, 200, -200, 200, -200, 200) 

此外,建议通过glOrtho(0, 400, 400, 400, -200, 200) 刷新单个缓冲的窗口

glFlush()的开头设置投影,并在结尾处调用glFlush()

on_draw
© www.soinside.com 2019 - 2024. All rights reserved.