Skip to main content

A small software 3D renderer for pygame surfaces.

Project description

MiniPy3DR

MiniPy3DR is a tiny software 3D renderer for Pygame surfaces. It is designed for lessons, prototypes, and small games where students can see the basics of cameras, meshes, lights, flat shading, and z-buffer rendering.

Install

Recommended for Windows classroom PCs:

python -m pip install minipy3dr

This installs the matching prebuilt Windows wheel from PyPI for 64-bit Python 3.10, 3.11, 3.12, or 3.13. Students do not need Visual Studio Build Tools.

To pin a specific version for a class:

python -m pip install "minipy3dr==0.4.2"

Check that the native renderer is available:

python -c "from minipy3dr.render import is_native_available; print(is_native_available())"

App uses mode="auto" by default, which selects the native renderer when it is available and falls back to the NumPy renderer otherwise. To force native rendering:

from minipy3dr import App, NativeRenderer, Renderer

app = App(mode="native")

renderer = NativeRenderer(size=(800, 600))
# Same as: Renderer(size=(800, 600), mode="native")

With uv:

uv pip install minipy3dr

Installing from GitHub source is useful for teachers and development, but it is not the recommended classroom default because pip builds the C++ extension on the local PC:

python -m pip install "git+https://github.com/andogensi/MiniPy3DR.git"

With uv:

uv pip install "git+https://github.com/andogensi/MiniPy3DR.git"

From a specific branch or tag:

python -m pip install "git+https://github.com/andogensi/MiniPy3DR.git@main"
python -m pip install "git+https://github.com/andogensi/MiniPy3DR.git@v0.4.2"

From this repository:

python -m pip install .

For classroom development, use editable install:

python -m pip install -e .

or with uv:

uv pip install -e .

After that, student files can simply import the beginner API:

from minipy3dr import App

Quick Start

from minipy3dr import App

app = App(title="MiniPy3DR")
cube = app.cube(position=(0, 0, -5), size=2, color=(220, 120, 80), ambient=0.22)
app.light(direction=(-0.4, -0.8, -0.6))


def update(app, delta):
    app.rotate(cube, y=delta)


app.run(update=update)

Load OBJ Meshes

from minipy3dr import App

app = App(title="OBJ demo")
model = app.obj("assets/model.obj", position=(0, 0, -6), color=(160, 210, 255))
app.light(direction=(-0.4, -0.8, -0.6))


def update(app, delta):
    app.rotate(model, y=delta)


app.run(update=update)

For lower-level code, use load_obj(path) to get a Mesh:

from minipy3dr import load_obj

mesh = load_obj("assets/model.obj")

Run the Demo

python -m minipy3dr

or, after installation:

minipy3dr-demo

Renderer Benchmark

Compare the current renderer modes before changing the rasterizer:

python -m minipy3dr.benchmark

or, after installation:

minipy3dr-benchmark

The default benchmark runs these cases at 640x480 and 1280x720:

  • cube_100
  • cube_500
  • sphere_obj_1

You can also run the heavier example scene with --cases doom_like_shooter.

It measures solid, solid_numpy, and solid_native. solid_native uses the C++ extension when it is built; otherwise it is reported as skipped.

From source, install or rebuild the project to compile the native extension:

python -m pip install -e .

For a quick smoke run:

python -m minipy3dr.benchmark --frames 1 --warmup 0 --cases sphere_obj_1 --resolutions 640x480

Beginner Lessons

  • docs/beginner_api.md
  • docs/classroom_setup.md
  • examples/beginner_01_cube.py
  • examples/beginner_02_keyboard.py
  • examples/beginner_03_collect_game.py

Build

python -m pip install -e ".[dev]"
python -m build

With uv:

uv pip install -e ".[dev]"
uv run python -m build

The wheel and source archive will be written to dist/.

Publish to PyPI

Windows wheels are built by GitHub Actions and published to PyPI on version tags. Before the first release, configure a PyPI trusted publisher or pending publisher for repository andogensi/MiniPy3DR, workflow wheels.yml, and environment pypi.

To publish a new version, update the version in pyproject.toml and minipy3dr/__init__.py, then push a tag:

git tag v0.4.2
git push origin main
git push origin v0.4.2

The Build and publish package workflow uploads cp310, cp311, cp312, and cp313 Windows win_amd64 wheels plus the source distribution to PyPI. Those wheels include the C++ native renderer, so students can use pip install minipy3dr without Visual Studio Build Tools.

The workflow uses PyPI trusted publishing with the pypi GitHub Environment. It sets MINIPY3DR_REQUIRE_NATIVE=1, so PyPI wheels fail to build if the native extension is missing. Source installs keep the extension optional and fall back to the Python/NumPy renderer when no compiler is available.

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

minipy3dr-0.5.0.tar.gz (56.9 kB view details)

Uploaded Source

Built Distributions

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

minipy3dr-0.5.0-cp313-cp313-win_amd64.whl (258.9 kB view details)

Uploaded CPython 3.13Windows x86-64

minipy3dr-0.5.0-cp312-cp312-win_amd64.whl (258.9 kB view details)

Uploaded CPython 3.12Windows x86-64

minipy3dr-0.5.0-cp311-cp311-win_amd64.whl (259.0 kB view details)

Uploaded CPython 3.11Windows x86-64

minipy3dr-0.5.0-cp310-cp310-win_amd64.whl (259.0 kB view details)

Uploaded CPython 3.10Windows x86-64

File details

Details for the file minipy3dr-0.5.0.tar.gz.

File metadata

  • Download URL: minipy3dr-0.5.0.tar.gz
  • Upload date:
  • Size: 56.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for minipy3dr-0.5.0.tar.gz
Algorithm Hash digest
SHA256 2c6b6295a6715a3651a85ccac853763e389f10d1e8d8f1d95dae065122eaf448
MD5 e7a02eae45dc9ae96793a57c2c41a841
BLAKE2b-256 59c2cbc5de03c794f199b329fdab9e3d1f057a4277f879dc1a2038bd8e70c156

See more details on using hashes here.

Provenance

The following attestation bundles were made for minipy3dr-0.5.0.tar.gz:

Publisher: wheels.yml on andogensi/MiniPy3DR

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file minipy3dr-0.5.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: minipy3dr-0.5.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 258.9 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for minipy3dr-0.5.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 62121e2f81c4cf8041e4eb87532fddcf173539eaf0ff94ada2b6a37df5c3e738
MD5 b875d8257f36fcc331f24667d5d7109b
BLAKE2b-256 2bbd32bf977bb951cf7c15eae95d3d2d076597d9114c1d0c03ca398a0a1c75c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for minipy3dr-0.5.0-cp313-cp313-win_amd64.whl:

Publisher: wheels.yml on andogensi/MiniPy3DR

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file minipy3dr-0.5.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: minipy3dr-0.5.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 258.9 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for minipy3dr-0.5.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f22c576fb64918dd348f76f48460828fe4ea583ad41b8326d5873852e72c0e00
MD5 2db34b38131ed39674908b5c54fd77de
BLAKE2b-256 a3d6e9afe20697d092a3b8f5a9745ff382e24bb0004557c8f0886fc83799beb6

See more details on using hashes here.

Provenance

The following attestation bundles were made for minipy3dr-0.5.0-cp312-cp312-win_amd64.whl:

Publisher: wheels.yml on andogensi/MiniPy3DR

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file minipy3dr-0.5.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: minipy3dr-0.5.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 259.0 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for minipy3dr-0.5.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 71aa4a40edcba8421e490fcc3afa3545fc952c49bd518115d9ce85848ffb4a3f
MD5 3853fc5178245daf2db0093dc467c862
BLAKE2b-256 0dfb58f82c18a10fd443c1cc6e0912de520d47c7340976b88141759505a5c782

See more details on using hashes here.

Provenance

The following attestation bundles were made for minipy3dr-0.5.0-cp311-cp311-win_amd64.whl:

Publisher: wheels.yml on andogensi/MiniPy3DR

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file minipy3dr-0.5.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: minipy3dr-0.5.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 259.0 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for minipy3dr-0.5.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d7b20ffd4c58f32748782797c33bd7e9754b18dd1b9607c27e61c8433cfd6c28
MD5 2d7b145d19a1cd818c11acc20a83d2a1
BLAKE2b-256 34d892a2933559bdb0ae1e9dbf39f1ea931020f962c5624bab4078fa193dec72

See more details on using hashes here.

Provenance

The following attestation bundles were made for minipy3dr-0.5.0-cp310-cp310-win_amd64.whl:

Publisher: wheels.yml on andogensi/MiniPy3DR

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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