def main(): ### Initialize fw.init() ### Monitor Info # print_all_monitors() ### Rift monitor = get_rift() curmode = monitor.video_mode curmode.refresh_rate # should be 74 # Check for Monitor - really should check for Rift attach/detach... # this doesn't work like I think it should fw.Monitor.set_callback(on_monitor) win = CbWindow(curmode.width, curmode.height, 'pyglfw', monitor) win.make_current() while not win.should_close: # blue! blue = (0.0, 0.0, 1.0, 0.0) glClearColor(*blue) glClear(GL_COLOR_BUFFER_BIT) win.swap_buffers() fw.poll_events() if win.keys.escape: win.should_close = True fw.terminate()
def main(): ### Initialize fw.init() ### Rift monitor = get_rift() win = CbWindow(640, 480, 'pyglfw') win.make_current() # XWindows... d = Display() root = d.screen().root pixmap = root.create_pixmap(256, 256, 8) # glXCreateWindow(d, cfg, pixmap, 0) while not win.should_close: render() win.swap_buffers() fw.poll_events() if win.keys.escape: win.should_close = True fw.terminate()
def main(): # Initialize the library if not glfw.init(): return # Create a windowed mode window and its OpenGL context window = glfw.window.Window(640, 480, "Hello World", None, None) if not window: glfw.terminate() return renderer = RiftGLRendererCompatibility() # Paint a triangle in the center of the screen renderer.append(TriangleDrawerCompatibility()) # Make the window's context current window.make_current() # Initialize Oculus Rift renderer.init_gl() renderer.rift.recenter_pose() # Loop until the user closes the window while not window.should_close: # Render here, e.g. using pyOpenGL renderer.display_rift_gl() # Swap front and back buffers window.swap_buffers() # Poll for and process events glfw.poll_events() glfw.terminate()
def main(): fw.init() fw.Monitor.set_callback(on_monitor) win = CbWindow(800, 600, "callback window") win.make_current() while not win.should_close: win.swap_buffers() fw.poll_events() if win.keys.escape: win.should_close = True fw.terminate()
def __init__(self, width, height, title='eezl'): print("creating eezl") self._width = width self._height = height self._title = title self._clear_color = [0.0, 0.0, 0.0, 1.0] self._stainq = queue.Queue(1) # queue to signal for redraw # init glfw if not glfw.init(): raise Exception("couldnt init glfw!") # create window self._win = glfw.Window(width, height, title) if not self._win: glfw.terminate() raise Exception("couldnt create glfw window!") self._win.make_current() self._win.swap_interval(1) # 0 -> go fast / 1 -> pause first self._nvg = nvg.Context() # setup gl context gl.glEnable(gl.GL_POINT_SPRITE) gl.glEnable(gl.GL_VERTEX_PROGRAM_POINT_SIZE) # overwrite pointsize gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) gl.glEnable(gl.GL_BLEND) gl.glClearColor(*self._clear_color) # register glfw.window callbacks self._win.set_window_size_callback(self._on_resize) self._win.set_window_close_callback(self._on_close) self._win.set_key_callback(self._on_key) self._win.set_mouse_button_callback(self._on_button) self._win.set_cursor_pos_callback(self._on_pos) # init window size self._on_resize(self._win, self._width, self._height)
def __init__( self, width, height, title='eezl' ): print( "creating eezl" ) self._width = width self._height = height self._title = title self._clear_color = [0.0, 0.0, 0.0, 1.0] self._stainq = queue.Queue( 1 ) # queue to signal for redraw # init glfw if not glfw.init(): raise Exception("couldnt init glfw!") # create window self._win = glfw.Window(width, height, title) if not self._win: glfw.terminate() raise Exception("couldnt create glfw window!") self._win.make_current() self._win.swap_interval( 1 ) # 0 -> go fast / 1 -> pause first self._nvg = nvg.Context() # setup gl context gl.glEnable( gl.GL_POINT_SPRITE ) gl.glEnable( gl.GL_VERTEX_PROGRAM_POINT_SIZE ) # overwrite pointsize gl.glBlendFunc( gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA ) gl.glEnable( gl.GL_BLEND ) gl.glClearColor( *self._clear_color ) # register glfw.window callbacks self._win.set_window_size_callback( self._on_resize ) self._win.set_window_close_callback( self._on_close ) self._win.set_key_callback( self._on_key ) self._win.set_mouse_button_callback( self._on_button ) self._win.set_cursor_pos_callback( self._on_pos ) # init window size self._on_resize( self._win, self._width, self._height )
def main(): # Initialize the library if not glfw.init(): return # Set some window hints glfw.Window.hint(floating=glfw.Window.floating) # Create a windowed mode window and its OpenGL context window = glfw.Window(300, 300, "Hello World", None, None) if not window: glfw.terminate() return # Move Window window.pos = (1600, 50) # Make the window's context current window.make_current() # vsync window.swap_interval(1) # Setup GL shaders, data, etc. initialize() # Loop until the user closes the window while not window.should_close: # Render here, e.g. using pyOpenGL render() # Swap front and back buffers window.swap_buffers() # Poll for and process events glfw.poll_events() glfw.terminate()
def main(): fw.init() monitor = get_dk2() if not monitor: sys.exit('Could not find DK2') curmode = monitor.video_mode print(curmode.refresh_rate) # should be 74 win = CbWindow(960, 540, 'pyglfw') win.make_current() dk2 = DK2(win) while not win.should_close: dk2.render() fw.poll_events() if win.keys.escape: win.should_close = True fw.terminate()
def main(): ### Initialize fw.init() ### Hints # ok, that doesn't work... can't get context for that # fw.Window.hint(stereo=True) ### Monitor Info # print_all_monitors() ### Rift monitor = get_rift() curmode = monitor.video_mode curmode.refresh_rate # should be 74 # Check for Monitor - really should check for Rift attach/detach... # this doesn't work like I think it should fw.Monitor.set_callback(on_monitor) win = CbWindow(640, 480, 'pyglfw') win.make_current() while not win.should_close: render() win.swap_buffers() fw.poll_events() if win.keys.escape: win.should_close = True fw.terminate()
def main(): # Initialize the library if not glfw.init(): return # Create a windowed mode window and its OpenGL context window = glfw.window.Window(640, 480, "Hello World", None, None) if not window: glfw.terminate() return # Make the window's context current window.make_current() # Loop until the user closes the window while not window.should_close: # Render here, e.g. using pyOpenGL # Swap front and back buffers window.swap_buffers() # Poll for and process events glfw.poll_events() glfw.terminate()
# coding=utf-8 import pyglfw.pyglfw as glfw import common2d if __name__ == '__main__': glfw.init() w = glfw.Window(640, 480, "Hello world!") w.make_current() program = common2d.init_shader_program() while not w.should_close: # Render here common2d.display(program) w.swap_buffers() glfw.poll_events() if w.keys.escape: w.should_close = True glfw.terminate()
def quit(self): """cleanup eezl window when finished """ self._win.close() glfw.terminate()
windows = [None, None] windows[0] = open_window('First', None, OFFSET, OFFSET) texture = create_texture() x, y = windows[0].pos width, height = windows[0].size windows[1] = open_window('Second', windows[0], x + width + OFFSET, y) with windows[0]: glColor3f(0.6, 0.0, 0.6) with windows[1]: glColor3f(0.6, 0.6, 0.0) while not windows[0].should_close and not windows[1].should_close: with windows[0]: draw_quad(texture) with windows[1]: draw_quad(texture) windows[0].swap_buffers() windows[1].swap_buffers() fw.wait_events() fw.terminate() sys.exit(0)
def __del__(self): glfw.terminate()
windows = [None, None] windows[0] = open_window("First", None, OFFSET, OFFSET) texture = create_texture() x, y = windows[0].pos width, height = windows[0].size windows[1] = open_window("Second", windows[0], x + width + OFFSET, y) with windows[0]: glColor3f(0.6, 0.0, 0.6) with windows[1]: glColor3f(0.6, 0.6, 0.0) while not windows[0].should_close and not windows[1].should_close: with windows[0]: draw_quad(texture) with windows[1]: draw_quad(texture) windows[0].swap_buffers() windows[1].swap_buffers() fw.wait_events() fw.terminate() sys.exit(0)
def quit( self ): """cleanup eezl window when finished """ self._win.close() glfw.terminate()