Commit Graph

132 Commits

Author SHA1 Message Date
Alex Szpakowski 7370bd56ce Improved the error message when love.graphics.newImage fails due to CompressedImageData not having all required mipmap levels (thanks Shell32!) 2016-03-03 20:36:30 -04:00
Alex Szpakowski cf4b409302 Renamed some things. 2016-02-18 22:11:41 -04:00
Alex Szpakowski abd3c64bc5 Moved another AMD-specific driver bug workaround to the OpenGL Bugs struct. 2016-01-13 21:43:00 -04:00
Alex Szpakowski 46a2e7b85c Happy new year! 🎉 2016-01-01 00:05:06 -04:00
Alex Szpakowski 5a98af7e2d ASTC has guaranteed support when OpenGL ES 3.2 is used. 2015-12-31 15:48:05 -04:00
Alex Szpakowski 6036454a20 Fixed up some code. 2015-11-30 02:26:59 -04:00
Alex Szpakowski 77998c707d Added the ability to use ASTC compressed textures, when the system supports them. 2015-11-28 14:55:26 -04:00
Alex Szpakowski 890802c0a3 Use a more descriptive error message if love.graphics.newImage fails because the OpenGL texture can't be created. 2015-10-15 14:42:57 -03:00
Martin Felis 1ea54042e3 Fixed compilation when building for Android. 2015-08-13 19:39:56 -03:00
Alex Szpakowski 12450c9657 Don't error if a compressed texture with no mipmap information is passed into love.graphics.newImage and the mipmaps flag is true. 2015-08-12 19:33:56 -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 c02ba91ef4 Fix segfault loading images from compressed data without an explicit sRGB flag 2015-08-01 14:22:36 +02: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 d8fd1413d6 Renamed the internal 'Matrix' class to 'Matrix4'. 2015-06-26 19:34:05 -03:00
Alex Szpakowski ed3f419747 Prevent redundant calls to glEnable/DisableVertexAttribArray. This should hopefully fix a performance regression compared to 0.9.2 as well. 2015-06-23 20:55:23 -03:00
Alex Szpakowski 0f986b10aa Cleaned up some code, the 'ry' parameter of love.graphics.rectangle now defaults to the value of 'rx' rather than defaulting to 0. 2015-05-27 17:36:27 -03:00
Alex Szpakowski c62b005ff3 Changed the default mipmap filter to be 'linear' instead of 'nearest'. 2015-04-13 12:51:48 -03:00
Alex Szpakowski f8ff50cfde Fixed Image:refresh for sRGB images when OpenGL ES 2 is being used. 2015-04-05 17:35:19 -03:00
Alex Szpakowski cf0968fc6d Avoid some VC++ compiler warnings 2015-04-02 00:28:09 -03:00
Alex Szpakowski a29b349014 Added love.math.compress(data, format [, level]) and love.math.decompress(compresseddata) / love.math.decompress(compressedstring, format).
Renamed the love.image CompressedData type to CompressedImageData.

love.math.compress returns a love.math CompressedData object which holds the newly compressed data. Currently supported formats are "lz4" and "zlib". Note that the formats are not file formats and don't compress filesystem hierarchies.
2015-03-23 11:28:14 -03:00
Alex Szpakowski d31168c0e0 Cleaned up some graphics code. 2015-03-20 00:16:36 -03:00
Alex Szpakowski 06ef263537 Added OpenGL debug groups for most graphics operations when love is built in debug mode for iOS. The Xcode frame capture tool uses them to create nice visual groups for OpenGL function calls. 2015-03-16 22:55:58 -03:00
Alex Szpakowski 4ef0d257e9 Added an optional font hinting argument to love.graphics.newFont / love.font.newRasterizer when loading TrueType fonts. Resolves issue #963.
Accepted values are "normal", "light", "mono", and "none".
2015-03-07 22:05:37 -04:00
Alex Szpakowski 4fa5ab4a07 Fixed the winding order of triangles in SpriteBatches and ParticleSystems. 2015-03-04 16:03:01 -04:00
Alex Szpakowski 3830a0969c Moved the Texture and Quad Lua wrapper files out of the opengl graphics implementation folder.
--HG--
branch : minor
2015-03-01 03:51:44 -04:00
Alex Szpakowski faa4a33fe9 Use triangle strips rather than triangle fans when possible.
--HG--
branch : minor
2015-02-28 02:32:34 -04:00
Alex Szpakowski 971380003b Reorganized some Image code.
--HG--
branch : minor
2015-02-21 03:47:19 -04:00
Alex Szpakowski 36e99b4880 Fix an OpenGL error when an sRGB image is created with mipmaps in OpenGL ES 2.
--HG--
branch : minor
2015-02-09 21:46:56 -04:00
Alex Szpakowski 8067d42df2 Canvases now have OpenGL ES support, updated Texture:setWrap to return false for repeat wrap modes in non-power-of-two textures if OpenGL ES 2 is used and the implementation doesn't have support for repeat on NPOT textures.
--HG--
branch : minor
2015-01-20 15:13:59 -04:00
Alex Szpakowski 18ab3973e8 Added support for ETC2/EAC compressed textures. Changed the CompressedFormat enum names to capitalize the format names (e.g. "PVR1rgba4" instead of "pvr1rgba4".) Improved sRGB support for compressed textures.
--HG--
branch : minor
2015-01-20 07:53:44 -04:00
Alex Szpakowski dfdd52e499 Added support for ETC1 and PVR1 compressed textures contained in KTX, PKM, and PVR files.
Most desktop graphics drivers don't support those formats.

--HG--
branch : minor
2015-01-20 03:18:28 -04:00
Alex Szpakowski 1124612c1f Some work towards OpenGL ES 2+ support for love 0.10.
--HG--
branch : minor
2015-01-19 23:32:16 -04:00
Alex Szpakowski a7e4148869 Merged default into minor
--HG--
branch : minor
2015-01-16 15:47:26 -04:00
Alex Szpakowski c7b45b3505 Updated copyright for the new year 2014-12-31 19:32:43 -04:00
Alex Szpakowski c4a1457603 Fixed Image:setMipmapFilter keeping bad state around if it errors. 2014-12-05 12:19:50 -04:00
Alex Szpakowski 8dba668ce9 Merged default into minor
--HG--
branch : minor
2014-11-15 20:17:18 -04:00
Alex Szpakowski 22bbe74ed9 Allow BC6 and BC7 compressed DDS files to be loaded into Images. 2014-11-05 21:11:22 -04:00
Alex Szpakowski 5eb37d30f7 Cleaned up and simplified some graphics code.
--HG--
branch : minor
2014-10-26 15:31:32 -03:00
Alex Szpakowski a9630811d8 Fixed a logic error making compressed textures with no mipmaps trigger a Lua error when they're loaded into an Image.
--HG--
branch : minor
2014-10-06 20:09:10 -03:00
Alex Szpakowski d1bdc9a7e2 Images and Canvases are now drawn using GL_TRIANGLE_FAN instead of GL_QUADS, for future compatibility with GLES and core GL3+.
--HG--
branch : minor
2014-09-07 13:19:27 -03:00
Alex Szpakowski 8a7481eaa3 Added optional xoffset/yoffset/width/height arguments to Image:refresh, to specify a sub-rectangle. Specifying a small sub-rectangle can improve the performance of Image:refresh.
--HG--
branch : minor
2014-08-26 09:40:24 -03:00
Alex Szpakowski 3a51f0ad08 Changed the love.graphics internal code to always use a default shader when none is set externally, and replaced the deprecated OpenGL vertex attribute code with the equivalent generic vertex attribute functions.
This will simplify the code and make it more maintainable when OpenGL ES 2+ support is added, compared to using the deprecated VA functions on desktop GL and the generic VA functions on GLES.

--HG--
branch : minor
2014-08-26 03:24:42 -03:00
Alex Szpakowski 766939bdd5 Removed mipmapping restriction on non-power-of-two Images.
--HG--
branch : minor
2014-08-25 01:37:05 -03:00
Alex Szpakowski 1978fa9910 Cleaned up a bit of unused code. 2014-08-22 17:44:52 -03:00
Alex Szpakowski 71c71985d3 Merged default into minor
--HG--
branch : minor
2014-08-21 16:53:43 -03:00
Alex Szpakowski 8ffe610659 Added love.graphics.getStats. It returns a table with performance-related graphics statistics. Currently it contains these fields:
drawcalls: The number of internal draw calls made so far in the current frame.

canvasswitches: The number of times the active Canvas has been changed so far in the current frame.

texturememory: The approximate amount of video memory (in bytes) used by OpenGL textures created by Images, Canvases, and Fonts.

images: The number of active Image objects.

canvases: The number of active Canvas objects.

fonts: The number of active Font objects.
2014-08-21 15:01:29 -03:00
Alex Szpakowski 5f6ee50541 Replaced the GLee OpenGL function loader with a modified version of GLAD (resolves issue #728.)
--HG--
branch : minor
2014-08-18 21:35:52 -03:00
Alex Szpakowski 53e63d48c9 Merged default into minor
--HG--
branch : minor
2014-08-07 18:10:19 -03:00
Alex Szpakowski d59c76a55f Reduced the number of explicit retain/release method calls on love objects. Less chance of bugs! 2014-08-07 14:53:17 -03:00
Alex Szpakowski afc505e183 Added stack type enums to love.graphics.push (resolves issue #906.) Current enums are "transform" and "all". "transform" is the default (for compatibility.) When love.graphics.push("all") is used, love.graphics.pop() will restore all love.graphics module state to what it was when push was called.
Updated the graphics code to use a custom matrix stack rather than OpenGL1's APIs.
2014-08-06 22:25:29 -03:00