Commit Graph

139 Commits

Author SHA1 Message Date
Alex Szpakowski dd59803ad3 Error when invalid setting names are used in the tables passed to love.graphics.newCanvas and newImage. See issue #1312. 2017-12-28 23:16:51 -04:00
Alex Szpakowski f7b2598490 Remove unnecessary internal constructor arguments. 2017-12-24 22:08:57 -04:00
Alex Szpakowski a31b500b03 Simplify quad drawing code, and use glDrawElementsBaseVertex when available. 2017-12-24 22:05:10 -04:00
Alex Szpakowski 3fb621af95 Always use a 16 bit index array for quad indices, with multiple draws when necessary. See issue #1356. 2017-12-24 15:54:03 -04:00
Alex Szpakowski 7354de2059 Add (low level) functionality to allow rendering 3D Meshes.
- Add love.graphics.setDepthMode(testcomparison, enablewrites).
- Add love.graphics.setMeshCullMode.
- Add love.graphics.setFrontFaceWinding.

Depth testing and depth writes require a depth buffer to work. The mesh cull mode controls whether front/back faces of a mesh are culled. The front face winding determines whether a clockwise or counterclockwise-oriented face in a mesh is considered front facing.

--HG--
branch : minor
2017-12-09 23:34:08 -04:00
Alex Szpakowski 915e6c8eec Fill-mode love.graphics.circle/ellipse draws a triangle fan from the center of the ellipse, instead of from an edge.
--HG--
branch : minor
2017-12-04 19:12:06 -04:00
Alex Szpakowski e099e57052 Cleaned up some internal love.graphics code.
--HG--
branch : minor
2017-12-03 23:04:40 -04:00
Alex Szpakowski cbcb1a8606 Allow a depth/stencil canvas to be active without a color canvas.
--HG--
branch : minor
2017-12-03 19:33:48 -04:00
Alex Szpakowski b8c4b07edf Clean up unused temporary Canvases after a few frames.
--HG--
branch : minor
2017-11-13 19:45:18 -04:00
Alex Szpakowski 7f88037d94 Move the implementation for Graphics::flushStreamDraws out of the opengl backend
--HG--
branch : minor
2017-10-26 21:05:15 -03:00
Alex Szpakowski e3fd489373 Abstracted lower level drawing code, moved all type-specific drawing code out of opengl backend, deleted obsolete files
--HG--
branch : minor
2017-10-26 20:58:19 -03:00
Alex Szpakowski 7a2e52b12d Cleaned up some vertex data-related code.
--HG--
branch : minor
2017-10-22 12:33:47 -03:00
Alex Szpakowski e5b0d96b27 Restructured some Shader code. Added runtime temporary caching and sharing of shader stages. Resolves issue #1235.
--HG--
branch : minor
2017-10-21 03:08:18 -03: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 1b3745b58b Fix a crash on quit if a non-default shader is active when quitting.
--HG--
branch : minor
2017-09-23 20:23:01 -03:00
Bart van Strien 77663ed847 Replace love.graphics.pop("all") with love.graphics.getStackDepth (resolves #1248 again)
The pop("all") api was a bit awkward, especially considering there's a
push("all") that does something else. I think any use case that benefited from
pop("all") benefits from getStackDepth just as much if not more. There is also
additional functionality, like being able to find the source of a mismatched
push/pop.

--HG--
branch : minor
2017-09-23 10:56:54 +02:00
Bart van Strien a2ad1b462f Add love.graphics.pop("all"), which pops the entire stack (resolves #1248)
--HG--
branch : minor
2017-09-18 14:31:51 +02:00
Alex Szpakowski b4f8f08b70 Enable (when available) and improve performance of persistently mapped buffer path for the vertex/index buffers used with automatic batching.
--HG--
branch : minor
2017-09-03 18:23:54 -03:00
Alex Szpakowski de28c6e6a8 Add the ability to have formally deprecated functions.
Functions which are deprecated will print out a message and show up in a small dialog on-screen, when they're first called. Deprecation output is disabled in fused mode by default, and can be modified with love.setDeprecationOutput(enable).

--HG--
branch : minor
2017-08-27 13:46:31 -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 d578c35f4a Fix love.graphics.circle (thanks xenthral!)
--HG--
branch : minor
2017-07-25 08:05:46 -03:00
Alex Szpakowski b3d4443f9d Added 'drawcallsbatched' field to the table returned by love.graphics.getStats.
It has the number of draw calls that were saved by auto-batching.

--HG--
branch : minor
2017-07-23 01:58:25 -03:00
Alex Szpakowski c37e9ed6bf Use vector2 arrays instead of raw float arrays for graphics primitives. Simplifies the code a bit.
--HG--
branch : minor
2017-07-23 01:49:27 -03:00
Alex Szpakowski 864147c38c love.graphics: move more platform-independent code out of the opengl backend
--HG--
branch : minor
2017-07-22 23:34:39 -03:00
Alex Szpakowski 34f25bd6c8 ESSL: always enable standard derivative functionality (dFdx, dFdy, fwidth) when available. Added 'shaderderivatives' graphics feature enum.
--HG--
branch : minor
2017-07-09 16:55:21 -03:00
Alex Szpakowski 54a049e206 Restructured internal code for graphics capabilities. Added love.graphics.getTextureTypes which returns a table of Texture Type to boolean supported fields.
--HG--
branch : minor
2017-06-27 22:26:30 -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 b019a4a64c Cleaned up texture VRAM usage tracking.
--HG--
branch : minor
2017-05-06 23:56:10 -03:00
Alex Szpakowski 621fb24ba1 Require stencil=true to be specified in setCanvas if stenciling is used while a Canvas is active and there is no custom stencil buffer.
--HG--
branch : minor
2017-04-29 21:29:37 -03:00
Alex Szpakowski fd64999748 Allow calling love.graphics.drawLayer(arraycanvas, layer) when rendering to a different layer of the same Canvas.
--HG--
branch : minor
2017-04-29 13:35:07 -03:00
Alex Szpakowski 70b32c47ce Error if a non-2D/affine matrix is used with auto-batched draws, since they perform CPU-side matrix transforms on 2-component vectors.
--HG--
branch : minor
2017-04-23 00:12:57 -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 0fde3fde35 Add new variants of love.graphics.print/printf which accept a Font argument, rather than relying on global love.graphics state to determine the Font to use.
--HG--
branch : minor
2017-03-06 23:15:10 -04: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 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 a3ae0e2279 Fix love.graphics.points when no per-point colors are given
--HG--
branch : minor
2017-01-29 17:47:29 -04:00
Alex Szpakowski c0e66eba83 Move backend-agnostic Mesh and SpriteBatch code out of the opengl implementation folder.
--HG--
branch : minor
2017-01-29 01:05:20 -04:00
Alex Szpakowski d990044288 love.graphics internal Buffer objects are no longer OpenGL-specific.
--HG--
branch : minor
2017-01-28 19:26:57 -04:00
Alex Szpakowski bea7cfdaab Add low-level hardware instancing support to Meshes.
Add “instancing” Graphics Feature constant.

Add love.graphics.drawInstanced(mesh, instancecount, x, y, …) which draws the mesh multiple times in a single draw call. Each instance of the mesh will appear in the exact same spot unless one of the following are used:

- Add an optional vertex attribute step type argument to Mesh:attachAttribute. “pervertex” is the default. “perinstance” causes the attribute to be per-instance instead of per-vertex, when the mesh is drawn.

- Add love_InstanceID as a built-in read only int variable in GLSL 3 vertex shaders. It is always 0 except when a Mesh is drawn with more than 1 instance specified in the draw call. It can be used to manually compute or index into per-instance values in a shader.

--HG--
branch : minor
2017-01-22 20:52:11 -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 a6669a8bb2 Merge default into minor
--HG--
branch : minor
2017-01-21 12:06:35 -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