pyglfw

HomePage: https://bitbucket.org/pyglfw/pyglfw

Author: Roman Valov

Download: https://pypi.python.org/packages/source/p/pyglfw/pyglfw-0.1.0.tar.gz

        ======
pyglfw
======

Python bindings for the `GLFW <http://www.glfw.org/>`_ library.

Home: https://bitbucket.org/pyglfw/pyglfw

Introduction
============

At the moment of development there were already available
numerous variants of bindings for the glfw library to python.
Besides driving by NIH syndrome these binding were developed
with following assumptions in mind:

 - Compatibility with GLFW version 3 and higher api.
 - Support for both Python2 (2.7) and Python3 (3.3+).
 - Provide low-level and pythonic api separately.
 - No external dependencies. Thus using ctypes.

Platforms
---------

During development these bindings were proven to work 
on all major operating systems environments including
Windows, OSX and Linux.

CPython implementations were tested against versions
of Python 2.7 and Python 3.3 with no serious issues found.

By the way testing was performed with PyPy. As a result there
were revealed issue with ctypes implemenation in PyPy. Issue
was fixed and should be available as a part of PyPy 2.2.2.


Licensing
---------

These bindings are distributed under the terms and
conditions of zlib license with the exception to files
in examples folder which are provided with no limitations
to use. Full text of license with copyright notice is
provided in the LICENSE file.

-------

Installation
============

Ensure you've installed GLFW shared library binary
according to instructions on project's page related
to installed operating system.

At the moment these binding could be installed with
provided setup.py script. To do this retrieve sources
either cloning repository or downloading and unpacking
source archive. Following commands depend on system
used.


On Linux and OSX
----------------

::

    $ python ./setup.py sdist

then

::

    # easy_install dist/pyglfw-<ver>.tar.gz

or

::

    # pip install dist/pyglfw-<ver>.tar.gz


On Windows
----------

::

    > python.exe setup.py bdist_wininst

then run exe installer from dist folder.

NOTE: Prebuilt exe installers could be found on the
project's home `download page`__

__ https://bitbucket.org/pyglfw/pyglfw/downloads

-------

Libapi
======

Low-level **libapi** package serves as thin wrapper
above GLFW library. It's api mostly resemble one of
C library except functions that require pass-by-ref
parameters. As a rule of thumb all functions that
return void and fill several values via pass-by-ref
parameters are mapped to functions returning tuple
of values. And functions that return pointer to array
with number of items set via pass-by-ref parameter are 
mapped to functions returning list of items. I.e.:

::

    int major, minor, rev;
    glfwGetVersion(&major, &minor, &rev)

becomes

::

    major, minor, rev = glfwGetVersion()

and

::

    int n_items;
    GLFWmonitor **monitors = glfwGetMonitors(&n_items)

becomes

::
     
    monitors = glfwGetMonitors()


Special note should be done regarding window pointer
functions. glfwSetWindowPointer allows to set any 
python object as a window private data and retrieve
it back with glfwGetWindowPointer. However it's still
required to hold reference to this object in python
code. Also this functionality will not work with PyPy
implemetation due to lack of py_object support.

The requirement to hold references also spreads to
functions that are settings varios callbacks. Please
refer to *raw_api* in examples for usage primer.

Pyglfw
======

Pythonic **pyglfw** package handles following moments:

 - Encapsulation of struct pointers and functions api
   into objects with properties and methods.
 - Transparent usage of strings (either from python 2
   or from python 3).
 - Raising exceptions in case of errors.
 - Eliminates need to use of ctypes structures and
   ctypes-based callback prototypes.
 - Holds references for set to callback functions,
   so there is no need to hold them outside.
 - Provide pythonic types for callback functions.

and following functionality is restricted:

 - No get/set window pointers. Due to its ambiquity.
 - No set error callback. Error callback is used to
   raise exeptions.
 - Set ca