Commit Graph

153 Commits

Author SHA1 Message Date
Alex Szpakowski 905e5baf06 Replace highdpi window flag with t.highdpi in love.conf 2020-11-01 21:36:15 -04:00
Alex Szpakowski 7934ce0a66 Handle backbuffer MSAA manually in love.graphics code
Previously love would use SDL APIs to make the system (WGL etc) handle it, which meant the OpenGL context had to be recreated whenever MSAA changed.
2020-10-25 22:24:07 -03:00
Alex Szpakowski 453322678c Rename internal uses of canvas to texture/render target 2020-02-08 20:40:10 -04:00
Alex Szpakowski 12c90b3dca Merge Image and Canvas GL backend classes into new common Texture class. 2020-02-07 20:29:21 -04:00
Alex Szpakowski 5f9b5a21d0 Merge default into minor
--HG--
branch : minor
2020-01-03 22:45:36 -04:00
Alex Szpakowski fc4847c69d Update copyright for the new year 2020-01-03 22:40:36 -04:00
Alex Szpakowski f3b52f66fe Update the internal naming convention for pixel formats.
--HG--
branch : minor
2019-12-23 23:38:04 -04:00
Alex Szpakowski bc12312f0f macOS: rename most internal uses of "macosx" to "macos".
--HG--
branch : minor
2019-12-22 17:54:20 -04:00
Alex Szpakowski 37c579929b Add support for GLSL 4.30 and GLSL ES 3.10, via #pragma language glsl4.
macOS and iOS won't support glsl4 until a Metal backend is implemented.

--HG--
branch : minor
2019-11-16 14:33:48 -04:00
Alex Szpakowski 37472d6f5e Add 'usedpiscale' boolean (true by default) to love.window.setMode's settings table and love.conf's t.window table. Add love.window.getNativeDPIScale.
When usedpiscale=false, love will no longer automatically scale coordinates by the screen's DPI scale factor (so all coordinates will be in pixels), even when highdpi=true. love.window.getDPIScale will return 1, love.graphics.newCanvas will default to a dpi scale of 1 instead of the screen's dpi scale, etc.

love.window.getNativeDPIScale() will return the screen's DPI scale as reported by the OS no matter what usedpiscale is set to.
2019-06-24 21:54:09 -03:00
Miku AuahDark 4a08c0f7c1 Implement love.window.getSafeArea for Android
--HG--
branch : android-safearea
2019-02-08 23:58:02 +08:00
Alex Szpakowski 0752f27bdf Update copyright year for 2019 2019-01-03 21:09:05 -04:00
Alex Szpakowski f504ace6cd Make sure love.window.getSafeArea is in DPI-scaled units on all platforms. 2018-12-26 10:36:41 -04:00
Alex Szpakowski d41aca836e Add love.window.getSafeArea (resolves issue #1437). Returns a rectangle (x, y, w, h) inside the window which is known to be unobstructed by a system title bar, the iPhone X notch, etc. Useful for making sure UI elements can be seen by the user.
Currently it only has a proper implementation on iOS and will return the window's full size otherwise.
2018-12-26 00:34:14 -04:00
Alex Szpakowski e2aa469170 Add love.window.get/setVSync, to allow changing the vsync setting without recreating the window. 2018-12-18 13:39:06 -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 bb228cab0c Fix love.event.quit causing crashes and other bad behaviour if a Canvas is active. Resolves issue #1395. 2018-04-07 12:43:00 -03:00
Bart van Strien e80247c191 Happy new year! 2018-01-03 19:47:35 +01:00
Alex Szpakowski b6cb6aed47 Error if the ImageData given to love.window.setIcon is not a 32 bit RGBA format.
--HG--
branch : minor
2017-11-26 18:31:43 -04:00
Alex Szpakowski 0b9ca3e344 Fix love.window.isMaximized. Add love.window.restore and love.window.isMinimized (resolves issue #1354).
--HG--
branch : minor
2017-11-20 22:20:39 -04:00
Alex Szpakowski 844900db39 Rename all cases of 'pixel density' to 'DPI scale' in love's APIs.
--HG--
branch : minor
2017-09-24 16:09:05 -03:00
Alex Szpakowski 518ed6f524 Small code style cleanup
--HG--
branch : minor
2017-07-21 21:17:55 -03:00
Alex Szpakowski 97789b18c0 Only use opengl debug groups if the LOVE_GRAPHICS_DEBUG environment variable is set to 1.
--HG--
branch : minor
2017-02-12 17:58:28 -04:00
Alex Szpakowski 731b5d5cf0 Added support for GLSL 3 shaders (GLSL 3.30 and GLSL ES 3.00).
To use GLSL 3 in a shader, the first line of the shader has to be: #pragma language glsl3

glsl1 is the default language.

Added “glsl3” graphics feature as part of the table returned by love.graphics.getSupported().

Added love.graphics.validateShader(boolean gles, shadercode). It returns a boolean along with an error string if the shader code has errors for its target language and platform (gles or desktop).

Implemented support for Core Profile OpenGL 3.3 in love.graphics.

--HG--
branch : minor
2017-01-22 18:54:04 -04:00
Alex Szpakowski 5243fb5a85 Allow disabling stencil capabilities for the main screen in love.window.setMode.
--HG--
branch : minor
2017-01-05 19:40:18 -04: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
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 60d90ca4a8 Merge default into minor
--HG--
branch : minor
2016-10-30 01:07:39 -03:00
Alex Szpakowski ec7565176e Add love.window.isMaximized 2016-10-24 21:35:22 -03:00
Alex Szpakowski b9c01b8674 Merge default into minor
--HG--
branch : minor
2016-10-21 22:04:39 -03:00
Alex Szpakowski 42be56858b Remove duplicate unused code. 2016-10-10 09:33:10 -03:00
Alex Szpakowski 03c38185f6 Fix love.window.maximize to immediately update the window dimensions instead of waiting for the next love.event.pump. Fixes issue #1221. 2016-10-10 09:14:57 -03:00
Alex Szpakowski 7eeca829e5 Fix a use of std::remove_if
--HG--
branch : minor
2016-09-12 08:11:38 -03:00
Alex Szpakowski 11328a23cf Don't consider different OpenGL versions when re-creating the window after a previous window and OpenGL context has been created. love.graphics has never supported switching GL versions mid-game, so we should prevent it from ever happening.
--HG--
branch : minor
2016-09-11 21:40:00 -03:00
Alex Szpakowski dd2a448099 The vsync field in t.window and love.window.setMode is now an integer.
0 disables vsync, 1 sets it to sync every screen refreshes, 2 sets it to sync every 2 screen refreshes (effectively setting the framerate to half the monitor's refresh rate), etc.

As a special case, -1 also attempts to use adaptive vsync (vsync enabled when FPS is >= monitor's refresh rate, disabled whe not) if the driver supports it.

--HG--
branch : minor
2016-08-29 22:52:15 -03:00
T-Bone b2291fb62a Fixes to make Löve compile on Windows 10 UWP 2016-04-07 22:56:03 +02:00
Alex Szpakowski 9ec6eceb8a Cleaned up the error message code when love.window.setMode fails. 2016-01-14 19:16:41 -04:00
Alex Szpakowski 46a2e7b85c Happy new year! 🎉 2016-01-01 00:05:06 -04:00
Alex Szpakowski efa08b1e44 Fixed a compile failure on Android (thanks xenthral!) 2015-12-19 22:21:50 -04:00
Alex Szpakowski f6809f941d Cleaned up some love.window code. 2015-12-17 23:15:06 -04:00
Alex Szpakowski 4e75c7be9a Improved the window and OpenGL context creation code to try more options if the OpenGL version is too low (e.g. if the driver in Windows gave back a Microsoft GL 1.1 software context because of a high requested MSAA value.) 2015-12-17 19:03:13 -04:00
Alex Szpakowski 0a059814e7 Revamped love.graphics.stencil and love.graphics.setStencilTest:
- Each canvas (and the screen) has an invisible stencil value associated with each pixel. Stencil values are between [0, 255].

- love.graphics.stencil takes a function argument which draws things, and makes the geometry of what's drawn set the stencil values of pixels instead of coloring the pixels.

- Its second argument is a 'stencil action' which determines what happens to the stencil values of pixels. The possible stencil actions are 'replace' (the default), 'invert', 'increment', 'decrement', 'incrementwrap', and 'decrementwrap'. If the stencil action is 'replace', the third argument of love.graphics.stencil is a number between [0, 255] which determines what the stencil value of each pixel that touches drawn objects is replaced with.

The fourth argument is a boolean which determines whether the previous stencil values of all pixels on-screen should be kept (true), or cleared to 0 (false, the default.) love.graphics.clear also clears the stencil values.

- love.graphics.setStencilTest allows for anything drawn to be affected by a comparison between the arguments to setStencilTest and the existing stencil value of the pixels that are touched by what's drawn. Its first argument is a compare mode which can be 'equal', 'notequal', 'less', 'lequal', 'gequal', or 'greater', and the second argument is an integer value (between 0 and 255) used in the comparison with the value in the stencil buffer.

For example, love.graphics.setStencilTest("greater", 0) will cause any geometry drawn afterwards to only appear on pixels whose stencil value is greater than 0.
2015-12-14 20:43:39 -04:00
Alex Szpakowski 7b8af113da Fixed the minimum window size to re-set itself when love.window.setFullscreen(false) is called. 2015-12-13 20:50:35 -04:00
Alex Szpakowski b0c19ef2c5 Renamed love.window.set/isScreenSaverEnabled to love.window.set/isDisplaySleepEnabled. 2015-11-24 22:35:57 -04:00
Alex Szpakowski 7ebef76b24 Added love.window.setScreenSaverEnabled and love.window.isScreenSaverEnabled (resolves issue #1088.) 2015-11-24 22:16:40 -04:00
Alex Szpakowski d79d96a8f2 Also display graphics card information in the popup message when GL2 isn't supported. 2015-08-20 22:43:15 -03:00
Alex Szpakowski 4daa190513 Show the detected OpenGL version in the popup dialog when GL2.1 or GLES2 isn't available when the window is created. 2015-08-20 20:34:53 -03:00
Alex Szpakowski 9a1c4ad565 The iOS game list screen now also displays folders that contain main.lua. 2015-08-15 23:57:04 -03:00