本文整理匯總了Python中glfw.window_should_close方法的典型用法代碼示例。如果您正苦於以下問題:Python glfw.window_should_close方法的具體用法?Python glfw.window_should_close怎麽用?Python glfw.window_should_close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類glfw
的用法示例。
在下文中一共展示了glfw.window_should_close方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _render_once
# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import window_should_close [as 別名]
def _render_once(self):
# See https://github.com/deepmind/dm_control/blob/92f9913013face0468442cd0964d5973ea2089ea/dm_control/viewer/gui/glfw_gui.py#L280 # noqa: E501
window = self._window
tick_func = self._tick_func
if (window._context
and not glfw.window_should_close(window._context.window)):
pixels = tick_func()
with window._context.make_current() as ctx:
ctx.call(window._update_gui_on_render_thread,
window._context.window, pixels)
window._mouse.process_events()
window._keyboard.process_events()
else:
window.close()
示例2: main_glfw
# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import window_should_close [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()
示例3: main
# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import window_should_close [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()
示例4: should_close
# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import window_should_close [as 別名]
def should_close(self):
"""
Ask glfw is the window should be closed
"""
return glfw.window_should_close(self.window)
示例5: is_closing
# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import window_should_close [as 別名]
def is_closing(self):
"""bool: Checks if the window is scheduled for closing"""
return glfw.window_should_close(self._window)
示例6: event_loop
# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import window_should_close [as 別名]
def event_loop(self, tick_func):
"""Runs the window's event loop.
This is a blocking call that won't exit until the window is closed.
Args:
tick_func: A callable, function to call every frame.
"""
while not glfw.window_should_close(self._context.window):
pixels = tick_func()
with self._context.make_current() as ctx:
ctx.call(
self._update_gui_on_render_thread, self._context.window, pixels)
self._mouse.process_events()
self._keyboard.process_events()
示例7: run_loop
# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import window_should_close [as 別名]
def run_loop(self):
"keep rendering until the user says quit"
while not glfw.window_should_close(self.window):
self.render_scene()
示例8: run_main_loop
# 需要導入模塊: import glfw [as 別名]
# 或者: from glfw import window_should_close [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 window_should_close [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 window_should_close [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()