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/dynamic.html
2023-05-22 17:01:19 +01:00

161 lines
No EOL
8.7 KiB
HTML
Raw Blame History

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="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Dynamic Bindings &mdash; Raylib Python documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.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 src="_static/jquery.js"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/sphinx_highlight.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="Building from source" href="BUILDING.html" />
<link rel="prev" title="C API" href="raylib.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" aria-label="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" role="heading"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="README.html">Python Bindings for Raylib 4.5</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#quickstart">Quickstart</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#installation">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#how-to-use">How to use</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#app-showcase">App showcase</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#rlzero">RLZero</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#help-wanted">Help wanted</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#license-updated">License (updated)</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#performance">Performance</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#packaging-your-app">Packaging your app</a></li>
<li class="toctree-l1"><a class="reference internal" href="README.html#advert">Advert</a></li>
<li class="toctree-l1"><a class="reference internal" href="pyray.html">Python API</a></li>
<li class="toctree-l1"><a class="reference internal" href="raylib.html">C API</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Dynamic Bindings</a></li>
<li class="toctree-l1"><a class="reference internal" href="BUILDING.html">Building from source</a></li>
<li class="toctree-l1"><a class="reference internal" href="RPI.html">Raspberry Pi</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" aria-label="Home"></a></li>
<li class="breadcrumb-item active">Dynamic Bindings</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/dynamic.rst.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">
<section id="dynamic-bindings">
<h1>Dynamic Bindings<a class="headerlink" href="#dynamic-bindings" title="Permalink to this heading"></a></h1>
<p>CFFI ABI dynamic bindings avoid the need to compile a C extension module. They now been moved to a separate module:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">python3</span> <span class="o">-</span><span class="n">m</span> <span class="n">pip</span> <span class="n">install</span> <span class="n">raylib_dynamic</span>
</pre></div>
</div>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>There have been some weird failures with dynamic bindings and ctypes bindings before and often the
failures are silent
so you dont even know something has gone wrong and you dont get proper stacktraces. Also the static bindings are faster.
Therefore I personally recommend the static ones.
But the dynamic bindings have the advantage that you dont need to compile anything to install. You just need a Raylib DLL.</p>
</div>
<p>The API is exactly the same as the static one documented here. (Therefore you cant have both modules installed at once.) The only difference is you cant do:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">raylib</span> <span class="kn">import</span> <span class="o">*</span>
</pre></div>
</div>
<p>Instead you have to do:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">raylib</span> <span class="kn">import</span> <span class="n">rl</span>
</pre></div>
</div>
<p>Then you access the functions with <code class="docutils literal notranslate"><span class="pre">rl.</span></code> prefix.</p>
<p>See <a class="reference external" href="https://github.com/electronstudio/raylib-python-cffi/blob/master/dynamic/test_dynamic.py">https://github.com/electronstudio/raylib-python-cffi/blob/master/dynamic/test_dynamic.py</a> for an example.</p>
<p>If you use the <code class="docutils literal notranslate"><span class="pre">rl.</span></code> prefix then code will work on both static and dynamic bindings.</p>
<div class="admonition tip">
<p class="admonition-title">Tip</p>
<p>If you access functions via <code class="docutils literal notranslate"><span class="pre">import</span> <span class="pre">pyray</span></code> then there is no difference at all, but be warned this hasnt been tested much.</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Standard Raylib DLLs do not include additional libraries like Raygui, Physac, etc. So these functions wont work.</p>
</div>
<div class="admonition important">
<p class="admonition-title">Important</p>
<p>If your system already has the Raylib library installed, you can set the environment variable <code class="docutils literal notranslate"><span class="pre">USE_EXTERNAL_RAYLIB</span></code> and it will
always be used instead of the bundled DLLs.</p>
</div>
</section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="raylib.html" class="btn btn-neutral float-left" title="C API" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="BUILDING.html" class="btn btn-neutral float-right" title="Building from source" 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>