Skip to main content

Python wrapper for BGFX Library

Project description


BGFX Python

Python 3.7+ wrapper for the BGFX library.



Key FeaturesHow To Use • • Using ImGUIExamplesLoggingCreditsLicense

Key Features

  • Uses Cppyy to natively wrap the C++ interface. No CTypes or ugly C interfaces.
  • Unless specified, the GIL is released for every invocation and pointers are passed by reference. This will ensure great overall performances.
  • Maintains the original documentation; use help() on a class or function to view it.
  • Compiles shaders on-the-fly, so you don't have to.
  • Ships with ImGui integrated in the BGFX rendering pipeline.

How To Use

Precompiled wheels

Precompiled wheels are available for Windows, Linux and MacOS. To install the latest published release, simply run:

$ pip install bgfx-python

Install from source

To install the latest version, you'll need to clone this repository and its submodules:

$ git clone --depth=1 https://github.com/fbertola/bgfx-python
$ git submodule update --init --recursive

Then, make sure to have make, cmake and ninja installed in your system.

Install the required dependency through poetry:

$ pip install poetry
$ poetry install

Finally, simply build and install the wheel.

$ pip setup.py install

Installing on MacOS

Building on MacOS X > 10.14 requires you to also install the SDK headers:

xcode-select --install
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
export SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk 

Installing on Windows

The easiest way is to install Visual Studio 2017 Community Edition. If you have Chocolatey installed, then run:

choco install visualstudio2017community

Before building the package, make sure to activate all the environment variables required by the compiler:

call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64

Using ImGUI

Two modules are exposed:

  • ImGui, which provides a standard wrapper around all the ImGui funcions and classes.
  • ImGuiExtra, which provides some additional functions to integrate ImGui in the BGFX rendering pipline.

To use it in your application, simply follow this template:

# Setup the application
def init():
    ImGuiExtra.create()

# Destroy the application
def destroy():
    ImGuiExtra.destroy()

# Update the application, rendering each fram
def update():
    ImGuiExtra.beginFrame(
        mouse_x, mouse_y, buttons_states, 0, width, height
    )

    # Other ImGui drawing directives...

    ImGuiExtra.endFrame()

Logging

Loguru is used for logging inside bgfx_python. By default the logger is disabled; to enable it, use the following instructions:

from loguru import logger

logger.enable("bgfx")

Examples

You will find some examples in the examples folder, be sure to check them out. For a more advanced example, see the Natrix project.

Credits

This software uses the following open source packages:

License (BSD 2-clause)

BSD 2-Clause License

Copyright (c) 2021, Federico Bertola
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

GitHub @fbertola

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bgfx-python-2.0.1.tar.gz (11.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

bgfx_python-2.0.1-cp39-cp39-win_amd64.whl (7.1 MB view details)

Uploaded CPython 3.9Windows x86-64

bgfx_python-2.0.1-cp39-cp39-manylinux_2_24_x86_64.whl (48.6 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.24+ x86-64

bgfx_python-2.0.1-cp39-cp39-macosx_10_9_x86_64.whl (9.7 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

bgfx_python-2.0.1-cp38-cp38-win_amd64.whl (7.1 MB view details)

Uploaded CPython 3.8Windows x86-64

bgfx_python-2.0.1-cp38-cp38-manylinux_2_24_x86_64.whl (48.6 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.24+ x86-64

bgfx_python-2.0.1-cp38-cp38-macosx_10_9_x86_64.whl (9.7 MB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

bgfx_python-2.0.1-cp37-cp37m-win_amd64.whl (7.1 MB view details)

Uploaded CPython 3.7mWindows x86-64

bgfx_python-2.0.1-cp37-cp37m-manylinux_2_24_x86_64.whl (48.6 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.24+ x86-64

bgfx_python-2.0.1-cp37-cp37m-macosx_10_9_x86_64.whl (9.7 MB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

File details

Details for the file bgfx-python-2.0.1.tar.gz.

File metadata

  • Download URL: bgfx-python-2.0.1.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.11

File hashes

Hashes for bgfx-python-2.0.1.tar.gz
Algorithm Hash digest
SHA256 cfc99ab01b60c3254f580a51a945345c6c311656051230de8183c9045539b62e
MD5 acb885998d20d9ea2667e00cccdd0759
BLAKE2b-256 212e62293d0bc98dae678a3027e5c4c9c89bd0d7fab8e78424d5cb2facce91ea

See more details on using hashes here.

File details

Details for the file bgfx_python-2.0.1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: bgfx_python-2.0.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 7.1 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.11

File hashes

Hashes for bgfx_python-2.0.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 31b4be4b791d28bfd75ed3ee92ddfadfa5b74f631bbf5202d325cf2bd1575d24
MD5 bd285fb69002a269035268c8b64d6729
BLAKE2b-256 05c51104e0308e4ad97932e9b6ce2af46171b760c15801a43377969cdfda714b

See more details on using hashes here.

File details

Details for the file bgfx_python-2.0.1-cp39-cp39-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: bgfx_python-2.0.1-cp39-cp39-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 48.6 MB
  • Tags: CPython 3.9, manylinux: glibc 2.24+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.11

File hashes

Hashes for bgfx_python-2.0.1-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 ea66bc03875bf17cb7ecd44280a756faa816df360b4fe0862e2a35f228e44ebd
MD5 452c331770572a81e3c69b9ca96a6406
BLAKE2b-256 45a52a83e9f9350f74872c41725adcd1770c9b3af4ba93df94ada2a32b0a21b7

See more details on using hashes here.

File details

Details for the file bgfx_python-2.0.1-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: bgfx_python-2.0.1-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 9.7 MB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.11

File hashes

Hashes for bgfx_python-2.0.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4cc51193502bb7c8ad23b57153336a34a73e9869f11ac7901ac82af9d8f60b1b
MD5 4e4f6de2a41bc35059c5c369df931638
BLAKE2b-256 6ce4120efc1b6b051d28d58d52db48d1b3ce16d78cb4d72778fdd50ae6a441ac

See more details on using hashes here.

File details

Details for the file bgfx_python-2.0.1-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: bgfx_python-2.0.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 7.1 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.11

File hashes

Hashes for bgfx_python-2.0.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 80d17fd07108b9f9cbb56b4c966689485ba0c138d5845975a514e1b9d9bbbd88
MD5 e085737f0ec7a5975cb8d07fc6df6c40
BLAKE2b-256 ccc1392f1fbbbbdd77ce965edc24424d1bedb11ee8e274581aab6d9a0364a82e

See more details on using hashes here.

File details

Details for the file bgfx_python-2.0.1-cp38-cp38-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: bgfx_python-2.0.1-cp38-cp38-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 48.6 MB
  • Tags: CPython 3.8, manylinux: glibc 2.24+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.11

File hashes

Hashes for bgfx_python-2.0.1-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 0bcfcfbc64fe4a47c10db953ce688b6037e0ec8f4e6c240449308858b207d570
MD5 84adb60cce9d52a1c1391a1de808951b
BLAKE2b-256 f99fdf0649f0210c70f887c51c4396ddddcb37254968b9b94cf9c24357f02f71

See more details on using hashes here.

File details

Details for the file bgfx_python-2.0.1-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: bgfx_python-2.0.1-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 9.7 MB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.11

File hashes

Hashes for bgfx_python-2.0.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f790b874f1b9d29842920fc99902a89d732d46719d0ef4799b8f7c3dd4ed4c0e
MD5 c4085ad14cfa6e0dbcc2f5a9242ab9ca
BLAKE2b-256 5fad11ff1b79c6494d0e1221e3073cd11ea6b2f3bbb105b9918b72b75ea08fc1

See more details on using hashes here.

File details

Details for the file bgfx_python-2.0.1-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: bgfx_python-2.0.1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 7.1 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.11

File hashes

Hashes for bgfx_python-2.0.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 cd8195d46e780f4678a73d92629bb1d59b233a9cba0e0a09b9988b66b2e07fce
MD5 d67f29e5b4e417c326d17b383a99952e
BLAKE2b-256 7b1bef04395a57bd30df690e6699ac00c2aecb346f171f6400f050c3b7ca067e

See more details on using hashes here.

File details

Details for the file bgfx_python-2.0.1-cp37-cp37m-manylinux_2_24_x86_64.whl.

File metadata

  • Download URL: bgfx_python-2.0.1-cp37-cp37m-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 48.6 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.24+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.11

File hashes

Hashes for bgfx_python-2.0.1-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 8433b37b3a3d85f6ad30bddde7a95ff8911cbd7fd50983bbfe927917b4bd447a
MD5 8727c84e0d4ae2f92a11b5f437715098
BLAKE2b-256 89ec5f47e00f3fbb218b72f579122f6e11a5335723e1bef1db9d4cc43b5a7ecf

See more details on using hashes here.

File details

Details for the file bgfx_python-2.0.1-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: bgfx_python-2.0.1-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 9.7 MB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.11

File hashes

Hashes for bgfx_python-2.0.1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 fd400488d7ceaa77c91b9f79b804c7ac97918aa119f5f34337751bb0ada43a51
MD5 ed9bc85c45391ba26d00a75672cfedf3
BLAKE2b-256 a1be1c7b9ce2431f4469cc62f18f90a64d7b78ba6aafc0d9a28ef399efe38f2a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page