Commit Graph

22 Commits

Author SHA1 Message Date
Antonio Niño Díaz
82171bbf69 chore: Simplify copyright years in notices
Instead of listing every individual year, keep only the first and last
years.
2024-03-09 01:42:29 +00:00
Antonio Niño Díaz
951f0f87ca library: Support autodeleting palettes
In many cases the developer doesn't want to keep track of palettes and
materials as two different objects. This is only required if a palette
needs to be shared between multiple materials.

In cases where there a palette is only used by one material, this new
function can be used so that the developer doesn't need to keep track of
the palette object, only the material.
2024-03-02 12:42:31 +00:00
Antonio Niño Díaz
83dd805fe8 examples: library: docs: Fix "properties" typo everywhere
Function names have also been changed, but this patch adds defines to
preserve compatibility with old names for the time being.
2024-02-05 01:45:14 +00:00
Antonio Niño Díaz
640d2441f6 library: Add helper to load textures in GRF format 2024-01-25 02:42:38 +00:00
Antonio Niño Díaz
a57af044f4 library: Make some pointers void and const
It doesn't make sense to use other types because the modified functions
treat the data as a constant binary blob.
2024-01-22 02:26:57 +00:00
Antonio Niño Díaz
65b4eb55a3 library: Add alternate functions to load Texel 4x4 textures
They can be used to load textures where the 3 chunks are stored as
different files.
2024-01-21 17:00:12 +00:00
Antonio Niño Díaz
f57fa76576 library: Handle failures correctly
The previous code relied too much on assertions, even for things that
are just regular things that may happen while the application is running
(like running out of memory).

- Many assertions have been turned into permanent checks
- Some functions now return "success" or "failure".
- NE_Init3D() and NE_InitDual3D() (and others) have been reworked to
  handle failures gracefully.
2023-04-21 18:19:02 +01:00
Antonio Niño Díaz
9f6c719373 library: Decouple meshes from models
Until now, a mesh was always owned by one single model. This made it
very difficult to clone models, because the mesh was always owned by one
of them. Whenever you deleted that model, the mesh was also deleted, and
all the cloned models would be unusable.

With the new system, there is a list of meshes with counters of how many
models use them. This way no matter how many models use the mesh, the
mesh will only be deleted when the last model is deleted.

In addition, in a similar way as before, a mesh has a flag that signals
if free() has to be called on the mesh data when the mesh is deleted.
This is useful when the mesh is loaded from a filesystem and stored in a
buffer allocated with malloc(), which is what Nitro Engine does.

Note that this code should be considered experimental for the time
being, until some tests are added.
2022-11-18 01:23:57 +00:00
Antonio Niño Díaz
bc2a564f77 library: Assign palettes to materials instead of textures
Previously it wasn't possible to load one texture to a material, clone the
material, and assign different palettes to each clone of the material.

With this change, it is possible to have the same texture with different
palettes.
2022-11-05 01:22:53 +01:00
Antonio Niño Díaz
2ced018926 library: Cleanup palette loading functions 2022-10-31 01:40:45 +00:00
Antonio Niño Díaz
8aa6b382d2 library: examples: Simplify texture loading code
This is done to make it easier to implement compressed texture loading.

The main change is to stop allowing widths that aren't a power of two:

- Supporting them complicates the loading code a lot.

- Compressed textures can't really be expanded because they are composed
  by many 4x4 sub-images.

- They don't save space in VRAM.

- They save space in the final ROM, but you can achieve the same effect
  compressing them with LZSS compression, for example.

The example incomplete_texture has been updated to reflect the new
limitations.
2022-10-29 02:13:21 +01:00
Antonio Niño Díaz
406364d3db library: Simplify internal handling of material properties 2022-10-26 21:30:41 +01:00
Antonio Niño Díaz
b3440e9526 library: Rename some functions for consistency
NE_MaterialClone() clones everything, not just the texture.

NE_MaterialSetPalette() sets the palette of the material, not the
palette of the texture (different materials may use the same texture but
different palettes.
2022-10-25 23:45:03 +01:00
Antonio Niño Díaz
17f026bb8f library: Make many function parameters const
This helps the compiler issue warning if there is some logical error in
the code, and it helps the developer realize if some assumption with
the code is wrong.
2022-10-20 22:36:58 +01:00
Antonio Niño Díaz
3ebcac15ba library: examples: Add enums for texture formats and parameters
This helps discover the possible options.
2022-10-20 01:51:19 +01:00
Antonio Niño Díaz
ccc8a67caf library: Cleanup the final source files 2022-10-16 13:55:06 +01:00
Antonio Niño Díaz
b1856d453a Minor fixes to comments 2019-06-14 13:03:23 +01:00
Antonio Niño Díaz
ed020174f7 Reduce default number of allocated objects
Rather than wasting memory, allocate a smaller number of elements. If
someone needs more elements they can be allocated at runtime as usual by
reseting the desired subsystem with the desired number of elements.
2019-06-13 01:57:43 +01:00
Antonio Niño Díaz
ea18da8320 Define not-set values to -1
Rather than having arbitrarily high numbers, -1 works for any number of
allocated elements.
2019-06-13 01:53:55 +01:00
Antonio Niño Díaz
029587a061 Clean code style of texture subsystem 2019-06-10 00:56:10 +01:00
Antonio Niño Díaz
5be032ed44 Fix coding style of library
With a bit of help of `indent -linux`, but mostly by hand. Also used
`iconv -f ISO-8859-1 -t UTF-8//TRANSLIT` to convert to UTF-8.

There is still some refactoring left to do.
2019-06-04 01:02:56 +01:00
Antonio Niño Díaz
f042d0be3e
Initial dump of code of v0.6.1
This commit is a simple dump of the files of [1]. This needs to undergo
some reorganization.

[1] http://www.skylyrac.net/old-site/nitroengine.html
2019-05-29 01:01:57 +01:00