当前位置: 首页>>代码示例>>Python>>正文


Python glfw.window_should_close方法代码示例

本文整理汇总了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() 
开发者ID:rlworkgroup,项目名称:garage,代码行数:16,代码来源:dm_control_viewer.py

示例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() 
开发者ID:swistakm,项目名称:pyimgui,代码行数:38,代码来源:integrations_all_in_one.py

示例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() 
开发者ID:swistakm,项目名称:pyimgui,代码行数:42,代码来源:integrations_glfw3.py

示例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) 
开发者ID:Contraz,项目名称:demosys-py,代码行数:7,代码来源:window.py

示例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) 
开发者ID:moderngl,项目名称:moderngl-window,代码行数:5,代码来源:window.py

示例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() 
开发者ID:deepmind,项目名称:dm_control,代码行数:17,代码来源:glfw_gui.py

示例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() 
开发者ID:cmbruns,项目名称:pyopenvr,代码行数:6,代码来源:glfw_app.py

示例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() 
开发者ID:cmbruns,项目名称:pyopenvr,代码行数:10,代码来源:hellovr_glfw.py

示例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() 
开发者ID:swistakm,项目名称:pyimgui,代码行数:63,代码来源:fonts.py

示例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() 
开发者ID:swistakm,项目名称:pyimgui,代码行数:49,代码来源:plots.py


注:本文中的glfw.window_should_close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。