2013-06-21 1 views
0

Pyopengl 대 Pyglet의 성능/기능을 평가해야합니다. 주요 관심사는 높은 FPS를 사용하는 동안 어떤 프레임도 드롭 할 수 없다는 것입니다. 그 중 하나를 배우기 전에 클라이언트가 필요로하는 것을 할 수 있는지 알아야합니다.Python : pyglet 대 프레임 드롭을위한 PyOpengl 성능 평가

빨강과 초록색 (전체 화면 모드)을 번갈아 사용하려고합니다 (vsync에서). 누구든지 나에게 훌륭한 튜토리얼 사이트를 제공하거나 예제를 통해 도움을 줄 수 있다면 매우 좋을 것입니다. FPS with Pyglet half of monitor refresh rate

가 수정을 만들었지 만, VSYNC 다른 하나에 하나 개의 색상으로 전환하는 방법을 볼 수 없습니다 :

이 게시물 (등) 살펴 보았다.

import pyglet 
from pyglet.gl import * 


fps = pyglet.clock.ClockDisplay() 

# The game window 
class Window(pyglet.window.Window): 
    def __init__(self): 
     super(Window, self).__init__(fullscreen=True, vsync = False) 
     self.flipScreen = 0 
     glClearColor(1.0, 1.0, 1.0, 1.0) 
     # Run "self.update" 128 frames a second and set FPS limit to 128. 
     pyglet.clock.schedule_interval(self.update, 1.0/128.0) 
     pyglet.clock.set_fps_limit(128) 


def update(self, dt): 
    self.flipScreen = not self.flipScreen 
    pass 

def on_draw(self): 
    pyglet.clock.tick() # Make sure you tick the clock! 
    if self.flipScreen == 0: 
     glClearColor(0, 1, 0, 1.0) 
    else: 
     glClearColor(1, 0, 0, 1.0) 
    self.clear() 
    fps.draw() 

# Create a window and run 
win = Window() 
pyglet.app.run() 

많은 자습서를 보았지만이 테스트를 실행하는 방법을 이해할 수 없었습니다.

도움 주셔서 감사합니다.

답변

0

여기에는 pyglet을 사용하는 코드가 있습니다. 60 Hz 및 120 Hz에서 3 개의 모니터로 테스트되었습니다. 전역 변수의 사용은 좋지 않습니다. 매우 깨끗한 것은 아니지만 vsync가 고려되었음을 분명히 보여줍니다. 이것은 vsync의 기능을 테스트하는 코드의 목적입니다.

import pyglet 
from pyglet.gl import * 
from OpenGL.GL import * 
from OpenGL.GLUT import * 
from OpenGL.GLU import * 

# Direct OpenGL commands to this window. 
config = Config(double_buffer = True) 
window = pyglet.window.Window(config = config) 
window.set_vsync(True) 
window.set_fullscreen(True) 

colorSwap = 0 
fullscreen = 1 

fps_display = pyglet.clock.ClockDisplay() 

def on_draw(dt): 
    global colorSwap 
    glClear(GL_COLOR_BUFFER_BIT) # Clear the color buffer 
    glLoadIdentity()    # Reset model-view matrix 

    glBegin(GL_QUADS) 
    if colorSwap == 1: 
     glColor3f(1.0, 0.0, 0.0) 
     colorSwap = 0 
    else: 
     glColor3f(0.0, 1.0, 0.0) 
     colorSwap = 1 

    glVertex2f(window.width, 0) 
    glVertex2f(window.width, window.height) 
    glVertex2f(0.0, window.height) 
    glVertex2f(0.0, 0.0) 
    glEnd() 
    fps_display.draw() 

@window.event 
def on_key_press(symbol, modifiers): 
    global fullscreen 
    if symbol == pyglet.window.key.F: 
     if fullscreen == 1: 
      window.set_fullscreen(False) 
      fullscreen = 0 
     else: 
      window.set_fullscreen(True) 
      fullscreen = 1 
    elif symbol == pyglet.window.key.ESCAPE: 
     print ''   


dt = pyglet.clock.tick() 
pyglet.clock.schedule_interval(on_draw, 0.0001) 
pyglet.app.run()