我需要在python Pyglet中制作多维数据集的多维数据集视口,但我总是只有一个。
查看def on_resize():
WINDOW = 1000
INCREMENT = 5
transparant = False
class Window(pyglet.window.Window):
xRotation = yRotation = zRotation = 30
zoom = 1
far = 100
dist = 35
x = y = z = 0
def __init__(self, width, height, title = '') :
super(Window, self).__init__( 1300,1000, title)
pgl.glClearColor(0, 0, 0, 1)
pgl.glEnable(pgl.GL_DEPTH_TEST)
def on_draw(self) :
self.clear()
立方体图
pgl.glPopMatrix()
def on_resize(self, width, height) :
pgl.glClear(pgl.GL_COLOR_BUFFER_BIT | pgl.GL_DEPTH_BUFFER_BIT)
pgl.glViewport(0, 0, 650, 500)
pgl.glLoadIdentity()
pgl.glMatrixMode(ogl.GL_PROJECTION)
pgl.glOrtho(-width / 8, width / 8, -height / 8, height / 8, 0, 500)
pgl.glFlush()
pgl.glViewport(500, 0, 650, 500)
pgl.glLoadIdentity()
pgl.glMatrixMode(ogl.GL_PROJECTION)
Ratio = width/height
# pgl.gluPerspective(self.dist, Ratio, 1, 1000)
pgl.glOrtho(-width/8, width/8, -height/8, height/8, 0, 500)
pgl.glFlush()
pgl.glMatrixMode(ogl.GL_MODELVIEW)
pgl.glTranslatef(0, 0, -100)
Window(WINDOW, WINDOW, 'Cube')
pyglet.app.run()
您能帮助解决这个问题吗?
答案 0 :(得分:1)
设置视口和矩阵将修改OpenGL状态。之后,您必须立即画些东西。设置新的视口将覆盖先前的设置。像这样:
pgl.glClear(pgl.GL_COLOR_BUFFER_BIT | pgl.GL_DEPTH_BUFFER_BIT)
pgl.glViewport(0, 0, 650, 500)
pgl.glMatrixMode(ogl.GL_PROJECTION)
pgl.glLoadIdentity()
pgl.glOrtho(-width / 8, width / 8, -height / 8, height / 8, 0, 500)
pgl.glMatrixMode(ogl.GL_MODELVIEW)
# set modelview matrix
# draw cube
pgl.glViewport(500, 0, 650, 500)
pgl.glMatrixMode(ogl.GL_PROJECTION)
pgl.glLoadIdentity()
# this is actually the same as before, so you can just leave it
pgl.glOrtho(-width/8, width/8, -height/8, height/8, 0, 500)
pgl.glMatrixMode(ogl.GL_MODELVIEW)
pgl.glTranslatef(0, 0, -100)
# set modelview matrix
# draw cube
答案 1 :(得分:0)
这是针对OpenGL初学者的一般提示/提示/规则,它们会遇到以下问题:
在学习的过程中,在绘图功能之外不进行OpenGL调用!!设置矩阵,视口等总是 进入绘图功能。