我使用Pyopengl和Pyglet進行簡單的應用。我正在使用Vsync以120 Hz交換緩衝區。這是問題。當我運行諸如Outlook,Chrome,NotePad ++等許多應用程序時,Dora在背景上的巨大冒險,Fps足夠穩定在120Hz。但是,當我關閉所有這些應用程序時,fps從114Hz變爲125Hz!?!?Pyglet:使用Vsync時不穩定的幀數...並沒有其他軟件
我認爲關閉應用程序實際上會改善fps,但是沒有。我的應用程序不同步。我也認爲由Pyglet給出的FPS將堅持119 & 121.
任何人都可以幫我弄清楚嗎?我沒有看到一些明顯的東西嗎?
下面是一些代碼
def on_draw(dt):
cnt
ScreenSwap
left = True
right = False
Rval = 0.0/255.0
Gval = 153.0/255.0
Bval = 0.0/255.0
ShapePosition(speed = 0.25)
glClear(GL_COLOR_BUFFER_BIT) # Clear the color buffer
glLoadIdentity() # Reset model-view matrix
DrawChecker(Nbr = 16, Dark = 25.0/255, Light = 75.0/255)
if ScreenSwap == 1:
DrawQuestionMark(Rval, Gval, Bval, left)
# Blue Line
BlueLine(left)
# Line to see if we are dropping frame
DropFrameTest(left)
ScreenSwap = 0
else:
DrawQuestionMark(Rval, Gval, Bval, right)
# Blue Line
BlueLine(right)
# Line to see if we are dropping frame
DropFrameTest(right)
ScreenSwap = 1
fps = pyglet.clock.get_fps()
fd.write(str(fps) + "\n") # debug
多:
display = pyglet.window.get_platform().get_default_display()
screens = display.get_screens()
# Direct OpenGL commands to this window.
config = Config(double_buffer = True)
window = pyglet.window.Window(config = config, screen=screens[1], vsync=True)
# Set full screen in separate function to avoid flicker a the start
window.set_fullscreen(True)
pyglet.clock.ClockDisplay()
#pyglet.clock.set_fps_limit(120)
fps = pyglet.clock.get_fps()
dt = pyglet.clock.tick()
pyglet.clock.schedule_interval(on_draw, 0.001)
pyglet.app.run()
fd.close()