Commit Graph

261 Commits

Author SHA1 Message Date
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
Alex Szpakowski 247e1b6af0 Merge default into minor
--HG--
branch : minor
2016-11-19 19:19:14 -04: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
Xpol Wan c28a6c51c4 love.arg.parse_option just return how many extra arg the current option consumes.
--HG--
branch : better-parse-options
2016-11-04 22:27:49 +08:00
xpol de855f30d5 Better love.arg.parse_options():
1. use string.match for we are mean to match
2. better match pattern which now do not allow somthing like `not-a-valid--console`
3. use while loop which allows change loop var.

--HG--
branch : better-parse-options
2016-11-04 11:37:38 +08: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 54efa825c3 Merge default into minor
--HG--
branch : minor
2016-09-11 13:09:01 -03:00
Alex Szpakowski e803878445 love.event.quit("restart") now causes LÖVE to restart the Lua state after shutting it down.
Note that this isn't perfect – it won't kill running threads which aren't cleaned up by the Lua code when the main Lua state is shut down.
2016-09-08 18:42:56 -03:00
Alex Szpakowski 8fca2aa607 Call collectgarbage after love.lowmemory(), instead of before. 2016-09-08 18:11:50 -03:00
Alex Szpakowski baebb45c2e Updated the love.conf default for vsync.
--HG--
branch : minor
2016-08-29 22:53:14 -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 8566729229 Merged in Bobbyjones/love/new-conf-flag-for-android-2 (pull request #53)
New conf flag for android 2
2016-01-10 20:11:34 -04:00
BobbyJones 57467448ad Made the android set save functions private.
--HG--
branch : new-conf-flag-for-android-2
2016-01-09 10:35:20 -05:00
Alex Szpakowski a590cf17aa The default error handler resets the mouse cursor now. 2016-01-05 18:45:20 -04:00
BobbyJones 9dc50fe423 switched c.useexternalstorage to c.externalstorage
--HG--
branch : new-conf-flag-for-android-2
2016-01-02 19:16:20 -05:00
BobbyJones e3da734ace clean up 2016-01-02 18:56:23 -05:00
BobbyJones 3aa51763e2 made a method for setting external save location on android 2016-01-02 18:52:25 -05:00
Alex Szpakowski 46a2e7b85c Happy new year! 🎉 2016-01-01 00:05:06 -04:00
BobbyJones 3c83fb8626 Added a flag that changes android storage from internal to external. 2015-12-31 01:28:00 -05:00
Alex Szpakowski 925eebdaf0 Removed love.event.addListener/removeListener/clearListeners.
They take away too much control from the main game code, which makes it harder to implement things like gamestates without modifying library code.
2015-12-12 17:54:54 -04:00
Alex Szpakowski e5c0c49751 Added love.event.clearListeners. 2015-12-12 14:19:37 -04:00
Alex Szpakowski 44d4ce2c99 Show the error screen instead of just exiting after printing the error, if there's a syntax error in conf.lua (thanks Shoozza!) 2015-12-12 14:13:04 -04:00
Bart van Strien 22f2175bec Add initial video playback support for Ogg Theora videos (resolves issue #66.)
The basic APIs are:

video = love.graphics.newVideo("myvideo.ogv")

love.graphics.draw(video, ...) -- Video objects are Drawables.

video:play(), video:pause()

video:getDuration(), video:tell(), video:rewind(), video:seek(seconds)

video:getSource()

video:getWidth(), video:getHeight(), video:setFilter(min, mag)

More advanced APIs include video:setSource(source), video:getStream(), and videostream:setSync.

To use a custom pixel shader when drawing a Video, call the new TexelVideo(texcoords) function instead of Texel(texture, texcoords) in order to get the pixel colors of a video frame.
2015-12-08 22:41:19 -04:00
Alex Szpakowski 99debab3a4 Updated the readme: Xcode 7 lets you build iOS apps for your device without a registered developer account. 2015-09-14 18:50:48 -03:00
Alex Szpakowski e979455772 love.event.quit now accepts a single (optional) argument, which is used as the program's exit status number. Resolves issue #1070. 2015-08-25 17:12:59 -03:00
Alex Szpakowski 71116807e3 Fixed the default error handler to disable relative mouse mode. 2015-08-18 22:13:06 -03:00
Alex Szpakowski d215d8a91e Reworked sRGB / gamma-correct APIs:
Gamma-correct blending and shader math can be enabled globally via the new 't.gammacorrect' boolean flag in love.conf.
The new function love.graphics.isGammaCorrect will return true if it was requested in love.conf and is supported on the system.

When gamma correct rendering is enabled, colors (including the colors of pixels from images) are automatically converted from sRGB to linear RGB before use. When drawing to the main screen or to a canvas with the 'normal' or 'srgb' format, the final output colors of pixel shaders are automatically converted from linear RGB to sRGB after blending and before the color is stored in the pixel.

This lets the rendering pipeline do math using linear RGB values for colors rather than sRGB values, so the math is correct, without making users of the APIs manually linearize their colors with the love.math.gammaToLinear function (which still exists). The final output of the screen is encoded as sRGB, which is what systems expect. Canvases (except when otherwise requested) store their contents with sRGB encoding for increased precision with darker colors.

the 'srgb' window setting flag has been removed, as well as the 'srgb' image flag. A new image flag 'linear' has been added, which when set to true will cause the colors of the image to always be treated as linear RGB rather than sRGB, when gamma-correct rendering is enabled.

A new function 'Shader:sendColor' has been added, which has the same argument structure as 'Shader:send' but expects colors in the range of [0, 255]. When gamma-correct rendering is enabled it automatically gamma-corrects the given colors (by applying gammaToLinear to them.)

New shader code functions have been added: gammaToLinear, linearToGamma, gammaCorrectColor, and unGammaCorrectColor. When gamma-correct rendering is enabled, the LOVE_GAMMA_CORRECT #define is set and gammaCorrectColor and unGammaCorrectColor are aliases for gammaToLinear and linearToGamma respectively, otherwise the functions do nothing.

The new shader functions have 'precise' and 'fast' variants. If the LOVE_PRECISE_GAMMA define is set, then the normal functions default to the precise variants, otherwise they default to the fast variants. Currently the define is set in vertex shaders and not set in pixel shaders.

The default per-vertex color is automatically gamma-corrected by LÖVE when gamma correct rendering is enabled, but any custom named per-vertex attribute specified with the new custom attribute Mesh functionality won't be, unless 'gammaCorrectColor' or similar functions are explicitly used (preferably inside the vertex shader code that has the custom attribute.)
2015-08-09 21:46:21 -03:00
Bart van Strien 4748132853 Show indicated version in incompatibility message (resolves issue #1066)
Also fixed a typo in the message
2015-08-05 14:36:07 +02:00
Alex Szpakowski 6bce7c7cd0 Fixed love.errhand. 2015-07-30 20:33:38 -03:00
Alex Szpakowski 8656797c5c Added a message box popup asking to quit the game to the default error handler, activated when the mouse is pressed or the screen is tapped. This is mostly useful on mobile devices where users can't press 'escape'. 2015-07-02 23:15:37 -03:00
Alex Szpakowski c3612acfde Fixed the use of getRealDirectory when auto-detecting the identity name. 2015-06-25 10:00:54 -03:00
Bart van Strien 29da6b3c26 Attempt to make identity autodetection even more robust using getRealDirectory 2015-06-25 11:36:49 +02:00
Alex Szpakowski 3053278048 Moved the no-game screen code to its own file. 2015-06-09 22:38: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 811b2db466 The full executable path, rather than argv[0], is now used when determining whether the executable is fused (resolves issue #1043.) 2015-05-04 10:38:28 -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 4a8e5bd4db Avoid non-ASCII UTF-8 in message box text - SDL's X11 backend for message boxes doesn't properly support it yet (https://bugzilla.libsdl.org/show_bug.cgi?id=1658). 2015-03-17 11:54:52 -03:00
Alex Szpakowski 5bc5a2b780 Show the compatibility warning message box before creating the window and loading main.lua, so it will still display even if there are errors in main.lua.
Also snprintf is only supported in VS2015...
2015-03-15 12:34:40 -03:00
Alex Szpakowski 44b9efb43e Added love.isVersionCompatible. Returns true if the running version of love is compatible with the specified version. 2015-03-13 19:26:09 -03:00
Alex Szpakowski afcad4defc Added new flag t.accelerometerjoystick to love.conf (true by default.) When set to false on mobile, the device's accelerometer will not show up as a joystick even if the joystick module is loaded.
This can reduce CPU usage if you don't use the accelerometer but you don't want to disable the joystick module entirely.
2015-03-07 15:36:53 -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 b9c90e8a6f Fixed the background color for the error screen, and updated LodePNG to the latest version.
--HG--
branch : minor
2015-02-27 21:20:31 -04:00
Alex Szpakowski 3efcf3901b Removed Canvas:clear. love.graphics.clear now accepts r,g,b,a values (and defaults to 0,0,0,0 with no arguments given.) love.graphics.clear clears the content of the currently active Canvas(es.)
--HG--
branch : minor
2015-02-27 03:47:25 -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 bf8f6f8b02 Changed the default fullscreen type from 'exclusive' to 'desktop'.
--HG--
branch : minor
2015-02-21 17:27:54 -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 71c9943bd0 Fixed the keypressed and keyreleased handler functions.
--HG--
branch : minor
2015-02-16 17:16:47 -04:00