This repository has been archived on 2025-06-21. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
raylib-python-cffi/docs
2021-10-03 17:09:46 +01:00
..
_sources update building docs 2021-10-03 17:09:46 +01:00
_static update building docs 2021-10-03 17:09:46 +01:00
generated update building docs 2021-10-03 17:09:46 +01:00
.buildinfo update building docs 2021-10-03 17:09:46 +01:00
.nojekyll dont use jekyll for docs 2021-08-27 03:44:28 +01:00
_config.yml Set theme jekyll-theme-cayman 2021-08-27 03:39:25 +01:00
BUILDING.html update building docs 2021-10-03 17:09:46 +01:00
dynamic.html update building docs 2021-10-03 17:09:46 +01:00
genindex.html update building docs 2021-10-03 17:09:46 +01:00
index.html update building docs 2021-10-03 17:09:46 +01:00
objects.inv update docstrings using raylib_api.json 2021-09-23 09:44:08 +01:00
py-modindex.html update building docs 2021-10-03 17:09:46 +01:00
pyray.html update building docs 2021-10-03 17:09:46 +01:00
raylib.html update building docs 2021-10-03 17:09:46 +01:00
README.html update building docs 2021-10-03 17:09:46 +01:00
search.html update building docs 2021-10-03 17:09:46 +01:00
searchindex.js update building docs 2021-10-03 17:09:46 +01:00

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Python Bindings for Raylib 3.7 &mdash; Raylib Python  documentation</title><link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
      <link rel="stylesheet" href="_static/graphviz.css" type="text/css" />
  <!--[if lt IE 9]>
    <script src="_static/js/html5shiv.min.js"></script>
  <![endif]-->
  <script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
        <script src="_static/jquery.js"></script>
        <script src="_static/underscore.js"></script>
        <script src="_static/doctools.js"></script>
    <script src="_static/js/theme.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="raylib.pyray" href="pyray.html" />
    <link rel="prev" title="Raylib Python" href="index.html" /> 
</head>

<body class="wy-body-for-nav"> 
  <div class="wy-grid-for-nav">
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
            <a href="index.html" class="icon icon-home"> Raylib Python
          </a>
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>
        </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
              <p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="current reference internal" href="#">Python Bindings for Raylib 3.7</a></li>
<li class="toctree-l1"><a class="reference internal" href="#license-updated">License (updated)</a></li>
<li class="toctree-l1"><a class="reference internal" href="#installation">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="#how-to-use">How to use</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#if-you-are-familiar-with-c-coding-and-the-raylib-c-library-and-you-want-to-use-an-exact-copy-of-the-c-api">If you are familiar with C coding and the Raylib C library and you want to use an exact copy of the C API</a></li>
<li class="toctree-l2"><a class="reference internal" href="#if-you-prefer-a-slightly-more-pythonistic-api-and-don-t-mind-it-might-be-slightly-slower">If you prefer a slightly more Pythonistic API and dont mind it might be slightly slower</a></li>
<li class="toctree-l2"><a class="reference internal" href="#if-you-insist-on-dynamic-bindings-and-don-t-care-that-they-are-slower-and-less-safe">If you insist on dynamic bindings and dont care that they are slower and less safe</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="#rlzero">RLZero</a></li>
<li class="toctree-l1"><a class="reference internal" href="#help-wanted">Help wanted</a></li>
<li class="toctree-l1"><a class="reference internal" href="#performance">Performance</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#bunnymark">Bunnymark</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="#packaging-your-app">Packaging your app</a></li>
<li class="toctree-l1"><a class="reference internal" href="#advert">Advert</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyray.html">raylib.pyray</a></li>
<li class="toctree-l1"><a class="reference internal" href="raylib.html">raylib.static</a></li>
<li class="toctree-l1"><a class="reference internal" href="dynamic.html">raylib.dynamic</a></li>
<li class="toctree-l1"><a class="reference internal" href="BUILDING.html">Building from source</a></li>
</ul>

        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="index.html">Raylib Python</a>
      </nav>

      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="index.html" class="icon icon-home"></a> &raquo;</li>
      <li>Python Bindings for Raylib 3.7</li>
      <li class="wy-breadcrumbs-aside">
            <a href="_sources/README.md.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
             
  <div class="tex2jax_ignore mathjax_ignore section" id="python-bindings-for-raylib-3-7">
<h1>Python Bindings for Raylib 3.7<a class="headerlink" href="#python-bindings-for-raylib-3-7" title="Permalink to this headline"></a></h1>
<p>New CFFI API static bindings.  Automatically generated to be as close as possible to
original Raylib.  Faster, fewer bugs and easier to maintain than ctypes.</p>
<p><a class="reference external" href="http://electronstudio.github.io/raylib-python-cffi">Full documentation</a></p>
</div>
<div class="tex2jax_ignore mathjax_ignore section" id="license-updated">
<h1>License (updated)<a class="headerlink" href="#license-updated" title="Permalink to this headline"></a></h1>
<p>The bindings are now under the Eclipse Public License, so you are free to
statically link and use in non-free / proprietary / commercial projects!</p>
</div>
<div class="tex2jax_ignore mathjax_ignore section" id="installation">
<h1>Installation<a class="headerlink" href="#installation" title="Permalink to this headline"></a></h1>
<p>We distribute a statically linked binary Raylib wheel:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>pip3 install raylib
</pre></div>
</div>
<p>Some platforms that <em>should</em> be available:  Windows 10 x64, MacOS 10.15 x64, Linux Ubuntu1804 x64.</p>
<p>If yours isnt available then pip will attempt to build from source, so you will need to have Raylib development libs installed.</p>
<p><a class="reference internal" href="BUILDING.html"><span class="doc std std-doc">If it doesnt work, build from source</span></a></p>
</div>
<div class="tex2jax_ignore mathjax_ignore section" id="how-to-use">
<h1>How to use<a class="headerlink" href="#how-to-use" title="Permalink to this headline"></a></h1>
<p>There are three different ways of using this binding.  You only need to pick one method, but you
can combine two methods in one program if you want to.</p>
<div class="section" id="if-you-are-familiar-with-c-coding-and-the-raylib-c-library-and-you-want-to-use-an-exact-copy-of-the-c-api">
<h2>If you are familiar with C coding and the Raylib C library and you want to use an exact copy of the C API<a class="headerlink" href="#if-you-are-familiar-with-c-coding-and-the-raylib-c-library-and-you-want-to-use-an-exact-copy-of-the-c-api" title="Permalink to this headline"></a></h2>
<p>Use <a class="reference external" href="https://electronstudio.github.io/raylib-python-cffi/raylib.html">raylib.static</a>.</p>
</div>
<div class="section" id="if-you-prefer-a-slightly-more-pythonistic-api-and-don-t-mind-it-might-be-slightly-slower">
<h2>If you prefer a slightly more Pythonistic API and dont mind it might be slightly slower<a class="headerlink" href="#if-you-prefer-a-slightly-more-pythonistic-api-and-don-t-mind-it-might-be-slightly-slower" title="Permalink to this headline"></a></h2>
<p>Use <a class="reference external" href="https://electronstudio.github.io/raylib-python-cffi/pyray.html">raylib.pyray</a>.</p>
</div>
<div class="section" id="if-you-insist-on-dynamic-bindings-and-don-t-care-that-they-are-slower-and-less-safe">
<h2>If you insist on dynamic bindings and dont care that they are slower and less safe<a class="headerlink" href="#if-you-insist-on-dynamic-bindings-and-don-t-care-that-they-are-slower-and-less-safe" title="Permalink to this headline"></a></h2>
<p>Use <a class="reference external" href="https://electronstudio.github.io/raylib-python-cffi/dynamic.html">raylib.dynamic</a>.</p>
</div>
</div>
<div class="tex2jax_ignore mathjax_ignore section" id="rlzero">
<h1>RLZero<a class="headerlink" href="#rlzero" title="Permalink to this headline"></a></h1>
<p>Work in progress:</p>
<p><a class="reference external" href="https://github.com/electronstudio/rlzero">A simplified API for Raylib for use in education and to enable beginners to create 3d games</a></p>
</div>
<div class="tex2jax_ignore mathjax_ignore section" id="help-wanted">
<h1>Help wanted<a class="headerlink" href="#help-wanted" title="Permalink to this headline"></a></h1>
<ul class="simple">
<li><p>converting more examples from C to python</p></li>
<li><p>testing and building on more platforms</p></li>
</ul>
</div>
<div class="tex2jax_ignore mathjax_ignore section" id="performance">
<h1>Performance<a class="headerlink" href="#performance" title="Permalink to this headline"></a></h1>
<p>For fastest permformance use Pypy rather than standard python.</p>
<p>Every call to C is costly, so its slightly faster if you use Python data structures and functions when calculating
in your update loop
and then only convert them to C data structures when you have to call the C functions for drawing.</p>
<div class="section" id="bunnymark">
<h2>Bunnymark<a class="headerlink" href="#bunnymark" title="Permalink to this headline"></a></h2>
<table class="colwidths-auto docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Library</p></th>
<th class="head"><p>Implementation</p></th>
<th class="head"><p>Bunnies (60 FPS)</p></th>
<th class="head"><p>Percentage</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>Raylib 3.7</p></td>
<td><p>C</p></td>
<td><p>168100</p></td>
<td><p>100%</p></td>
</tr>
<tr class="row-odd"><td><p>Raylib Python CFFI 3.7</p></td>
<td><p>Pypy 3.7</p></td>
<td><p>33800</p></td>
<td><p>20%</p></td>
</tr>
<tr class="row-even"><td><p>Raylib Python CFFI 3.7</p></td>
<td><p>Python 3.9</p></td>
<td><p>7700</p></td>
<td><p>4.5%</p></td>
</tr>
<tr class="row-odd"><td><p>Raylib Python CFFI 3.7</p></td>
<td><p>Python 3.9 Nuitka</p></td>
<td><p>8600</p></td>
<td><p>5.1%</p></td>
</tr>
<tr class="row-even"><td><p>Raylib Python CFFI 3.7 Dynamic</p></td>
<td><p>Python 3.9</p></td>
<td><p>6300</p></td>
<td><p>3.7%</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="tex2jax_ignore mathjax_ignore section" id="packaging-your-app">
<h1>Packaging your app<a class="headerlink" href="#packaging-your-app" title="Permalink to this headline"></a></h1>
<p>You can create a standalone binary using the Nuitka compiler.  For example, here is how to package Bunnymark:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>pip3 install nuitka
cd examples/textures
python3 -m nuitka --onefile --linux-onefile-icon resources/wabbit_alpha.png textures_bunnymark.py
</pre></div>
</div>
</div>
<div class="tex2jax_ignore mathjax_ignore section" id="advert">
<h1>Advert<a class="headerlink" href="#advert" title="Permalink to this headline"></a></h1>
<p><a class="reference external" href="https://store.steampowered.com/app/664240/RetroWar_8bit_Party_Battle/?git">RetroWar: 8-bit Party Battle</a> is out now.  Defeat up to 15 of your friends in a tournament of 80s-inspired retro mini games.</p>
<p><a class="reference external" href="https://github.com/electronstudio/pygame-zero-book">Coding Games With Pygame Zero &amp; Python</a> is
a book for Python beginners.</p>
</div>


           </div>
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="index.html" class="btn btn-neutral float-left" title="Raylib Python" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="pyray.html" class="btn btn-neutral float-right" title="raylib.pyray" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2021, Richard Smith.</p>
  </div>

  Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    provided by <a href="https://readthedocs.org">Read the Docs</a>.
   

</footer>
        </div>
      </div>
    </section>
  </div>
  <script>
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>