Commit Graph

101 Commits

Author SHA1 Message Date
Sasha Szpakowski c823dbca96 Update copyright year for 2023 2022-12-31 22:25:49 -04:00
Miku AuahDark 3c2b1b888e Properly pause all audio processing in Android when minimized.
This uses ALC_SOFT_pause_device extension which is available since
OpenAL-soft 1.16. We guarantee almost 100% availability of this extension
since we've been using OpenAL-soft in Android since beginning.

Fixes #1828
2022-08-26 11:45:25 +08:00
Alex Szpakowski 8e7fd10b6f Update copyright year for 2022 2021-12-31 18:33:40 -04:00
Miku AuahDark 216d5ca4b2 Fix love.displayrotated passes boolean instead of string
Fixes #1722
2021-08-21 14:31:44 +08:00
Alex Szpakowski f89aabb0bb Update copyright year for 2021 2021-04-04 16:14:45 -03:00
Alex Szpakowski fc4847c69d Update copyright for the new year 2020-01-03 22:40:36 -04:00
Alex Szpakowski 0752f27bdf Update copyright year for 2019 2019-01-03 21:09:05 -04:00
Alex Szpakowski d4762b4612 Add love.window.getDisplayOrientation and a love.displayrotated callback. Resolves issue #1441.
Note that this tracks screen orientation, rather than device orientation.
2018-12-17 16:19:56 -04:00
Alex Szpakowski c798cce89d Improve the error message given when love.event pumping functions are called with a Canvas active. 2018-01-14 19:25:38 -04:00
Bart van Strien e80247c191 Happy new year! 2018-01-03 19:47:35 +01:00
Alex Szpakowski b838d0de54 Simplified an internal Variant constructor to be more intuitive to use.
--HG--
branch : minor
2017-09-30 10:39:24 -03:00
Alex Szpakowski abb72cb813 Happy new year! 🥂
--HG--
branch : minor
2017-01-02 01:28:29 -04:00
Alex Szpakowski d26002f5cc Revamped and streamlined retina / high-DPI support (resolves issue #1122).
With the highdpi window flag enabled on a retina-capable display and OS, content should now appear to the user at the same size and in the same positions as with the flag disabled.

As a result, mouse and touch coordinates, Texture and graphics dimensions, and the graphics coordinate system now use pixel density-scaled units instead of pixels. Raw pixel units should generally only be used for things such as shader algorithms which execute per-pixel and rely on accurate pixel dimensions. love.window.fromPixels and friends typically don’t need to be used anymore.

Images, Canvases, and Fonts can have an optional explicit ‘pixel density’ set when creating them. This allows for easily loading high pixel density content which displays at the same size as regular or low pixel density content.

API changes:

- Added Texture:getPixelWidth/getPixelHeight/getPixelDimensions and Texture:getPixelDensity. Texture:getWidth/getHeight return the pixel density-scaled width and height (as it will appear on the screen when drawn) rather than the number of pixels on each texture dimension.

- Added love.graphics.getPixelWidth/getPixelHeight/getPixelDimensions.

- Added optional ‘pixeldensity’ field to the settings table parameter of love.graphics.newImage. It defaults to 1, or if the file the Image was loaded from has “@2x”, “@3x”, etc. at the end of its name, it uses that number as the pixel density scale by default.

- love.graphics.newCanvas now takes a table as its third parameter, with fields “format”, “msaa”, and “pixeldensity”. pixeldensity defaults to the main screen’s pixel density. The width and height parameters specify the visual size that the Canvas will be drawn at / can be drawn to (pixel density-scaled units).

- love.graphics.newVideo accepts a table as its second parameter, with optional fields “audio” and “pixeldensity”. pixeldensity defaults to 1.

- love.graphics.newFont variants have an optional pixeldensity parameter at the end of the argument list. For TrueType fonts this defaults to the current pixel density scale of the screen, and for BMFonts and ImageFonts this defaults to 1.

- Added Font:getPixelDensity.

- Renamed love.window.getPixelScale to love.window.getPixelDensity.

--HG--
branch : minor
2016-12-29 23:55:51 -04:00
Alex Szpakowski 2a47a8c9e2 Revert most render pass API changes. The APIs need more work and iteration before they’re better to use than the old setCanvas APIs.
love.graphics.captureScreenshot has not been reverted.

--HG--
branch : minor
2016-12-11 16:33:05 -04:00
Bart van Strien cac5a3519a Fix automatically pausing and resuming audio on android (resolves #1237)
--HG--
branch : minor
2016-12-02 13:59:21 +01:00
Bart van Strien 24a7a3d367 Merge minor into dynamiccore2
--HG--
branch : dynamiccore2
2016-11-26 22:19:12 +01:00
Alex Szpakowski 3e80ec2257 Render pass API. Replaces love.graphics.setCanvas and friends.
- Removed love.graphics.set/getCanvas, Canvas:renderTo, Canvas:newImageData, love.graphics.clear, love.graphics.discard, and love.graphics.newScreenshot.

- Added love.graphics.beginPass and love.graphics.endPass. All rendering must happen within a pass. love.draw is now called while a render pass to the main screen is active.
- Added love.graphics.renderPass, which is a wrapper for begin/endPass which calls the supplied function argument in between a begin/end. This is similar to the old Canvas:renderTo.
- Added love.graphics.isPassActive, getPassCanvases, getPassWidth, getPassHeight, and getPassDimensions.
- Added love.graphics.captureScreenshot.

- Added a new love.run callback love.drawpasses, which is called after love.update and before love.draw. It is the place to render to Canvases using beginPass or renderPass, since love.draw now always draws to the main screen.

- Renamed the ‘canvasswitches’ field in the table returned by love.graphics.getStats to ‘renderpasses’.

love.graphics.beginPass has the following variants (and renderPass mirrors them with an additional function argument at the end):

- love.graphics.beginPass(), begins rendering to the main screen without clearing it.
- love.graphics.beginPass(r, g, b [, a]), begins rendering to the main screen and clears the screen to the specified color.

- love.graphics.beginPass(canvas [, willstencil]), begins rendering to the specified Canvas without clearing it. love.graphics.stencil can only be used within the Canvas if ‘willstencil’ is true.
- love.graphics.beginPass(canvas, r, g, b [, a] [, willstencil]), beings rendering to the specified Canvas and clears it to the specified color. love.graphics.stencil can only be used within the Canvas if ‘willstencil’ is true.

- love.graphics.beginPass(info), where ‘info’ is a table in the following form:
{
    {canvas [, r, g, b, a]}, — A canvas and an optional color to clear the Canvas to when the pass begins.
    {canvas2, [r, g, b, a]}, — Additional Canvases and optional clear colors for multi-canvas rendering.
    …,
    stencil = false, — Optional boolean field to specify whether love.graphics.stencil is allowed within this pass. False by default.
}

The pass info table can be created once up-front and used for multiple beginPass/renderPass calls.

love.graphics.endPass can take an optional callback function argument, which causes endPass to capture the contents of the Canvas drawn to in the render pass to a new ImageData and passes it to the supplied function (this replaces Canvas:newImageData). This does not work on the main screen.

love.graphics.captureScreenshot replaces love.graphics.newScreenshot. It takes a callback function argument which causes love.graphics.present to capture the contents of the screen to a new ImageData and passes it to the supplied function. captureScreenshot can only be called before drawing to the main screen begins in the current frame (e.g. in love.keypressed, love.update, etc.)

--HG--
branch : minor
2016-11-19 19:13:26 -04: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 aba4386807 SDL click count functionality was added in 2.0.2, not 2.0.4. So we can get rid of some useless code since we require 2.0.2+ in love 0.11...
--HG--
branch : minor
2016-09-27 22:53:48 -03:00
Alex Szpakowski b38e567e74 Added a click count argument to love.mousepressed/released. Tracks double/triple/etc. clicks.
--HG--
branch : minor
2016-09-27 22:46:55 -03:00
Alex Szpakowski 23fcaec89f The Variant class is now meant to be used on the stack instead of allocated on the heap. As a result (and because of related changes), performance of Channels has roughly doubled when pushing and popping most types. 2016-02-14 16:39:32 -04:00
Alex Szpakowski c2de8dbb6a Fixed audio on android to properly pause when the app is inactive, and resume when the app becomes active again. 2016-01-31 18:41:24 -04:00
Alex Szpakowski 46a2e7b85c Happy new year! 🎉 2016-01-01 00:05:06 -04:00
Alex Szpakowski 7ebef76b24 Added love.window.setScreenSaverEnabled and love.window.isScreenSaverEnabled (resolves issue #1088.) 2015-11-24 22:16:40 -04:00
Martin Felis 637a3a9d62 Pause OpenAL when the app is in the background, on Android. 2015-08-13 19:46:11 -03:00
Alex Szpakowski 66942d5f31 Added the ability to use custom mipmaps in Images, via love.graphics.newImage(filename, {mipmap1, mipmap2, ...}). Resolves issue #1064.
All mipmap levels must be present if custom mipmaps are used (and their sizes must be half the size of the previous mipmap level, rounded down.)

Image:getData now returns all custom mipmaps in an Image.
2015-07-30 20:48:36 -03:00
Alex Szpakowski 48a0910907 Renamed love.textedit to love.textedited. (text composition event callback) 2015-05-29 23:33:01 -03:00
Alex Szpakowski cffa899e03 Explicitly mention SDL in the error message caused by SDL subsystem initialization failure. 2015-03-26 14:51:47 -03:00
Alex Szpakowski 86d41620dd Replaced the mouse button constants ("l", "r", "m", etc.) with button numbers. 1 is the primary button, 2 is the secondary button, 3 is middle-mouse, etc. Resolves issue #1019. 2015-03-25 00:31:16 -03:00
Alex Szpakowski 78dd8bc547 Added love.touch.getPressure(touchid). Not useful on most touch-capable devices, but I do expect Apple's Force Touch to make it into iPhones in the near future. 2015-03-24 20:45:21 -03:00
Alex Szpakowski 14cbc91e7f Fixed a memory leak in love.graphics.newText. 2015-03-16 03:13:10 -03:00
Alex Szpakowski b76b7bac8b Added support for a few more mouse buttons (via "x3", "x4", and "x5" button constants.) 2015-03-07 23:28:58 -04:00
Alex Szpakowski 7e99ea6839 Added a boolean argument to love.mousemoved indicating whether the event came from a touch press (love.mousepressed and love.mousereleased already have it.) 2015-03-07 00:41:18 -04:00
Alex Szpakowski 9869999fda Added a missing key constant.
--HG--
branch : minor
2015-03-02 00:52:07 -04: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 95f87ed886 Added love.lowmemory event callback function, called when the app is close to running out of memory on iOS and Android.
--HG--
branch : minor
2015-02-26 00:45:48 -04:00
Alex Szpakowski 52c4f2c119 Improved the performance of love.window.getPixelScale / toPixels / fromPixels by caching some values. Made some coordinate space-sensitive code use the proper conversions to get to the correct coordinate space.
--HG--
branch : minor
2015-02-23 17:55:30 -04:00
Alex Szpakowski 33d20620b5 The Proxy struct now stores an actual love::Object pointer (rather than void*), which makes code using Proxies a bit cleaner.
--HG--
branch : minor
2015-02-21 20:52:29 -04:00
Alex Szpakowski e26e170f78 Enabled high-dpi code on Linux (even though SDL doesn't support it yet on Linux, as of 2.0.4.) SDL 2.0.1 or newer is now required on Linux.
I'd rather have high-dpi work on Linux without needing to rebuild love when it's eventually implemented in SDL, rather than preserve backwards-compatibility with SDL 2.0.0 on Linux (which isn't important for love 0.10.0.)

--HG--
branch : minor
2015-02-21 19:06:41 -04:00
Alex Szpakowski 5652475dd2 Use lightuserdata instead of Lua numbers (doubles) to represent touch IDs.
--HG--
branch : minor
2015-02-17 22:46:20 -04:00
Alex Szpakowski c02c8b154d Added a boolean argument to love.mousepressed and love.mousereleased indicating whether the button event originated from a touchscreen press
--HG--
branch : minor
2015-02-17 02:33:42 -04:00
Alex Szpakowski ac2b03e8a4 Added love.graphics.isActive. love.graphics function calls (and method calls on objects created via love.graphics) are only guaranteed to work when isActive is true, otherwise bad things might happen (the program crashing, for example.)
It's usually only false when the app is inactive on iOS, and when the window hasn't been created yet.

--HG--
branch : minor
2015-02-17 02:24:09 -04:00
Alex Szpakowski cafbf1ffbe Trigger love.quit when the SDL_APP_TERMINATING event occurs.
--HG--
branch : minor
2015-02-17 00:40:50 -04:00
Alex Szpakowski 2f1c89006e Slightly more robust hack to work around SDL's touch coordinate issues in Linux.
--HG--
branch : minor
2015-02-16 17:35:45 -04:00
Alex Szpakowski 5c1e6014cc Changed the love.keypressed and love.keyreleased event callbacks to be love.keypressed(key, scancode, isrepeat) and love.keyreleased(key, scancode). Added love.keyboard.isScancodeDown. Resolves issue #993.
--HG--
branch : minor
2015-02-16 17:10:03 -04:00
Alex Szpakowski 7f9abc1e77 Added love.touch module and touch screen events. Resolves issue #825.
Note: this implementation is slightly different from the implementation in the love 0.9.x Android and iOS ports!

Added love.touchpressed(id, x, y), love.touchmoved(id, x, y, dx, dy), and love.touchreleased(id, x, y, dx, dy).

id is a unique identifier for the touch press that persists until love.touchreleased. After that it is no longer unique.
x and y are the coordinates of the touch event in pixels within the window.
dx and dy are the amount in pixels that the touch has moved since the last event.

Added love.touch.getTouchCount and love.touch.getTouch(index).

love.touch.getTouch takes an index (not the same as an id. indices are not stable and don't correspond to a unique touch press.)
It returns the id of the touch and its current x and y coordinates in pixels.

--HG--
branch : minor
2015-02-16 16:29:45 -04:00
Alex Szpakowski c106d9ff53 love.event can now handle any number of event arguments.
--HG--
branch : minor
2015-02-15 21:31:22 -04:00
Alex Szpakowski a7e4148869 Merged default into minor
--HG--
branch : minor
2015-01-16 15:47:26 -04:00
Alex Szpakowski b4f2a9417a Added new event callback love.mousemoved(x, y, xrel, yrel), where xrel and yrel are the amount of pixels moved since the last event. Added love.mouse.setRelative(bool relative) and love.mouse.isRelative. Resolves issue #470.
Enabling relative mouse mode will hide the cursor and let the system generate relative mouse move events while preventing the mouse from getting stuck at the edges of the screen (i.e. you can keep moving the mouse in one direction forever and the relative movement events will be generated accordingly.)

The reported absolute mouse position is not updated while relative mode is enabled, even while relative movement events are generated.
2015-01-15 20:22:57 -04:00
Alex Szpakowski c7b45b3505 Updated copyright for the new year 2014-12-31 19:32:43 -04:00