3D engine for the Nintendo DS
Go to file
jonko0493 8932de1fff
Some checks failed
Documentation / Generate website (push) Has been cancelled
Documentation / Publish website with GitHub pages (push) Has been cancelled
rich text: Optionally return cursor position from dry run & allow indenting text
The goal of the changes made in this PR is to create something with this
effect ("Jonko" is in in green, the rest is in white):

    "Dear god." Jonko quickly replied,
    crestfallen.

In order to do this, I need to call `NE_RichTextRender3D` or
`NE_RichTextRender3DAlpha` three times: once to draw the first part of
the sentence with the white font, once to draw "Jonko" in turquoise, and
once to draw the remainder of the sentence in white again. In order to
ensure that text is being drawn in the correct location, I need the
position where the previous call stopped drawing, which leads to the
first change this PR makes: I have added a version of
`DSF_StringRenderDryRun` which accepts pointers to `final_x` and
`final_y` and stores the last position of `font->pointer_x` and
`font->pointer_y` in them and I have added a new variant of
`NE_RichTextRenderDryRun` called `NE_RichTextRenderDryRunWithPos` which
uses that DSF function and has analogous parameters.

These functions get us the position where we need to place the next
cursor, but the next issue is that currently NitroEngine and libDSF only
allow for specifying the position of the overall box to draw text in,
but not where to offset the cursor in that box. This leads to the
following problem ("Jonko" is in in green, the rest is in white):

    "Dear god." Jonko quickly replied,
                        crestfallen.

Thus, the second change: I have introduced new versions of
`DSF_StringRender3D` and `DSF_StringRender3DAlpha` which accept an
`xStart` position that is added to the `pointerX`. Correspondingly, I
have added versions of `NE_RichTextRender3D` and
`NE_RichTextRender3DAlpha` that use these new functions as well.

Let me know if there are any issues with how I've written this (C is not
my forte, after all), but the first screenshot is this being tested in
production code.
2025-06-11 00:03:38 +01:00
.github/workflows github: Add workflow to publish the documentation 2025-05-14 00:02:21 +01:00
docs docs: Document all Dual 3D modes 2023-10-18 22:29:17 +01:00
documentation docs: library: Update changelog and version number to 0.15.3 2025-03-26 18:08:47 +00:00
examples rich text: Allow the number of fonts to be specified dynamically 2025-05-25 01:32:55 +02:00
include rich text: Optionally return cursor position from dry run & allow indenting text 2025-06-11 00:03:38 +01:00
licenses examples: Change license to CC0-1.0 2022-10-16 22:55:06 +01:00
screenshots docs: Update sprites screenshot in readme 2024-03-24 16:52:19 +00:00
source rich text: Optionally return cursor position from dry run & allow indenting text 2025-06-11 00:03:38 +01:00
tests docs: build: library: examples: Set BlocksDS as main toolchain 2024-06-02 17:38:52 +01:00
tools tools: Update md5_2_dsma 2024-06-02 12:08:08 +01:00
.gitignore library: docs: example: Refactor debug mode builds 2022-10-21 00:50:13 +01:00
changelog.rst docs: library: Update changelog and version number to 0.15.3 2025-03-26 18:08:47 +00:00
Makefile build: docs: Remove outdated devkitARM makefiles 2025-03-24 21:03:01 +00:00
Makefile.blocksds build: Build library with debug symbols enabled 2025-03-26 18:06:36 +00:00
readme.rst build: docs: Remove outdated devkitARM makefiles 2025-03-24 21:03:01 +00:00

############
Nitro Engine
############

Introduction
============

This is a 3D game engine, a lot of functions designed to simplify the process of
making a 3D game. It isn't standalone, it needs libnds to work.

You can use Nitro Engine with `BlocksDS <https://blocksds.github.io/docs/>`_.

Features:

- Support for static models, converted from OBJ files.
- Support for animated models, thanks to the `DSMA library
  <https://github.com/AntonioND/dsma-library>`_, which converts MD5 models (with
  skeletal animation) into a format that can be rendered with hardware
  acceleration. It can also blend two animations together (for transitions).
- Support for all format of textures (even compressed textures, thanks to
  `ptexconv <https://github.com/Garhoogin/ptexconv>`_).
- Dual 3D (render 3D to both screens, but at 30 FPS instead of 60 FPS).
- Functions to render 2D images accelerated by 3D hardware.
- Text system based on `libDSF <https://github.com/AntonioND/libdsf>`_, which is
  based on `BMFont <https://www.angelcode.com/products/bmfont/>`_.
- Basic GUI elements like buttons and scrollbars.
- Basic physic system: Axis-aligned bounding boxes (AABB) only.

Nitro Engine doesn't support any of the 2D hardware of the DS. In order to use
the 2D hardware you can use libnds directly, or you can use a library like
`NFlib <https://github.com/knightfox75/nds_nflib>`_. There is an example of how
to integrate Nitro Engine and NFlib in the same project `here
<./examples/templates/using_nflib>`_.

Setup
=====

BlocksDS
--------

You can install this library with ``wf-pacman`` directly:

.. code:: bash

    wf-pacman -Sy blocksds-nitroengine

If you want to build the library from source, follow the instructions:

1. Clone this repository and run:

   .. code:: bash

       make install -j`nproc`

   This should build the library in both debug and release modes and install it.

2. If you want to check that everything is working as expected, open one of the
   folders of the examples and run:

   .. code:: bash

       make

   That should build an ``.nds`` file that you can run on an emulator or real
   hardware.

Note: The build system of the examples in this repository is make. The makefiles
aren't very flexible, and they don't support converting 3D models, or saving
graphics or models to the filesystem (you can only inject them as data to the
ARM9, which isn't acceptable for big games).

You can also try `ArchitectDS <https://github.com/AntonioND/architectds>`_. This
build system written in Python supports converting every format that Nitro
Engine supports, and it lets you save everything in NitroFS so that your game
can grow as much as you want. ArchitectDS comes with plenty of examples of how
to use it with Nitro Engine.

devkitPro
---------

**NOTE**: This option has been temporarily removed. The Makefiles that were
present in the repository were only valid in old versions of devkitARM,
unsupported by their maintainers. The code and examples will also need changes
to work with the new version of their libraries.

Usage notes
-----------

Note that some features of the 3D hardware aren't emulated by most emulators, so
you may need to use an actual NDS to test some things. **melonDS** seems to
emulate all features correctly. **DeSmuME** doesn't emulate the polygon/vertices
count registers, so the touch test feature of Nitro Engine doesn't work.

Normally you should link your programs with ``-lNE``, which is the release
version of Nitro Engine. If you want to use the debug features of Nitro Engine,
you should link with ``-lNE_debug``, and add ``-DNE_DEBUG`` to the ``CFLAGS``
and ``CPPFLAGS`` in your Makefile. Make sure to clean and rebuild your project
after doing the changes mentioned in this step. Check the **error_handling**
example to see how to use the debug mode of Nitro Engine.

Screenshots
===========

Screenshots of some of the examples included with Nitro Engine:

.. |animated_model| image:: screenshots/animated_model.png
.. |box_tower| image:: screenshots/box_tower.png
.. |fog| image:: screenshots/fog.png
.. |specular_material| image:: screenshots/specular_material.png
.. |screen_effects| image:: screenshots/screen_effects.png
.. |shadow_volume| image:: screenshots/shadow_volume.png
.. |sprites| image:: screenshots/sprites.png
.. |text| image:: screenshots/text.png

+------------------+-------------------+
| Animated model   | Box tower physics |
+------------------+-------------------+
| |animated_model| | |box_tower|       |
+------------------+-------------------+

+------------------+---------------------+
| Hardware fog     | Specular material   |
+------------------+---------------------+
| |fog|            | |specular_material| |
+------------------+---------------------+

+------------------+-------------------+
| Text             | Shadow volume     |
+------------------+-------------------+
| |text|           | |shadow_volume|   |
+------------------+-------------------+

+------------------+-------------------+
| Screen effects   | 2D sprites        |
+------------------+-------------------+
| |screen_effects| | |sprites|         |
+------------------+-------------------+

Contact
=======

This project is currently hosted on GitHub at:

    https://github.com/AntonioND/nitro-engine

If you want to contact me (Antonio Niño Díaz) directly you can email me at:

   antonio underscore nd at outlook dot com

License
=======

The code of this repository is under the MIT license. The examples are under the
CC0-1.0 license.

The full text of the licenses can be found under the ``licenses`` folder.

Future work
===========

- Asynchronous loading of assets (loading textures during VBL).

Thanks to
=========

- **devkitPro**: https://devkitpro.org/
- **DLDI**: https://www.chishm.com/DLDI/
- **DeSmuME**: http://desmume.org/
- **melonDS**: https://melonds.kuribo64.net/
- **no$gba**: https://problemkaputt.de/gba.htm
- **gbatek**: https://problemkaputt.de/gbatek.htm
- **gbadev forums**: https://forum.gbadev.org/