pyglet 仅在使用附加绘图命令后显示形状
pyglet displays shapes only after using additional draw command
Pyglet,windows10。
当启用 sample_buffers
以获得更好看的图纸时,我遇到了以下问题。
仅当存在如下所示的附加线时,我才会看到我绘制的任何形状 batch
(在本例中为一条线)。当它存在时 batch
内容被绘制。如果不存在,则不显示任何内容。
不使用config
时,不需要这一行。
代码被剥离到最低限度,出现这种行为的地方。
我怀疑我的配置缺少某些东西。
我已经尝试通过 screen.get_best_config
获取初始配置。没有变化。
import pyglet
from pyglet import shapes
config = pyglet.gl.Config(sample_buffers=1, samples=8, double_buffer=False)
window = pyglet.window.Window(960, 540,config=config, resizable=True)
batch = pyglet.graphics.Batch()
line = shapes.Line(100, 100, 50, 200, width=19, batch=batch)
@window.event
def on_draw():
window.clear()
batch.draw()
pyglet.graphics.draw(2, pyglet.gl.GL_LINES,('v2i', (10, 15, 300, 305))) #without this line nothing is displayed
pyglet.app.run()
如果您禁用双缓冲(double_buffer=False
- 请参阅 pyglet.gl
), you must manually force the execution of GL commands with glFlush
:
import pyglet
from pyglet import shapes
config = pyglet.gl.Config(sample_buffers=1, samples=8, double_buffer=False)
window = pyglet.window.Window(960, 540,config=config, resizable=True)
batch = pyglet.graphics.Batch()
line = shapes.Line(100, 100, 50, 200, width=19, batch=batch)
@window.event
def on_draw():
window.clear()
batch.draw()
pyglet.gl.glFlush()
pyglet.app.run()
Pyglet,windows10。
当启用 sample_buffers
以获得更好看的图纸时,我遇到了以下问题。
仅当存在如下所示的附加线时,我才会看到我绘制的任何形状 batch
(在本例中为一条线)。当它存在时 batch
内容被绘制。如果不存在,则不显示任何内容。
不使用config
时,不需要这一行。
代码被剥离到最低限度,出现这种行为的地方。
我怀疑我的配置缺少某些东西。
我已经尝试通过 screen.get_best_config
获取初始配置。没有变化。
import pyglet
from pyglet import shapes
config = pyglet.gl.Config(sample_buffers=1, samples=8, double_buffer=False)
window = pyglet.window.Window(960, 540,config=config, resizable=True)
batch = pyglet.graphics.Batch()
line = shapes.Line(100, 100, 50, 200, width=19, batch=batch)
@window.event
def on_draw():
window.clear()
batch.draw()
pyglet.graphics.draw(2, pyglet.gl.GL_LINES,('v2i', (10, 15, 300, 305))) #without this line nothing is displayed
pyglet.app.run()
如果您禁用双缓冲(double_buffer=False
- 请参阅 pyglet.gl
), you must manually force the execution of GL commands with glFlush
:
import pyglet
from pyglet import shapes
config = pyglet.gl.Config(sample_buffers=1, samples=8, double_buffer=False)
window = pyglet.window.Window(960, 540,config=config, resizable=True)
batch = pyglet.graphics.Batch()
line = shapes.Line(100, 100, 50, 200, width=19, batch=batch)
@window.event
def on_draw():
window.clear()
batch.draw()
pyglet.gl.glFlush()
pyglet.app.run()