Пример #1
0
    def framebuffer_size(self):
        width = ffi.new('int *')
        height = ffi.new('int *')

        call('glfwGetWindowSize', self._window, width, height)

        return int(width), int(height)
Пример #2
0
    def get_position(self):
        x = ffi.new('int *')
        y = ffi.new('int *')

        call('glfwGetWindowPos', self._window, x, y)

        return int(x), int(y)
Пример #3
0
    def size(self):
        width = ffi.new('int *')
        height = ffi.new('int *')

        call('glfwGetMonitorPos', self._monitor, width, height)

        return int(width), int(height)
Пример #4
0
    def position(self):
        x = ffi.new('int *')
        y = ffi.new('int *')

        call('glfwGetMonitorPos', self._monitor, x, y)

        return int(x), int(y)
Пример #5
0
def get_version(verbose=False):
    if not verbose:
        major = ffi.new('int *')
        minor = ffi.new('int *')
        rev = ffi.new('int *')

        call('glfwGetVersion', major, minor, rev)

        return '{}.{}.{}'.format(major, minor, rev)
    else:
        return str(call('glfwGetVersionString'))
Пример #6
0
def get_primary_monitor():
    monitor = call('glfwGetPrimaryMonitor', )

    if monitor not in _monitors:
        _monitors[monitor] = Monitor(monitor)

    return _monitors[monitor]
Пример #7
0
def wait_events():
    """ Sleep until at least one event has been received.

    This will invoke all relevant window callbacks in the current thread.

    This function is not required for joystick input to work.

    .. note::
      - This function may only be called from the main thread.
      - This function may not be called from a callback.
      - On some platforms, certain callbacks may be called outside of a call
        to one of the event processing functions.

    .. seealso::
        :py:fun:`poll_events`

    """
    call('glfwWaitEvents')
Пример #8
0
def poll_events():
    """ Process events that have already been received and return immediately.

    This will invoke all relevant window callbacks in the current thread.

    This function is not required for joystick input to work.

    .. note::
      - This function may only be called from the main thread.
      - This function may not be called from a callback.
      - On some platforms, certain callbacks may be called outside of a call
        to one of the event processing functions.

    .. seealso::
      :py:fun:`wait_events`

    """
    call('glfwPollEvents')
Пример #9
0
    def __init__(self, width, height, title, monitor=None):
        self._title = str(title)
        if not isinstance(title, ffi.CData):
            title = ffi.new('const char[]', title.encode('utf-8'))

        if isinstance(monitor, Monitor):
            monitor = monitor._monitor

        if monitor is None:
            monitor = ffi.NULL

        self._window = call('glfwCreateWindow', width, height, title, monitor,
                            ffi.NULL)
Пример #10
0
 def set_position(self, x, y):
     call('glfwSetWindowSize', self._window, x, y)
Пример #11
0
 def set_title(self, title):
     self._title = str(title)
     if not isinstance(title, ffi.CData):
         title = ffi.new('const char *', title)
     call('glfwSetWindowTitle', self._window, title)
Пример #12
0
 def should_close(self):
     return bool(call('glfwWindowShouldClose', self._window))
Пример #13
0
 def swap_buffers(self):
     call('glfwSwapBuffers', self._window)
Пример #14
0
 def hide(self):
     call('glfwHideWindow', self._window)
Пример #15
0
 def restore(self):
     call('glfwRestoreWindow', self._window)
Пример #16
0
 def name(self):
     return str(call('glfwGetMonitorName', self._monitor))
Пример #17
0
 def set_size(self, width, height):
     call('glfwSetWindowSize', self._window, width, height)
Пример #18
0
 def show(self):
     call('glfwShowWindow', self._window)
Пример #19
0
 def iconify(self):
     call('glfwIconifyWindow', self._window)
Пример #20
0
 def make_current(self):
     call('glfwMakeContextCurrent', self._window)