Commit Graph

68 Commits

Author SHA1 Message Date
Bart van Strien e80247c191 Happy new year! 2018-01-03 19:47:35 +01:00
Alex Szpakowski 6dea2ab714 Clamp all color arguments to [0, 1] in cases where values outside that range don't make sense (fixed-point color values & sRGB colors). Closes issue #1315.
--HG--
branch : minor
2017-11-21 19:49:52 -04:00
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 84d5d8b636 Move decoder-agnostic love.image code out of the magpie backend folder.
--HG--
branch : minor
2017-08-01 23:22:24 -03:00
Alex Szpakowski 5ef6730497 Added a variant of love.graphics.captureScreenshot which takes a single filename parameter. Resolves issue #1293.
--HG--
branch : minor
2017-07-29 12:54:53 -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
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 abb72cb813 Happy new year! 🥂
--HG--
branch : minor
2017-01-02 01:28:29 -04:00
Bart van Strien 7bd3581a52 Merge dynamiccore2 into minor
Instead of a global type enum and bitfield, all types now have their own
love::Type static member. This means they automatically assign their ids, build
their bitsets, etc. As a bonus, it simplifies wrapper code since most functions
already know which type they're pushing to or getting from lua, so they can
directly get the static member (if it's called 'type').

--HG--
branch : minor
2016-11-30 22:38:30 +01:00
Alex Szpakowski 0a3adc0839 Unify pixel format enums for ImageData, CompressedImageData, and Canvas into a single PixelFormat enum.
Replace love.graphics.getRawImageFormats and love.graphics.getCompressedImageFormats with love.graphics.getImageFormats.

--HG--
branch : minor
2016-11-27 22:53:23 -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 e71f95595c ImageData (and Images loaded from them) now support different data formats. Resolves issue #1048.
Currently exposed formats are rgba8 and rgba16 (normalized), and rgba16f and rgba32f (floating-point). Some systems, especially mobile ones, won't support every format when creating a love.graphics Image. Use love.graphics.getRawImageFormats to check for support.

love.image.newImageData now takes an optional format parameter as its third argument when creating an empty sized ImageData. It defaults to rgba8.

16-bit PNGs, .hdr images, and floating-point OpenEXR images can now be loaded via love.image.newImageData and love.graphics.newImage.

--HG--
branch : minor
2016-05-22 15:28:20 -03:00
Alex Szpakowski 3e6d01748e Merged default into minor
--HG--
branch : minor
2016-05-22 15:11:15 -03:00
Alex Szpakowski 9900051647 Improved performance of ImageData:mapPixel when JIT compilation is unavailable (e.g. on iOS and Android) 2016-05-21 22:18:12 +00:00
Alex Szpakowski 4666d83beb Fixed ImageData:mapPixel again, for non-JIT platforms this time.
--HG--
branch : minor
2016-05-21 15:24:11 -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 46a2e7b85c Happy new year! 🎉 2016-01-01 00:05:06 -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 2168d509b3 Reworked ImageData:encode:
- It now returns a FileData containing the encoded ImageData.

- The first argument is now the format to encode to.

- The second argument is now the filename to write to, and is optional. No file will be written if a filename is not given.
2015-07-04 22:30:09 -03:00
Bart van Strien 3cb777e2b7 Add basic lua 5.3 support 2015-06-16 10:25:41 +02:00
Alex Szpakowski df1bd42dec Implemented efficient FFI versions of ImageData methods.
Note that ImageData:mapPixel (with its optional sub-rectangle parameters) is often many times faster than a loop of ImageData:setPixel and/or getPixel, for anything more than a few pixels.
2015-06-15 00:50:01 -03:00
Alex Szpakowski aac595525a Cleaned up some ImageData code. 2015-06-14 01:01:44 -03:00
Alex Szpakowski 2f419c1c83 Replaced most cases of type bits and type name strings in love's Lua wrapper code with type id's.
--HG--
branch : minor
2015-03-01 18:32:41 -04:00
Alex Szpakowski c7b45b3505 Updated copyright for the new year 2014-12-31 19:32:43 -04:00
Alex Szpakowski dfa319e01a Replaced the EXCEPT_GUARD macro for converting love exceptions into Lua errors with the new luax_catchexcept function, which takes lambda function arguments. 2014-06-03 19:27:00 -03:00
Alex Szpakowski 3120a0e650 Goodbye 2013, hello 2014! 2014-01-03 17:28:58 -04:00
Alex Szpakowski e068aab6ea The function passed to ImageData:mapPixel must return at least r,g,b. Alpha component defaults to 255 (resolves issue #603) 2013-10-12 00:40:18 -03:00
Alex Szpakowski 06f80d5c08 Fixed undefined behaviour when love exceptions are converted into Lua errors (resolves issue #729) 2013-09-05 23:17:29 -03:00
Alex Szpakowski c15fc4453b Re-added Data:getPointer (can be used with LuaJIT's FFI) 2013-08-29 17:16:21 -03:00
Alex Szpakowski bcc85f884e ImageData:mapPixel can now take optional x,y,w,h parameters to constrain it to a rectangle in the ImageData 2013-07-11 01:10:19 -03:00
Alex Szpakowski b04a2fee87 Improved performance when using ImageData methods in multiple threads when ImageData:encode is called 2013-06-26 03:42:42 -03:00
Alex Szpakowski b8efa6372b oops 2013-06-25 05:37:44 -03:00
Alex Szpakowski 6e3a7288dd Improved performance of ImageData:mapPixel (now up to 2x as fast as in 0.8.0!); love.graphics.newImage, Image:refresh, love.window.setIcon, and ImageRasterizers now prevent other threads from modifying the ImageData used in those functions until they're done accessing it 2013-06-25 05:28:20 -03:00
Bart van Strien 402ae4638a Make ImageData:setPixel accept a table (issue #582) 2013-05-10 17:28:55 +02:00
Alex Szpakowski 3bf43dadd8 Renamed CompressedData:getNumMipmaps to CompressedData:getMipmapCount; Improved type-checking error messages for some functions which expect function arguments 2013-05-02 17:26:50 -04:00
Alex Szpakowski fb9f8d2962 Added the getString method to all Data objects (issue #608) 2013-04-26 22:35:01 -07:00
Alex Szpakowski 16f3a93f28 Removed vestigial internal code for Data:getPointer 2013-04-26 22:05:58 -07:00
Alex Szpakowski e9ff803c42 alpha values for ImageData:mapPixel default to 255 (issue #603) 2013-04-19 14:20:11 -03:00
Alex Szpakowski 7403245715 Cosmetic code improvements
--HG--
branch : image-CompressedData
2013-04-07 22:58:08 -03:00
Alex Szpakowski d5aa807747 More internal code cleanup 2013-03-31 19:02:27 -03:00
darthfodder 275a144907 Remove commented out line 2013-03-25 20:43:51 -07:00
darthfodder 69ccf4aaa1 Set default alpha value on ImageData:setPixel to 255. resolves #575
--HG--
branch : imagedata-alpha-default
2013-03-25 11:42:19 -07:00
Alex Szpakowski 17bcab4f32 Added love.graphics.getDimensions and Image/Canvas/ImageData:getDimensions (issue #566) 2013-03-11 19:03:37 -03:00
Alex Szpakowski 96161c66f6 Updated copyright text for the new year 2013-02-05 05:32:49 -04:00