Commit Graph

366 Commits

Author SHA1 Message Date
Alex Szpakowski 0d2e08baff Implement automatic batching for points, lines, shapes, and images/quads.
The above are batched together into a single draw call when called without other drawing calls in between, as long as the following criteria are met:

- The texture is the same.
- The primitive type is the same (points cannot be batched with non-points).
- The love.graphics state is the same (aside from the current color - i.e. setColor - and the transform state).
- The active shader’s uniform values are the same.

You can examine the ‘drawcalls’ field of love.graphics.getStats() to help determine if your code is allowing for optimum batching.

--HG--
branch : minor
2016-12-27 21:02:58 -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
Alex Szpakowski c647317a74 Re-generated boot.lua.h. 2016-11-05 17:33:32 -03: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 e9ac008f43 Merge default into minor
--HG--
branch : minor
2016-08-13 12:41:14 -03:00
Bart van Strien f4999bd2c7 Fail gracefully when auto.lua is called on a file not in src/scripts 2016-07-28 17:15:52 +02: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 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 c283e36126 made a new boot.lua.h 2015-12-31 02:16:36 -05:00
BobbyJones 3c83fb8626 Added a flag that changes android storage from internal to external. 2015-12-31 01:28:00 -05:00
Alex Szpakowski 5ef0195a88 Fixed an error in the nogame screen if the window's height is too small. 2015-12-22 15:47:50 -05:00
Alex Szpakowski ed0ec611b9 Pressing escape now exits the nogame screen. 2015-12-14 11:54:09 -04: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
Alex Szpakowski 532943649b Slightly tweaked the no-game screen. 2015-12-11 22:33:51 -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 75faf77d66 Improved the performance of Shader:send when matrices are used. 2015-11-24 14:25:52 -04:00
rude 2990b6d440 Add some mosaic patterns which appear sometimes. 2015-11-18 17:12:54 +01:00
Alex Szpakowski e9c75c342e Text:add and Text:addf now return index numbers which can be used as arguments to Text:getWidth and text:getHeight to determine the (pre-transformed) width and height of specific text within the Text object. 2015-11-14 18:51:43 -04:00
Alex Szpakowski b2b14eb2d6 Simplified some of the high-dpi scaling code for the no-game screen. 2015-11-11 19:57:09 -04:00
Alex Szpakowski 7043b5314d Added high-dpi / retina support to the no-game screen; additional minor tweaks and cleanup. 2015-11-11 19:35:45 -04:00
rude 3cd18bae20 Tweak colors in no-game screen. 2015-11-11 18:23:13 +01:00
rude 7a260af39f Add 0.10.0 (Super Toast) no-game screen.
This commit adds a version codename and accompanying no-game screen. It should
cause at least a few seizures, if we're lucky. (Press 'F' for fullscreen).

Colors could use some tweaks, probably ... and it would be cool if various
hypnotizing patterns appeared intermittedly in the mosiac ... but that's for
the next commit. (Only two years until next time)!
2015-11-10 23:17:48 +01: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 42ae9c9585 Moved the love.graphics Lua code into the graphics module folder. 2015-06-18 14:27:45 -03:00
Alex Szpakowski 3053278048 Moved the no-game screen code to its own file. 2015-06-09 22:38:36 -03:00