Python glfw.poll_events() Examples
The following are 10
code examples of glfw.poll_events().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
glfw
, or try the search function
.
Example #1
Source File: integrations_all_in_one.py From pyimgui with BSD 3-Clause "New" or "Revised" License | 6 votes |
def main_glfw(): def glfw_init(): width, height = 1280, 720 window_name = "minimal ImGui/GLFW3 example" if not glfw.init(): print("Could not initialize OpenGL context") exit(1) # OS X supports only forward-compatible core profiles from 3.2 glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, 3) glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, 3) glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE) glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, gl.GL_TRUE) # Create a windowed mode window and its OpenGL context window = glfw.create_window( int(width), int(height), window_name, None, None ) glfw.make_context_current(window) if not window: glfw.terminate() print("Could not initialize Window") exit(1) return window window = glfw_init() impl = GlfwRenderer(window) while not glfw.window_should_close(window): glfw.poll_events() impl.process_inputs() imgui.new_frame() on_frame() gl.glClearColor(1., 1., 1., 1) gl.glClear(gl.GL_COLOR_BUFFER_BIT) imgui.render() impl.render(imgui.get_draw_data()) glfw.swap_buffers(window) impl.shutdown() glfw.terminate()
Example #2
Source File: integrations_glfw3.py From pyimgui with BSD 3-Clause "New" or "Revised" License | 5 votes |
def main(): imgui.create_context() window = impl_glfw_init() impl = GlfwRenderer(window) while not glfw.window_should_close(window): glfw.poll_events() impl.process_inputs() imgui.new_frame() if imgui.begin_main_menu_bar(): if imgui.begin_menu("File", True): clicked_quit, selected_quit = imgui.menu_item( "Quit", 'Cmd+Q', False, True ) if clicked_quit: exit(1) imgui.end_menu() imgui.end_main_menu_bar() imgui.show_test_window() imgui.begin("Custom window", True) imgui.text("Bar") imgui.text_colored("Eggs", 0.2, 1., 0.) imgui.end() gl.glClearColor(1., 1., 1., 1) gl.glClear(gl.GL_COLOR_BUFFER_BIT) imgui.render() impl.render(imgui.get_draw_data()) glfw.swap_buffers(window) impl.shutdown() glfw.terminate()
Example #3
Source File: window.py From demosys-py with ISC License | 5 votes |
def swap_buffers(self): """ Swaps buffers, incement the framecounter and pull events. """ self.frames += 1 glfw.swap_buffers(self.window) self.poll_events()
Example #4
Source File: window.py From demosys-py with ISC License | 5 votes |
def poll_events(self): """Poll events from glfw""" glfw.poll_events()
Example #5
Source File: window.py From moderngl-window with MIT License | 5 votes |
def swap_buffers(self): """Swap buffers, increment frame counter and pull events""" glfw.swap_buffers(self._window) self._frames += 1 glfw.poll_events()
Example #6
Source File: glfw_gui.py From dm_control with Apache License 2.0 | 5 votes |
def _update_gui_on_render_thread(self, window, pixels): self._fullscreen_quad.render(pixels, self.shape) glfw.swap_buffers(window) glfw.poll_events()
Example #7
Source File: glfw_app.py From pyopenvr with BSD 3-Clause "New" or "Revised" License | 5 votes |
def render_scene(self): "render scene one time" self.init_gl() # should be a no-op after the first frame is rendered glfw.make_context_current(self.window) self.renderer.render_scene() # Done rendering # glfw.swap_buffers(self.window) # avoid double buffering to avoid stalling glFlush() # single buffering glfw.poll_events()
Example #8
Source File: hellovr_glfw.py From pyopenvr with BSD 3-Clause "New" or "Revised" License | 5 votes |
def run_main_loop(self): while not glfw.window_should_close(self.window): self.handle_input() self.render_frame() glfw.swap_buffers(self.window) GL.glClearColor(0, 0, 0, 1) GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT) glfw.poll_events()
Example #9
Source File: fonts.py From pyimgui with BSD 3-Clause "New" or "Revised" License | 4 votes |
def main(): window = impl_glfw_init() impl = GlfwRenderer(window) font_scaling_factor = fb_to_window_factor(window) io = impl.io # clear font atlas to avoid downscaled default font # on highdensity screens. First font added to font # atlas will become default font. io.fonts.clear() # set global font scaling io.font_global_scale = 1. / font_scaling_factor # dictionary of font objects from our font directory fonts = { os.path.split(font_path)[-1]: io.fonts.add_font_from_file_ttf( font_path, FONT_SIZE_IN_PIXELS * font_scaling_factor, io.fonts.get_glyph_ranges_latin() ) for font_path in FONTS_DIR } secondary_window_main_font = random.choice(list(fonts.values())) impl.refresh_font_texture() while not glfw.window_should_close(window): glfw.poll_events() impl.process_inputs() imgui.new_frame() imgui.begin("Window with multiple custom fonts", True) imgui.text("This example showcases font usage on text() widget") for font_name, font in fonts.items(): imgui.separator() imgui.text("Font:{}".format(font_name)) with imgui.font(font): imgui.text("This text uses '{}' font.".format(font_name)) imgui.end() with imgui.font(secondary_window_main_font): imgui.begin("Window one main custom font", True) imgui.text("This window uses same custom font for all widgets") imgui.end() gl.glClearColor(1., 1., 1., 1) gl.glClear(gl.GL_COLOR_BUFFER_BIT) imgui.render() impl.render(imgui.get_draw_data()) glfw.swap_buffers(window) impl.shutdown() glfw.terminate()
Example #10
Source File: plots.py From pyimgui with BSD 3-Clause "New" or "Revised" License | 4 votes |
def main(): window = impl_glfw_init() imgui.create_context() impl = GlfwRenderer(window) plot_values = array('f', [sin(x * C) for x in range(L)]) histogram_values = array('f', [random() for _ in range(20)]) while not glfw.window_should_close(window): glfw.poll_events() impl.process_inputs() imgui.new_frame() imgui.begin("Plot example") imgui.plot_lines( "Sin(t)", plot_values, overlay_text="SIN() over time", # offset by one item every milisecond, plot values # buffer its end wraps around values_offset=int(time() * 100) % L, # 0=autoscale => (0, 50) = (autoscale width, 50px height) graph_size=(0, 50), ) imgui.plot_histogram( "histogram(random())", histogram_values, overlay_text="random histogram", # offset by one item every milisecond, plot values # buffer its end wraps around graph_size=(0, 50), ) imgui.end() gl.glClearColor(1., 1., 1., 1) gl.glClear(gl.GL_COLOR_BUFFER_BIT) imgui.render() impl.render(imgui.get_draw_data()) glfw.swap_buffers(window) impl.shutdown() glfw.terminate()