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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

bgfx_python-2.0.0-cp39-cp39-win_amd64.whl (7.0 MB view details)

Uploaded CPython 3.9Windows x86-64

bgfx_python-2.0.0-cp39-cp39-manylinux_2_24_x86_64.whl (48.1 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.24+ x86-64

bgfx_python-2.0.0-cp39-cp39-macosx_10_9_x86_64.whl (9.4 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

bgfx_python-2.0.0-cp38-cp38-win_amd64.whl (7.0 MB view details)

Uploaded CPython 3.8Windows x86-64

bgfx_python-2.0.0-cp38-cp38-manylinux_2_24_x86_64.whl (48.1 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.24+ x86-64

bgfx_python-2.0.0-cp38-cp38-macosx_10_9_x86_64.whl (9.4 MB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

bgfx_python-2.0.0-cp37-cp37m-win_amd64.whl (7.0 MB view details)

Uploaded CPython 3.7mWindows x86-64

bgfx_python-2.0.0-cp37-cp37m-manylinux_2_24_x86_64.whl (48.1 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.24+ x86-64

bgfx_python-2.0.0-cp37-cp37m-macosx_10_9_x86_64.whl (9.4 MB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: bgfx_python-2.0.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 7.0 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.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 488fa86e22ed1190fb4cf2fd1125c67bbf862e5ecf30bfcb651711f655e17b46
MD5 973b2a755529869a3a8d590d66e6d8e6
BLAKE2b-256 4fa1afcd1ce6f71c98ff74d033e0e58c41cabbb70f92008d3d249ec4815aae09

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bgfx_python-2.0.0-cp39-cp39-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 48.1 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.0-cp39-cp39-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 02c1189c83cec992c9ff901446575b1009baf98707beed9fc38985591814b633
MD5 cab5bebf87f897cf05fabccf17449e88
BLAKE2b-256 80536236eef1508a8fe96def98442c75aafb69f1e9e267baa401cc9187636a2c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bgfx_python-2.0.0-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 9.4 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.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 62a3c46cf47a885d2c73130da8d1fc293e20dd5ee9645741710a43800fc8ed8e
MD5 166b5e80718e7764083b2648bdcb29f5
BLAKE2b-256 f74290f5ff55a6fbb30e6713be4675877111da8ee729d7422987aa0b10a08b24

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bgfx_python-2.0.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 7.0 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.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 92288d4b38ab1c217f98d9fe6adb0909ad9982bda0fcaa761076743853225489
MD5 472ff02b2a4edaf01b1e896ad1629a29
BLAKE2b-256 51842876abedbcfdb955a1644d598111fda70759014af8eb78b4be6732758ac7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bgfx_python-2.0.0-cp38-cp38-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 48.1 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.0-cp38-cp38-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 2770061f69d35330565d532403f8a571e529c570dc5995906abbd65260c930b7
MD5 af5be45ad66b2fc09099dd0fee28db30
BLAKE2b-256 67e815585dbf6b928aa16ee994f302bb54489bdba22fb88b0fb1e5cef7125049

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bgfx_python-2.0.0-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 9.4 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.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 79911519634d2768840cf393a23da83fc5bfb2a11e886d34a4e85edd579f29a6
MD5 49591aa8b581b15fff478025deedb3c6
BLAKE2b-256 921e12473f993cd9ff92678508d76fdb360eea3ff572a4cf18f112fc79065642

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bgfx_python-2.0.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 7.0 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.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 4ddf3286dd650054e2864f7282a5a0d7216d1100936919afc339497064f7f9f8
MD5 c959add304efe7da2d354190f477b8a7
BLAKE2b-256 4ffbeb664cd58bb9925c58859afecc5d11b83915f0abe330e91abf4530109c25

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bgfx_python-2.0.0-cp37-cp37m-manylinux_2_24_x86_64.whl
  • Upload date:
  • Size: 48.1 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.0-cp37-cp37m-manylinux_2_24_x86_64.whl
Algorithm Hash digest
SHA256 3e36ef48c39f48049b7fb6b46aab0ca0aae75be326ca834d3232e9e40fe69884
MD5 6bd9660558b12ae881148f98daff5d8e
BLAKE2b-256 4099bf94d581fb50b4e19864f3d39d6e16c1412631608d77e2dc94c5e6d26bc3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: bgfx_python-2.0.0-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 9.4 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.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 91c23e1424a5c22e655326974a6e8c8e15a1905d7f63c91b4de22020c9bc42c3
MD5 09fa9c910efabccba384547a02b76dab
BLAKE2b-256 50b96af7a32be7040ee1f161b537a49ecc713a2baa9b32257ad533ec8cddecfd

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