Commit Graph

67 Commits

Author SHA1 Message Date
Alex Szpakowski e10444c21f Move Texture:generateMipmaps error handling out of backend code 2020-10-25 23:13:50 -03:00
Alex Szpakowski 2c4bfab1de Merge branch '12.0-development' into GraphicsBuffer 2020-05-23 20:29:38 -03:00
Alex Szpakowski e0ff593d09 Fix love.graphics.newTexture(imagedata, {canvas=true}) not using an sRGB format when it should 2020-03-04 20:37:41 -04:00
Alex Szpakowski 7fbb68e90e Merge branch '12.0-development' into GraphicsBuffer 2020-02-28 23:10:21 -04:00
Alex Szpakowski 9425c9224b Rename internal batched draw code to be more clear 2020-02-27 20:08:50 -04:00
Alex Szpakowski b1c028a4d3 Merge branch '12.0' into GraphicsBuffer 2020-02-17 16:31:02 -04:00
Alex Szpakowski 7c34345fa6 Rename new/set/getRenderTarget back to new/set/getCanvas, for now.
The setRenderTarget/setCanvas API will likely change before 12.0 is released, so there's no reason to rename things unnecessarily before then.
2020-02-16 19:42:11 -04:00
Alex Szpakowski 4ec9cafdea Better error checking in the GL texture backend 2020-02-12 22:57:13 -04:00
Alex Szpakowski 694bc9c5b7 rename love_Canvases to love_RenderTargets in shaders.
More misc. renaming
2020-02-09 12:11:19 -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 0017f9c77d Remove a redundant internal Texture method 2020-02-04 22:15:18 -04:00
Alex Szpakowski 258129738f Remove graphics::Canvas and graphics::Image 2020-02-04 22:06:55 -04:00
Alex Szpakowski 0304bdf450 Move getMipmapMode from Canvas to Texture 2020-02-04 19:56:19 -04:00
Alex Szpakowski 4104c136cf Move Canvas:newImageData to Texture:newImageData 2020-02-04 19:19:37 -04:00
Alex Szpakowski 4716211c14 Move replacePixels from Image to Texture 2020-02-04 19:05:43 -04:00
Alex Szpakowski 63c5df6aa7 Begin unification of Canvases and Images. 2020-02-03 23:05:46 -04:00
Alex Szpakowski fc0d60a96d Move Canvas:getMSAA to Texture:getMSAA. 2020-02-03 19:26:11 -04:00
Alex Szpakowski b46b3ed552 Move some Canvas code to Texture, devirtualize Texture::draw. 2020-02-03 19:02:58 -04:00
Alex Szpakowski f9248d478c Refactor sampler state parameters for textures. 2020-02-02 22:26:28 -04:00
Alex Szpakowski f24b1aa377 Move internal Slices class from Image to Texture 2020-02-02 13:50:37 -04:00
Alex Szpakowski 2572f0c7a1 Meshes expose GraphicsBuffers, part 2 2020-02-01 15:39:59 -04:00
Alex Szpakowski ee5304ba53 Remove vertex namespace 2020-01-13 20:41:05 -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 361cefbb05 Add new wrap mode "clampone". Pixels sampled outside of [0, 1] are white (1, 1, 1, 1).
--HG--
branch : minor
2019-12-27 13:57:20 -05:00
Alex Szpakowski 9ab2a94037 Rename internal C++ Color struct to Color32 to help differentiate it from Colorf. 2019-09-14 23:13:40 -03:00
Alex Szpakowski 0752f27bdf Update copyright year for 2019 2019-01-03 21:09:05 -04:00
Martin Felis 1462f4cf56 (Android) Removed declaration of log2 as it is available in newer NDK APIs 2018-03-31 22:46:12 +02:00
Alex Szpakowski 39201af79f Improve the error message when an invalid layer or face index is given in love.graphics.setMode. 2018-01-14 19:15:24 -04:00
Alex Szpakowski 6808968893 Fix an issue when calculating the number of mipmaps for a volume/3D texture. 2018-01-06 01:55:09 -04:00
Bart van Strien e80247c191 Happy new year! 2018-01-03 19:47:35 +01:00
Bart van Strien 9e4374935d Show (short) list of possible enum values when an invalid value is encountered (resolves #1318)
All enum errors have (hopefully) been changed to a luax_enumerror, which has a
fixed error message. If additionally a list of valid options is passed, it
lists that in the error message. For every enum error with few options I've
implemented this using a getConstants call.

This solution has been designed specifically to reduce the number of template
instantiations (as I've been told that was a concern). All new template code
happens in places where there already was an instantiation of the relevant
StringMap. Of course there is still std::vector<std::string>...

--HG--
branch : minor
2017-10-02 17:11:53 +02: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 0b68c92570 Rename some internal functionality to better match what it actually is.
--HG--
branch : minor
2017-08-25 22:42:03 -03:00
Alex Szpakowski 130ee7e1d9 Consolidated Image and Canvas dimension validation code.
--HG--
branch : minor
2017-07-11 20:38:47 -03:00
Alex Szpakowski 9fe81ad922 Allow a temporary/internal depth buffer to be used when a Canvas is active, similar to how temporary stencil buffers are allowed.
Syntax is setCanvas{canvas [, depth=true, stencil=true]} or setCanvas{canvas, depthstencil=true}.

--HG--
branch : minor
2017-06-10 14:25:22 -03:00
Alex Szpakowski e03c763215 Fix love.graphics.drawLayer.
--HG--
branch : minor
2017-05-20 15:37:29 -03:00
Alex Szpakowski 7694edfd52 Auto-batched draws (except for love.graphics.print, for now) are affected by 3D transforms.
--HG--
branch : minor
2017-05-17 22:03:09 -03:00
Alex Szpakowski ac697ddb0f Clean up love’s internal Vector code a bit, and rename it to Vector2 so it’s more obvious what it is.
--HG--
branch : minor
2017-05-16 22:07:01 -03:00
Alex Szpakowski 135d928922 Fix compilation
--HG--
branch : minor
2017-05-06 23:59:15 -03:00
Alex Szpakowski b019a4a64c Cleaned up texture VRAM usage tracking.
--HG--
branch : minor
2017-05-06 23:56:10 -03:00
Alex Szpakowski 7161d600b7 Add mipmapping support to Canvases.
- Added an optional mipmap index argument to the non-table variant of love.graphics.setCanvas, and an optional ‘mipmap’ field to the table variant.
- Canvas:setMipmapFilter now works.
- Added Canvas:generateMipmaps.
- Added Canvas:getMipmapMode.
- Added a new ‘mipmaps’ enum field to the table passed into love.graphics.newCanvas. Accepted values are “none” (default), “manual”, and “auto”.

If a Canvas has the manual mipmap mode, you will either need to render to a mipmap level or call Canvas:generateMipmaps. If it has the auto mode, mipmaps will be automatically generated after rendering to that Canvas. Generating mipmaps is not free.

--HG--
branch : minor
2017-04-15 01:58:03 -03:00
Alex Szpakowski a0ef2ac28b Add Depth compare / shadow sampler support. Officially this is only supported in glsl3 shaders.
- Add Texture:setDepthSampleMode(comparemode). Only works on textures with depth pixel formats. A texture with the depth sample mode set will only work with a depth sampler.
- Add DepthImage, DepthArrayImage, and DepthCubeImage sampler keywords to glsl3.

--HG--
branch : minor
2017-04-12 20:26:06 -03:00
Alex Szpakowski 018a3831cb Add a new “stencil8” pixel format for Canvases (resolves issue #1003).
Also fixed Canvas MSAA (resolves issue #1271).

stencil-formatted Canvases can’t be drawn, and can only be used as the value for a new ‘depthstencil’ field to the table-argument variant of love.graphics.setCanvas.

--HG--
branch : minor
2017-04-11 00:00:22 -03:00
Alex Szpakowski 66b299822a Array textures can be easily drawn without a shader (resolves issue #1111).
Added love.graphics.drawLayer(texture, layerindex, …). ‘texture’ must be an array texture.
Added SpriteBatch:add/setLayer.

Added Quad:get/setLayer. This applies to array textures that are drawn without specifying an explicit layer index in the draw call.

Added love.graphics.newQuad variants which have layer arguments.

--HG--
branch : minor
2017-02-26 17:11:22 -04:00
Alex Szpakowski 73fd45558b Implement Array, Cubemap, and Volume texture types (issue #1111).
- Add love.graphics.newArrayImage, newCubeImage, and newVolumeImage.
- Add love.graphics.newCanvas(w, h, layers) and newCanvas(w, h, layers, settings). Add ‘type’ field to the settings table of newCanvas.

- Add new love.graphics.setCanvas variants: setCanvas(canvas, slice), and setCanvas(canvastable) where canvastable is in the format: {{canvas1, layer=2}, {canvas2, face=5}}

- Add Texture:getTextureType, getDepth, getLayerCount, getMipmapCount, and getFormat.

- Remove Image:getData and Image:refresh.
- Add Image:replacePixels(imagedata [, slice] [, mipmap]).

- Update Canvas:newImageData to accept a slice argument.

- Add love.image.newCubeFaces(imagedata).

--HG--
branch : minor
2017-02-20 14:58:13 -04:00
Alex Szpakowski abb72cb813 Happy new year! 🥂
--HG--
branch : minor
2017-01-02 01:28:29 -04:00
Alex Szpakowski f12596dd19 More code restructuring.
Move all love.graphics functionality that doesn’t call OpenGL out of the OpenGL backend Graphics class.

--HG--
branch : minor
2016-12-30 18:36:54 -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 19aee7e75c Minor optimizations to love.graphics.draw(texture).
--HG--
branch : minor
2016-12-28 01:24:21 -04:00