Commit Graph

25 Commits

Author SHA1 Message Date
Antonio Niño Díaz
8cb10264bb library: Support setting texture coordinates in sprites
This allows you to use one single texture for multiple images, and to
specify the coordinates that a sprite needs to use so that you don't need
to keep track of them.
2024-03-24 16:14:21 +00:00
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
a7f8353bac library: Set sprite size to the texture size it is assigned
What most people will want to do is to draw sprites with the same size as
the texture, so do that by default.
2024-02-28 02:50:29 +00:00
Antonio Niño Díaz
ee37e7fefc library: Remove texcoord offset when drawing 2D quads
This was a hack that was added to make up for an incorrect 2D projection
setup. It sometimes compensated the distortion caused by that
projection in order to display the 2D sprites correctly.

Commit 193a50c939 ("library: Fix 2D projection") fixed it, so this
patch removes the hack.
2023-09-25 02:28:59 +01:00
Antonio Niño Díaz
193a50c939 library: Fix 2D projection
The current factor of 12 is too big, and it causes significant Y axis
distortion in the 2D projection. It has been lowered to 2.

Check the comment in the code for more information.
2023-07-16 13:50:51 +01: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
15e2122514 library: Clean viewport handling code 2022-10-23 23:08:28 +01:00
Antonio Niño Díaz
86e73650d5 library: Replace some GL calls by register writes 2022-10-23 22:16:30 +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
c05b5ab2e1 library: Clean code and documentation of some files 2022-10-14 02:50:35 +01:00
Antonio Niño Díaz
d8eaaf2562 Remove unneeded casts 2019-06-10 17:17:19 +01:00
Antonio Niño Díaz
fd95ee34fe Replace malloc() by calloc() where it makes sense
If the memory is going to be cleared right away it is better to use
calloc(), as it does it automatically.
2019-06-10 17:17:08 +01:00
Antonio Niño Díaz
cec6b3d093 Remove return value in void function 2019-06-09 17:44:32 +01:00
Antonio Niño Díaz
aa1777ed75 Small cleanup of 2D subsystem 2019-06-09 17:20:04 +01:00
Antonio Niño Díaz
52c191c0df Simplify logic in NE_SpriteCreate() 2019-06-09 17:12:36 +01:00
Antonio Niño Díaz
e29cca88cd Use calloc instead of malloc 2019-06-09 17:08:35 +01:00
Antonio Niño Díaz
856559ee5e Fix memory leak in NE_SpriteCreate()
If there are no free slots the memory allocated for the NE_Sprite struct
isn't freed.
2019-06-09 17:06:37 +01:00
Antonio Niño Díaz
976cf4d4c6 Simplify NE_DebugPrint messages
The function name is now part of the macro.
2019-06-05 14:19:04 +01:00
Antonio Niño Díaz
a9ae923fff Simplify NE_Assert messages
The function name is now part of the macro.
2019-06-05 14:06:10 +01:00
Antonio Niño Díaz
d6a4a14e2b Simplify NE_AssertMinMax messages
The function name is now part of the macro.
2019-06-05 13:48:30 +01:00
Antonio Niño Díaz
700971beef Simplify NE_AssertPointer messages
Now the name of the function is added as part of the macro.
2019-06-05 13:41:35 +01:00
Antonio Niño Díaz
68d90b44c9 Remove occurrences of inline keyword
Let the compiler decide about it.
2019-06-04 18:24:22 +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
8f8bf4d249 Run dos2unix on library source files 2019-05-30 18:45:00 +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