本文整理汇总了Python中glfw.get_framebuffer_size方法的典型用法代码示例。如果您正苦于以下问题:Python glfw.get_framebuffer_size方法的具体用法?Python glfw.get_framebuffer_size怎么用?Python glfw.get_framebuffer_size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类glfw
的用法示例。
在下文中一共展示了glfw.get_framebuffer_size方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import get_framebuffer_size [as 别名]
def __init__(self, window, attach_callbacks=True):
super(GlfwRenderer, self).__init__()
self.window = window
if attach_callbacks:
glfw.set_key_callback(self.window, self.keyboard_callback)
glfw.set_cursor_pos_callback(self.window, self.mouse_callback)
glfw.set_window_size_callback(self.window, self.resize_callback)
glfw.set_char_callback(self.window, self.char_callback)
glfw.set_scroll_callback(self.window, self.scroll_callback)
self.io.display_size = glfw.get_framebuffer_size(self.window)
self._map_keys()
self._gui_time = None
示例2: process_inputs
# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import get_framebuffer_size [as 别名]
def process_inputs(self):
io = imgui.get_io()
window_size = glfw.get_window_size(self.window)
fb_size = glfw.get_framebuffer_size(self.window)
io.display_size = window_size
io.display_fb_scale = compute_fb_scale(window_size, fb_size)
io.delta_time = 1.0/60
if glfw.get_window_attrib(self.window, glfw.FOCUSED):
io.mouse_pos = glfw.get_cursor_pos(self.window)
else:
io.mouse_pos = -1, -1
io.mouse_down[0] = glfw.get_mouse_button(self.window, 0)
io.mouse_down[1] = glfw.get_mouse_button(self.window, 1)
io.mouse_down[2] = glfw.get_mouse_button(self.window, 2)
current_time = glfw.get_time()
if self._gui_time:
self.io.delta_time = current_time - self._gui_time
else:
self.io.delta_time = 1. / 60.
self._gui_time = current_time
示例3: fb_to_window_factor
# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import get_framebuffer_size [as 别名]
def fb_to_window_factor(window):
win_w, win_h = glfw.get_window_size(window)
fb_w, fb_h = glfw.get_framebuffer_size(window)
return max(float(fb_w) / win_w, float(fb_h) / win_h)
示例4: resize
# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import get_framebuffer_size [as 别名]
def resize(self, width, height):
"""
Sets the new size and buffer size internally
"""
self.width = width
self.height = height
self.buffer_width, self.buffer_height = glfw.get_framebuffer_size(self.window)
self.set_default_viewport()
示例5: glfw_window_resize_callback
# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import get_framebuffer_size [as 别名]
def glfw_window_resize_callback(self, window, width, height):
"""
Window resize callback for glfw
Args:
window: The window
width: New width
height: New height
"""
self._width, self._height = width, height
self._buffer_width, self._buffer_height = glfw.get_framebuffer_size(self._window)
self.set_default_viewport()
super().resize(self._buffer_width, self._buffer_height)
示例6: _glfw_setup
# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import get_framebuffer_size [as 别名]
def _glfw_setup(self, window):
glfw.set_cursor_pos_callback(window, self._handle_move)
glfw.set_mouse_button_callback(window, self._handle_button)
glfw.set_scroll_callback(window, self._handle_scroll)
framebuffer_width, _ = glfw.get_framebuffer_size(window)
window_width, _ = glfw.get_window_size(window)
return framebuffer_width, window_width
示例7: shape
# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import get_framebuffer_size [as 别名]
def shape(self):
"""Returns a tuple with the shape of the window, (width, height)."""
with self._context.make_current() as ctx:
return ctx.call(glfw.get_framebuffer_size, self._context.window)
示例8: __init__
# 需要导入模块: import glfw [as 别名]
# 或者: from glfw import get_framebuffer_size [as 别名]
def __init__(self, **kwargs):
super().__init__(**kwargs)
if not glfw.init():
raise ValueError("Failed to initialize glfw")
# Configure the OpenGL context
glfw.window_hint(glfw.CONTEXT_CREATION_API, glfw.NATIVE_CONTEXT_API)
glfw.window_hint(glfw.CLIENT_API, glfw.OPENGL_API)
glfw.window_hint(glfw.CONTEXT_VERSION_MAJOR, self.gl_version[0])
glfw.window_hint(glfw.CONTEXT_VERSION_MINOR, self.gl_version[1])
glfw.window_hint(glfw.OPENGL_PROFILE, glfw.OPENGL_CORE_PROFILE)
glfw.window_hint(glfw.OPENGL_FORWARD_COMPAT, True)
glfw.window_hint(glfw.RESIZABLE, self.resizable)
glfw.window_hint(glfw.DOUBLEBUFFER, True)
glfw.window_hint(glfw.DEPTH_BITS, 24)
glfw.window_hint(glfw.SAMPLES, self.samples)
monitor = None
if self.fullscreen:
monitor = glfw.get_primary_monitor()
mode = glfw.get_video_mode(monitor)
self._width, self._height = mode.size.width, mode.size.height
glfw.window_hint(glfw.RED_BITS, mode.bits.red)
glfw.window_hint(glfw.GREEN_BITS, mode.bits.green)
glfw.window_hint(glfw.BLUE_BITS, mode.bits.blue)
glfw.window_hint(glfw.REFRESH_RATE, mode.refresh_rate)
self._window = glfw.create_window(self.width, self.height, self.title, monitor, None)
self._has_focus = True
if not self._window:
glfw.terminate()
raise ValueError("Failed to create window")
self.cursor = self._cursor
self._buffer_width, self._buffer_height = glfw.get_framebuffer_size(self._window)
glfw.make_context_current(self._window)
if self.vsync:
glfw.swap_interval(1)
else:
glfw.swap_interval(0)
glfw.set_key_callback(self._window, self.glfw_key_event_callback)
glfw.set_cursor_pos_callback(self._window, self.glfw_mouse_event_callback)
glfw.set_mouse_button_callback(self._window, self.glfw_mouse_button_callback)
glfw.set_scroll_callback(self._window, self.glfw_mouse_scroll_callback)
glfw.set_window_size_callback(self._window, self.glfw_window_resize_callback)
glfw.set_char_callback(self._window, self.glfw_char_callback)
glfw.set_window_focus_callback(self._window, self.glfw_window_focus)
glfw.set_cursor_enter_callback(self._window, self.glfw_cursor_enter)
glfw.set_window_iconify_callback(self._window, self.glfw_window_iconify)
self.init_mgl_context()
self.set_default_viewport()