Commit Graph

268 Commits

Author SHA1 Message Date
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 d5ccdc040a Cleaned up some Proxy-related code. 2014-08-09 16:18:22 -03:00
Alex Szpakowski da7cd267ea Changed luax_pushtype to retain the pushed object itself, but only if the object isn't in the Lua state already.
Previously, calling e.g. love.graphics.getFont() 10,000 times would retain the object 10,000 times (and release it 10,000 times when the Font object was garbage-collected in the Lua state.) Now it will only retain it once and release it once.
2014-08-09 16:04:59 -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
Alex Szpakowski 014b9a46e5 Updated the Lua wrapper code for modules to account for cases where the module's instance is removed from memory completely and recreated during the program's lifetime. 2014-07-21 14:52:01 -03:00
Alex Szpakowski d11ccd0e69 Added love.graphics.getCanvasFormats and love.graphics.getCompressedImageFormats, and removed love.graphics.hasCanvasFormat.
The two new functions return tables containing the names of all relevant formats as keys, and boolean values indicating whether the formats are supported.
2014-07-05 16:22:52 -03:00
Alex Szpakowski 4c67a94ba3 Hopefully fixed issue #898, and cleaned up code for love.graphics.getRendererInfo. 2014-06-19 03:02:37 -03:00
Alex Szpakowski 23d3cbc2e2 Renamed all cases of FSAA to the more accurately-named MSAA. The FSAA names (canvas:getFSAA, t.window.fsaa, etc.) still exist for now, for backwards-compatibility. 2014-06-13 23:28:00 -03:00
Alex Szpakowski 3792dee4b4 Backout changeset 57172a7f03452a6b07f346e850f3e1020e230f46 2014-06-05 14:59:29 -03:00
Alex Szpakowski e9e303c1e8 Changed embedded Lua scripts to be included in the love source via C++11's raw string literals instead of a generated header file. Removed auto.lua.
As a result, love can be compiled immediately after editing an embedded Lua script.

Visual Studio 2013 or newer is required for C++11 raw string literals in Windows.
2014-06-05 13:42:03 -03:00
Alex Szpakowski 79b453653a Added love.joystick.loadGamepadMappings (resolves issue #842), and Joystick:saveGamepadMapping.
The latter returns a mapping string, and the former loads a newline-separated list of mapping strings.
2014-06-04 15:50:06 -03:00
Alex Szpakowski dfa319e01a Replaced the EXCEPT_GUARD macro for converting love exceptions into Lua errors with the new luax_catchexcept function, which takes lambda function arguments. 2014-06-03 19:27:00 -03:00
Alex Szpakowski 724bdbd296 love.graphics.newImage, love.image.newImageData, etc. no longer leave Lua-owned FileData objects floating around waiting to be GC'd when called with filename arguments, resulting in less memory use on startup (resolves issue #890.)
Moved love.filesystem Lua wrapper code from src/modules/filesystem/physfs/ to src/modules/filesystem/.
2014-06-02 00:22:41 -03:00
Alex Szpakowski 408a593113 Added support for several specific Canvas formats. Also added love.graphics.hasCanvasFormat.
The list includes RGBA with 4-bit components, RGBA with 10-bit R, G, and B components and a 2-bit alpha component, RGB with 9-bit RGB components and a 5-bit exponent component (for HDR rendering), and several more.

--HG--
branch : Canvas-formats
2014-05-13 20:54:58 -03:00
Alex Szpakowski 5428a5d75f Backout changeset b3928e24add23da69dcd90c34985cd6a05454be0 2014-05-03 22:07:32 -03:00
Alex Szpakowski 4bc96f1bf6 Internally compose and pass an array of shader source codes to OpenGL, instead of relying on #line to make sure the line number is correct for shader error messages (resolves issue #882) 2014-05-03 21:43:20 -03:00
Alex Szpakowski ecf37320a9 Changed love.graphics.newMesh, Mesh:setVertex, and Mesh:setVertices to default the u,v arguments to 0,0 instead of requiring them 2014-02-27 05:38:46 -04:00
Alex Szpakowski b625bb6624 moved Mesh:setWireframe to love.graphics.setWireframe (affects all draws until it's disabled.)
Wireframe mode should only be used for debugging: the wireframe lines behave differently than regular lines, their widths aren't affected by the graphics scale, and the mode isn't available on OpenGL ES.
2014-02-03 04:59:58 -04:00
Alex Szpakowski ce4fdf4ac9 Added sRGB (gamma-correct) support for Images, Canvases, and the main screen.
love.graphics.newImage(path, “srgb”) creates a new Image whose texels are treated as being in the sRGB color space, so they are linearized when drawing/sampling from the image.

love.graphics.newCanvas(w, h, “srgb”) creates a new Canvas whose texels are treated as being in the sRGB color space, so drawing to the Canvas does a linear->sRGB conversion (but blends linearly), and sampling from it (drawing it or using it in a shader) converts from sRGB to linear space.

The "srgb" window flag does the same as Canvases for the main screen.
2014-02-02 18:31:41 -04:00
Alex Szpakowski 988404e4ca Added love.graphics.getSystemLimit (resolves issue #840). Deprecated love.graphics.getMaxPointSize.
love.graphics.getSystemLimit currently accepts these enum strings: “pointsize”, “texturesize”, “multicanvas”, and “canvasfsaa”.
2014-01-27 02:19:30 -04:00
Alex Szpakowski 7556fde5e6 Added antialiasing (MSAA) support to Canvases via a new optional parameter. Added Canvas:getFSAA. 2014-01-27 01:31:41 -04:00
Alex Szpakowski ba7e69d776 Added Mesh:setDrawRange(min, max) and Mesh:getDrawRange().
If no vertex map is set, this restricts the drawn vertices to those whose indices in the vertex array are between [min, max] inclusive.
If a vertex map is set, this restricts the values used in the vertex map to those whose indices in the vertex map array are between [min, max] inclusive.

Added Mesh constructor variant: love.graphics.newMesh(vertexcount, texture, drawmode). Creates a Mesh with a certain number of vertices with x,y,u,v,r,g,b,a values of (0,0,0,0,255,255,255,255).
2014-01-21 06:16:47 -04:00
Alex Szpakowski 73f1ce0d40 Added instancing support to Meshes via Mesh:setInstanceCount. Added a new built-in variable to vertex shaders: int love_InstanceID.
love.graphics.draw(mesh) will draw the mesh instancecount times, using hardware instancing when available. The only way to draw individual instances differently from each other is to use the love_InstanceID variable in a vertex shader.

Added love.graphics.isSupported(“instancing”). Hardware instancing is supported if true, otherwise a (slower) pseudo-instancing fallback is used internally when drawing instanced meshes.
2014-01-21 06:01:50 -04:00
Alex Szpakowski 0e13975c11 Improved some error message text 2014-01-17 22:28:06 -04:00
Alex Szpakowski fda005c5ff love.graphics.getScissor now has a proper C++ module method 2014-01-09 22:49:00 -04:00
Alex Szpakowski c64b3d2527 Renamed love.graphics.getMaxImageSize to love.graphics.getMaxTextureSize (old function is still there, but deprecated.) 2014-01-09 22:18:37 -04:00
Alex Szpakowski 510ed6f11e Abstracted lua bindings for general Texture methods into wrap_Texture.cpp 2014-01-04 21:19:03 -04:00
Alex Szpakowski 3120a0e650 Goodbye 2013, hello 2014! 2014-01-03 17:28:58 -04:00
Alex Szpakowski aa69a695d3 Canvases can now be used in SpriteBatches, ParticleSystems, and Meshes (resolves issue #782).
Canvases and Images are now subclasses of the new Texture class.
Added setTexture and getTexture methods for Meshes, ParticleSystems, and SpriteBatches (the old set/getImage methods are deprecated but not removed.)
Canvas texture coordinates are no longer flipped.
2014-01-03 17:07:12 -04:00
Alex Szpakowski d9da19d665 Error for misspelled / invalid window attributes in love.window.setMode (resolves issue #736) 2013-10-20 13:17:57 -03:00
Alex Szpakowski b556dde3cb love.graphics.draw(image, quad, x, y, ...) now errors instead of shifting parameters if the quad argument is nil 2013-10-14 03:38:07 -03:00
Alex Szpakowski 206e184cde love.graphics.print's x and y arguments now default to 0 (resolves issue #638) 2013-10-07 23:52:30 -03:00
Alex Szpakowski fb34f5bc9e Auto-padded NPOT images' texture coordinates are now scaled at draw time via the texture matrix (fixes auto-padded images with Meshes.) Also fixed love.graphics.newQuad.
--HG--
branch : Mesh
2013-10-06 23:25:29 -03:00
Alex Szpakowski c426998b04 Fixed Mesh:setVertexMap when the mesh has more than 2^16-1 vertices (still needs more work to make it use smaller data types when available), added Mesh:setVertices
--HG--
branch : Mesh
2013-09-30 04:30:17 -03:00
Alex Szpakowski b59e3d9c35 Meshes now use vertex buffers for more efficient drawing.
--HG--
branch : Mesh
2013-09-29 21:24:19 -03:00
Alex Szpakowski c63e2ec624 Merged default into Mesh
--HG--
branch : Mesh
2013-09-29 04:58:26 -03:00
Alex Szpakowski 1e696c4505 Added Mesh objects and love.graphics.newMesh. Mesh objects are similar to Geometry but they're drawables (the relationship between meshes and images is the opposite of geometry and images.)
Removed Geometry objects and re-added Quads.

example:
local vertices = {{0, 0, 0, 0}, {100, 0, 1, 0}, {100, 100, 1, 1}, {0, 100, 0, 1}}
mesh = love.graphics.newMesh(vertices, image, "fan")
..
love.graphics.draw(mesh, 0, 0)

--HG--
branch : Mesh
2013-09-28 18:26:47 -03:00
Alex Szpakowski bcee9a222b Made some float/int/unsigned char conversions explicit, fixed ParticleSystem:getColors, fixed love.mouse.isDown with x1 and x2 buttons 2013-09-26 00:36:50 -03:00
Alex Szpakowski 5de43a7207 The Vertex struct is now recognized as POD by C++, also fixed the name to be consistent with other love structs 2013-09-24 11:09:18 -03:00
Alex Szpakowski b36d643570 Changed love.graphics.getRendererInfo to return all the info (resolves issue #757) 2013-09-23 18:03:10 -03:00
Alex Szpakowski 21d1e7737c Fixed ParticleSystem:setAreaSpread("none") to not require x/y arguments (resolves issue #738) 2013-09-17 00:54:55 -03:00
Alex Szpakowski f89097ed90 Fixed the error message when only one argument is given to newImageFont (resolves issue #737) 2013-09-16 03:11:38 -03:00
Alex Szpakowski ef9f30d5c4 Fixed a typo preventing compressed textures from being loaded into images 2013-09-06 00:59:19 -03:00
Alex Szpakowski 06f80d5c08 Fixed undefined behaviour when love exceptions are converted into Lua errors (resolves issue #729) 2013-09-05 23:17:29 -03:00
Alex Szpakowski ec9dec6b80 Replaced luax_newtype with luax_pushtype (and added luax_rawnewtype for the old functionality of luax_newtype.)
luax_pushtype keeps the object in a weak table and checks the table before creating a new userdata, so it re-uses the object's existing wrapper userdata if it can, whenever the object is pushed to Lua.

This fixes some subtle issues with love objects, where using them as keys in tables would not always work as expected (https://love2d.org/forums/viewtopic.php?f=4&t=39398&p=112388#p112415). It also decreases the amount of new Lua objects created, saving the garbage collector some work.
2013-08-29 00:40:06 -03:00
Alex Szpakowski 1b5912a461 Really fixed setScissor erroring when scissoring is disabled and x,y,w,h from getScissor is used (see issue #709) 2013-08-21 19:37:26 -03:00
Alex Szpakowski 394888bd13 Fixed love.graphics.setScissor and love.graphics.setColorMask to not error if a single nil argument is given (resolves issue #709) 2013-08-21 18:52:07 -03:00
Alex Szpakowski 96a668ecf3 Renamed CompressedData:getType to CompressedData:getFormat 2013-08-17 14:30:23 -03:00
Alex Szpakowski 72068ba519 love.graphics.isSupported now errors if an invalid string is given (see issue #690) 2013-08-17 00:12:46 -03:00
Alex Szpakowski 73e9f327dc Cleaned up boot.lua a tiny bit 2013-08-08 03:19:54 -03:00