[英]Multiple viewports on one Pyglet window?
我需要在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()
您能幫助解決這個問題嗎?
設置視口和矩陣將修改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
這是針對此類問題的OpenGL初學者的一般提示/提示/規則:
在學習時,請不要在繪圖功能之外進行OpenGL調用 ! 設置矩陣,視口等總是進入繪圖功能。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.