Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 3
0
    def size(self):
        width = ffi.new('int *')
        height = ffi.new('int *')

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

        return int(width), int(height)
Exemplo n.º 4
0
    def position(self):
        x = ffi.new('int *')
        y = ffi.new('int *')

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

        return int(x), int(y)
Exemplo n.º 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'))
Exemplo n.º 6
0
def get_primary_monitor():
    monitor = call('glfwGetPrimaryMonitor', )

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

    return _monitors[monitor]
Exemplo n.º 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')
Exemplo n.º 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')
Exemplo n.º 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)
Exemplo n.º 10
0
 def set_position(self, x, y):
     call('glfwSetWindowSize', self._window, x, y)
Exemplo n.º 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)
Exemplo n.º 12
0
 def should_close(self):
     return bool(call('glfwWindowShouldClose', self._window))
Exemplo n.º 13
0
 def swap_buffers(self):
     call('glfwSwapBuffers', self._window)
Exemplo n.º 14
0
 def hide(self):
     call('glfwHideWindow', self._window)
Exemplo n.º 15
0
 def restore(self):
     call('glfwRestoreWindow', self._window)
Exemplo n.º 16
0
 def name(self):
     return str(call('glfwGetMonitorName', self._monitor))
Exemplo n.º 17
0
 def set_size(self, width, height):
     call('glfwSetWindowSize', self._window, width, height)
Exemplo n.º 18
0
 def show(self):
     call('glfwShowWindow', self._window)
Exemplo n.º 19
0
 def iconify(self):
     call('glfwIconifyWindow', self._window)
Exemplo n.º 20
0
 def make_current(self):
     call('glfwMakeContextCurrent', self._window)