How to use the wgpu.gui.glfw.get_framebuffer_size function in wgpu

To help you get started, we’ve selected a few wgpu examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github almarklein / wgpu-py / wgpu / gui / glfw.py View on Github external
def _set_logical_size(self):
        # There is unclarity about the window size in "screen pixels".
        # It appears that on Windows and X11 its the same as the
        # framebuffer size, and on macOS it's logical pixels.
        # See https://github.com/glfw/glfw/issues/845
        # Here, we simply do a quick test so we can compensate.

        # The target logical size
        lsize = self._logical_size
        pixel_ratio = glfw.get_window_content_scale(self._window)[0]
        # The current screen size and physical size, and its ratio
        ssize = glfw.get_window_size(self._window)
        psize = glfw.get_framebuffer_size(self._window)
        screen_ratio = ssize[0] / psize[0]
        # Apply
        glfw.set_window_size(
            self._window,
            int(lsize[0] * pixel_ratio / screen_ratio),
            int(lsize[1] * pixel_ratio / screen_ratio),
        )
github almarklein / wgpu-py / wgpu / gui / glfw.py View on Github external
def _get_logical_size(self):
        # Because the value of get_window_size is in physical pixels
        # on some systems and logical pixels on other, we use the
        # framebuffer size and pixel ratio to derive the logical size.
        psize = glfw.get_framebuffer_size(self._window)
        psize = int(psize[0]), int(psize[1])
        ratio = glfw.get_window_content_scale(self._window)[0]
        return psize[0] / ratio, psize[1] / ratio
github almarklein / wgpu-py / wgpu / gui / glfw.py View on Github external
def get_physical_size(self):
        psize = glfw.get_framebuffer_size(self._window)
        return int(psize[0]), int(psize[1])