本文整理匯總了Python中glfw.poll_events方法的典型用法代碼示例。如果您正苦於以下問題:Python glfw.poll_events方法的具體用法?Python glfw.poll_events怎麽用?Python glfw.poll_events使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類glfw
的用法示例。
在下文中一共展示了glfw.poll_events方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main_glfw
# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import poll_events [as 別名]
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()
示例2: main
# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import poll_events [as 別名]
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()
示例3: swap_buffers
# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import poll_events [as 別名]
def swap_buffers(self):
"""
Swaps buffers, incement the framecounter and pull events.
"""
self.frames += 1
glfw.swap_buffers(self.window)
self.poll_events()
示例4: poll_events
# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import poll_events [as 別名]
def poll_events(self):
"""Poll events from glfw"""
glfw.poll_events()
示例5: swap_buffers
# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import poll_events [as 別名]
def swap_buffers(self):
"""Swap buffers, increment frame counter and pull events"""
glfw.swap_buffers(self._window)
self._frames += 1
glfw.poll_events()
示例6: _update_gui_on_render_thread
# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import poll_events [as 別名]
def _update_gui_on_render_thread(self, window, pixels):
self._fullscreen_quad.render(pixels, self.shape)
glfw.swap_buffers(window)
glfw.poll_events()
示例7: render_scene
# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import poll_events [as 別名]
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()
示例8: run_main_loop
# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import poll_events [as 別名]
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()
示例9: main
# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import poll_events [as 別名]
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()
示例10: main
# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import poll_events [as 別名]
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()