Commit Graph

122 Commits

Author SHA1 Message Date
Bart van Strien 9e4374935d Show (short) list of possible enum values when an invalid value is encountered (resolves #1318)
All enum errors have (hopefully) been changed to a luax_enumerror, which has a
fixed error message. If additionally a list of valid options is passed, it
lists that in the error message. For every enum error with few options I've
implemented this using a getConstants call.

This solution has been designed specifically to reduce the number of template
instantiations (as I've been told that was a concern). All new template code
happens in places where there already was an instantiation of the relevant
StringMap. Of course there is still std::vector<std::string>...

--HG--
branch : minor
2017-10-02 17:11:53 +02:00
Alex Szpakowski 90e86c329d Add love.data module.
- Moved love.math.compress / decompress / decode / encode / hash to love.data.
- Changed love.data.compress/decompress to take the format argument first instead of second.
- Added love.data.newDataView. Returns a read-only subsection of an existing Data object.
- Added love.data.newByteData. Mostly useful in combination with LuaJIT's FFI as it has no extra methods currently.
- Added implementations of Lua 5.3's data packing APIs: love.data.packString / packData / unpack / getPackedSize.

Resolves issue #1336.
Resolves issue #1331.

--HG--
branch : minor
2017-09-24 19:25:27 -03:00
Alex Szpakowski 5f64737956 Shader:send now optionally accepts a Data object (with optional byte offset and size parameters). Resolves issue #1343.
Also changed the optional 'columnMajor' argument of the matrix variant of Shader:send and Transform:setMatrix to accept enum constants instead. Valid values are "row" and "column".

--HG--
branch : minor
2017-09-23 19:47:57 -03:00
Alex Szpakowski fee157b6b9 Functions that take a boolean argument now properly type-check for it.
--HG--
branch : minor
2017-08-14 22:56:20 -03:00
Alex Szpakowski ef5897b22c Seed love.math.random when the math module is loaded, instead of in love.run.
--HG--
branch : minor
2017-07-23 19:45:49 -03:00
Alex Szpakowski 34ebe18f14 Use luaL_check/optinteger instead of luaL_check/optnumber when getting integer arguments to functions. Resolves issue #1251.
--HG--
branch : minor
2017-07-16 12:17:50 -03:00
Tanner Rogalsky 9084dce58f Add bindings for setting and getting a Transform's matrix representation.
--HG--
branch : minor
2017-06-20 08:06:28 -04:00
Alex Szpakowski ac697ddb0f Clean up love’s internal Vector code a bit, and rename it to Vector2 so it’s more obvious what it is.
--HG--
branch : minor
2017-05-16 22:07:01 -03:00
Alex Szpakowski 70b32c47ce Error if a non-2D/affine matrix is used with auto-batched draws, since they perform CPU-side matrix transforms on 2-component vectors.
--HG--
branch : minor
2017-04-23 00:12:57 -03:00
Alex Szpakowski f8c58c54c8 love.math.randomNormal can be JIT-compiled
--HG--
branch : minor
2017-04-01 21:19:19 -03:00
Raidho 8572a33880 Prettifyed the code exploiting inheritance rules
added missing comma, added missing `override`

--HG--
branch : minor
2017-02-10 18:36:47 +03:00
Raidho 6ea1ebde9c Data:clone ported to minor
minor tweaks

--HG--
branch : minor
2017-02-10 06:19:53 +03:00
Alex Szpakowski a6669a8bb2 Merge default into minor
--HG--
branch : minor
2017-01-21 12:06:35 -04:00
Mastificate 93a15ce983 added error handling for bezier curves and fixed infinite loop bugs 2017-01-13 19:28:09 -05:00
Alex Szpakowski abb72cb813 Happy new year! 🥂
--HG--
branch : minor
2017-01-02 01:28:29 -04:00
Bart van Strien 24a7a3d367 Merge minor into dynamiccore2
--HG--
branch : dynamiccore2
2016-11-26 22:19:12 +01:00
Alex Szpakowski 5d2b0a98e5 Add missing applyTransform and replaceTransform functions…
--HG--
branch : minor
2016-11-24 21:54:19 -04:00
Alex Szpakowski 14aa6965b3 Added Transform objects to love.math (resolves issue #1228).
- Added love.math.newTransform.
- Added love.graphics.applyTransform and love.graphics.replaceTransform.
- love.graphics.draw/print/printf, Text:add/addf, and SpriteBatch:add can accept a Transform argument.
- love.graphics.push can accept an optional Transform as a second argument, which will apply the Transform after pushing the matrix stack,
- Shader:send can accept Transform objects when sending to a mat4 uniform variable.

--HG--
branch : minor
2016-11-24 21:30:45 -04:00
Bart van Strien 9f6aa716fa Pass Type to luax_register_type by pointer instead of reference
Since the type is passed to va_start, and apparently that's undefined behaviour if it's a reference.

<Textmode> the best kind of behavior

--HG--
branch : dynamiccore2
2016-11-14 21:51:47 +01:00
Bart van Strien d967a755e5 Make love::Type handle type names
TODO: Fix undefined behaviour in luax_register_type, you can't use a va_list after a reference type

--HG--
branch : dynamiccore2
2016-11-14 21:06:53 +01:00
Bart van Strien 5d43c9601a Automatically deduce the type in luax_pushtype, if possible
--HG--
branch : dynamiccore2
2016-11-13 17:38:42 +01:00
Bart van Strien 7dd960619d Automatically deduce the type in luax_checktype, luax_getmodule, luax_optmodule and luax_totype
--HG--
branch : dynamiccore2
2016-11-13 17:13:40 +01:00
Bart van Strien c761202486 Build type information on first use (load-time), instead of using a hardcoded list
--HG--
branch : dynamiccore2
2016-11-13 16:38:57 +01:00
Alex Szpakowski a9593d926e Fix love.math.noise(nil) to error instead of returning nil. 2016-10-20 22:57:12 -03:00
Alex Szpakowski 0341fc1189 Reduce memory allocations for the SHA formats of love.math.hash.
--HG--
branch : minor
2016-10-22 21:31:48 -03:00
Alex Szpakowski b9c01b8674 Merge default into minor
--HG--
branch : minor
2016-10-21 22:04:39 -03:00
Alex Szpakowski 0653ec9564 Address some compiler warnings about implicit integer conversions.
--HG--
branch : minor
2016-10-18 22:32:35 -03:00
Alex Szpakowski 2bc036f4c9 Use love's sized int typedefs instead of C's.
--HG--
branch : minor
2016-10-06 23:01:44 -03:00
Alex Szpakowski 37520bd18b Added Object:release. Calling it is the equivalent of removing all Lua-side references to an object and doing a full garbage collection cycle (thus deleting the object from memory if nothing else in LÖVE's code is referencing it).
Any attempt to call a method on the object after it has been released will result in an error. Object:release() returns true if it was successful, or false if not (if it has already been released previously).

--HG--
branch : minor
2016-10-06 21:59:01 -03:00
Alex Szpakowski ef61573cd3 Merge default into minor
--HG--
branch : minor
2016-08-29 22:41:24 -03:00
Alex Szpakowski 677a8d60b8 Use love::Vector (8 bytes) instead of love::Vertex (20 bytes) for love.math.triangulate and love.math.isConvex. 2016-08-24 18:02:27 -03:00
Alex Szpakowski 8b920ba816 Improved the numeric distribution of love.math.random.
--HG--
branch : minor
2016-05-15 10:25:08 -03:00
Bart van Strien 0aaaf6b6f0 Make hash constants static, and out-of-line hopefully fixes compilation errors with vc++.
--HG--
branch : minor
2016-04-02 19:01:38 +02:00
Bart van Strien 3a2e859acd Add love.math.hash, which supports MD5/SHA-1/SHA-2.
--HG--
branch : minor
2016-04-02 18:39:53 +02:00
Alex Szpakowski cc1b9bc619 Moved most love.math functions out of the Math class, since they're pure functions.
--HG--
branch : minor
2016-03-28 19:46:29 -03:00
Alex Szpakowski 734789eb93 Added love.math.encode(format, data | string [, linelength]) and love.math.decode(format, data | string). Current formats are "base64" and "hex". The optional line length only applies to base64 and specifies the maximum number of characters per line in the encoded string.
Removed the variant of love.filesystem.newFileData which decoded a base64-encoded string since it's redundant.

--HG--
branch : minor
2016-03-28 19:28:40 -03:00
Alex Szpakowski ed933847f8 Color values in love's APIs are now in the range of [0, 1] rather than [0, 255].
--HG--
branch : minor
2016-01-31 10:49:29 -04:00
Alex Szpakowski 314a82b126 Fixed the piecewise function in linearToGamma to use <= instead of < when determining whether to use the linear part of the function. 2016-01-13 21:23:56 -04:00
Alex Szpakowski a9e10dcadf Fixed RandomGenerator.random crashing if a nil 'self' is passed. (closes issue #1116)
It still doesn't generate a proper error message if a non-RandomGenerator 'self' is used, however.
2016-01-02 21:15:39 -04:00
Alex Szpakowski 46a2e7b85c Happy new year! 🎉 2016-01-01 00:05:06 -04:00
Alex Szpakowski 20fb7f44df Cleaned up the code for love.math.random and related functions. 2015-12-10 13:09:54 -04:00
Alex Szpakowski 52b1bd78f2 Implemented LuaJIT FFI versions of love.math.random and RandomGenerator:random. 2015-12-10 12:45:53 -04:00
Alex Szpakowski a1dab12117 Fixed a bug in love.math.gammaToLinear/linearToGamma when a table with an alpha channel is passed in as an argument. 2015-12-08 21:43:32 -04:00
Alex Szpakowski 374d1ae0e1 Implemented LuaJIT FFI versions of love.math.noise, love.math.gammaToLinear, and love.math.linearToGamma.
The new versions of the functions are only used if LuaJIT's JIT compiler is enabled.

Those functions are often combined with ImageData:mapPixel or ImageData:setPixel, which also have LuaJIT FFI versions in 0.10.0 - so without JIT-able implementations of the math functions, the FFI code in the ImageData methods would not be JIT-compiled and would end up taking up to 10 times as long to execute compared to the non-FFI versions in 0.9.2.
2015-12-08 21:24:16 -04:00
Alex Szpakowski 004ffb8819 Fixed the build. 2015-12-07 23:14:27 -04:00
Alex Szpakowski e0dca60380 Cleaned up some code. 2015-12-07 23:01:52 -04:00
Alex Szpakowski 2c4e713114 Imported some of the dynamiccore branch from love-experiments:
- Type names for love's Lua objects are specified as an argument to luax_register_type, rather than being statically defined in an array.

- luax_register_type takes a variable number of method array arguments, for registering superclass methods without copying them into the subclass' method array.

Also removed most of the header declarations for wrapper functions.
2015-11-29 20:38:12 -04:00
Alex Szpakowski c03ce3a9ab love.math.random now uses a slight variant of Xorshift (Xorshift*). 2015-10-26 20:47:56 -03:00
Alex Szpakowski d587c206f0 Added a new variant love.math.decompress(data, format), where data is any Data object. 2015-10-03 01:49:12 -03:00
Alex Szpakowski 2e9154283c Added gzip support to love.math.compress and love.math.decompress. 2015-10-02 03:18:11 -03:00