Commit Graph

121 Commits

Author SHA1 Message Date
Alex Szpakowski 8c204efafb Minor pre-emptive fixes for GL3.
--HG--
branch : minor
2017-01-05 22:33:10 -04:00
Alex Szpakowski 551dc423a2 Improved performance slightly when love.graphics.setColor is used heavily with automatic batching.
--HG--
branch : minor
2017-01-03 23:49:29 -04:00
Alex Szpakowski 8899c03651 Add C++ side support for unsigned int shader uniforms. Note that the shader languages love currently supports (glsl 1.20, glsl es 1.00) don’t support uints at the moment.
--HG--
branch : minor
2017-01-02 20:41:07 -04:00
Alex Szpakowski abb72cb813 Happy new year! 🥂
--HG--
branch : minor
2017-01-02 01:28:29 -04:00
Alex Szpakowski 548293e100 Don’t call unnecessary OpenGL APIs in love.graphics.setColor
--HG--
branch : minor
2017-01-02 01:02:15 -04:00
Alex Szpakowski 66749e874f love.graphics Video code is upwards-compatible with GL3.
--HG--
branch : minor
2017-01-01 21:58:13 -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 8aa6725039 Cleaned up some duplicated pixel format-related code in Font files.
--HG--
branch : minor
2016-12-29 02:45:27 -04:00
Alex Szpakowski 52b7b0f80d Unify separate GL/GLES code paths for love’s built in matrices in shaders.
--HG--
branch : minor
2016-12-28 19:32:43 -04:00
Alex Szpakowski 0d2e08baff Implement automatic batching for points, lines, shapes, and images/quads.
The above are batched together into a single draw call when called without other drawing calls in between, as long as the following criteria are met:

- The texture is the same.
- The primitive type is the same (points cannot be batched with non-points).
- The love.graphics state is the same (aside from the current color - i.e. setColor - and the transform state).
- The active shader’s uniform values are the same.

You can examine the ‘drawcalls’ field of love.graphics.getStats() to help determine if your code is allowing for optimum batching.

--HG--
branch : minor
2016-12-27 21:02:58 -04:00
Alex Szpakowski 0a8c6f3ee6 Cleaned up some love.graphics code.
--HG--
branch : minor
2016-12-10 23:46:00 -04:00
Alex Szpakowski 0a3adc0839 Unify pixel format enums for ImageData, CompressedImageData, and Canvas into a single PixelFormat enum.
Replace love.graphics.getRawImageFormats and love.graphics.getCompressedImageFormats with love.graphics.getImageFormats.

--HG--
branch : minor
2016-11-27 22:53:23 -04:00
Alex Szpakowski f85ee6b504 Add some more graphics feature and limit queries (resolves issue #1234).
love.graphics.getSupported():
 - Added “fullnpot” field, is true everywhere except on some older mobile devices. If false, mipmapping and wrap modes other than “clamp” can’t be used on non-power-of-two sized textures.
 - Added “pixelshaderhighp” field, is true everywhere except some older mobile devices. If false, “highp” precision can’t be used in pixel shaders and love will default to “mediump” instead.

love.graphics.getSystemLimits():
- Added “anisotropy” field, gets the maximum amount of anisotropy you can specify in Texture:setFilter. love will clamp anisotropy arguments greater than this value.

--HG--
branch : minor
2016-11-25 19:35:07 -04:00
Alex Szpakowski bed9bc1bae We don’t need a list of projection matrices..
--HG--
branch : minor
2016-11-19 20:12:12 -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 a9d935caa1 Fixed compilation
--HG--
branch : minor
2016-10-21 23:43:26 -03:00
Alex Szpakowski 2222bb37d2 Removed gl.bindTexture, so it won't get accidentally used.
--HG--
branch : minor
2016-10-21 23:42:09 -03:00
Alex Szpakowski 14f1afa446 Reduce redundant glActiveTexture calls.
--HG--
branch : minor
2016-10-21 22:19:16 -03:00
Alex Szpakowski d1c5edd792 Prevent redundant glBindBuffer calls.
--HG--
branch : minor
2016-10-20 21:50:48 -03:00
Alex Szpakowski 901cc362df Added 'shaderswitches' to love.graphics.getStats. 2016-04-02 18:14:52 -03:00
Alex Szpakowski 8b07bad15e Fixed the build. 2016-03-20 22:36:54 -03:00
Alex Szpakowski 9ebd759851 Don't call glGetFloat every time love.graphics.getSystemLimits is called. 2016-03-20 22:00:24 -03: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 6d6d805858 Workaround for love.graphics.clear + love.graphics.setCanvas AMD driver bug, take two. 2016-01-09 23:40:04 -04:00
Alex Szpakowski 4f093e7fac Added a workaround for an AMD driver bug where setCanvas + clear + setCanvas doesn't work. 2016-01-09 17:14:05 -04:00
Alex Szpakowski 46a2e7b85c Happy new year! 🎉 2016-01-01 00:05:06 -04:00
Alex Szpakowski 538f3869c5 Don't query the current texture bindings when initializing OpenGL. 2015-12-24 15:53:50 -05:00
Alex Szpakowski 6036454a20 Fixed up some code. 2015-11-30 02:26:59 -04:00
Alex Szpakowski 4c82c96369 Added a new texture wrap mode "clampzero", which outputs transparent black (or opaque black for textures without an alpha channel) rather than the texture's edge colors, when it's drawn or sampled from outside of its regular texture coordinate range. 2015-11-30 02:22:20 -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 f6448116cc Fixed OpenGL ES function loading on some Android devices. 2015-08-13 19:44:52 -03:00
Alex Szpakowski af06203a4a Moved the appveyor script to a subfolder and updated it to properly choose Visual Studio 2012 and to create a post-build zip file. 2015-06-28 21:39:56 -03:00
Alex Szpakowski d8fd1413d6 Renamed the internal 'Matrix' class to 'Matrix4'. 2015-06-26 19:34:05 -03:00
Alex Szpakowski 247daa85b5 Added a couple comments documenting why some codepaths have been chosen. 2015-06-24 22:25:55 -03:00
Alex Szpakowski 4c571e8fd7 Prevent redundant shader uniform uploads for built-in uniforms when OpenGL ES 2 is used.
As a result, the graphics primitive drawing functions (e.g. love.graphics.rectangle) are now more efficient on mobile devices.
2015-06-24 22:04:19 -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 c82ccbb89b love.graphics.setColor no longer uses the main per-vertex color attribute. This lets it affect the color of ParticleSystems, and SpriteBatches and Meshes even when they use custom per-vertex colors. 2015-06-21 11:20:26 -03:00
Alex Szpakowski 33e1d2736d Removed restrictions preventing sRGB and non-sRGB canvases from being used together when doing multi-canvas rendering. 2015-04-25 21:32:10 -03:00
Alex Szpakowski d8a68d6ce1 Updated iOS-specific graphics code to use the latest SDL changes. 2015-04-13 12:26:54 -03:00
Alex Szpakowski d31168c0e0 Cleaned up some graphics code. 2015-03-20 00:16:36 -03:00
Alex Szpakowski a36dbc3d49 Only update the shader point size in OpenGL ES 2 when it's been modified, rather than before every draw. 2015-03-17 17:24:45 -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 4dc73959a6 Hopefully fixed a major bug related to using Shader:send with textures. 2015-03-06 02:08:33 -04:00
Alex Szpakowski 06fa7bd7a4 Don't enable SDL_GL_FRAMEBUFFER_SRGB_CAPABLE in Linux when creating the window, to work around a potential bug. sRGB windows are still possible even without that. 2015-03-03 17:48:19 -04:00
Alex Szpakowski 8277eb9abd Renamed the internal OpenGL buffer class from VertexBuffer to GLBuffer. 2015-03-03 02:21:28 -04:00
Alex Szpakowski 3fea174008 Cleaned up some shader code.
--HG--
branch : minor
2015-03-02 15:18:12 -04:00
Alex Szpakowski b9c90e8a6f Fixed the background color for the error screen, and updated LodePNG to the latest version.
--HG--
branch : minor
2015-02-27 21:20:31 -04:00
Alex Szpakowski 3efcf3901b Removed Canvas:clear. love.graphics.clear now accepts r,g,b,a values (and defaults to 0,0,0,0 with no arguments given.) love.graphics.clear clears the content of the currently active Canvas(es.)
--HG--
branch : minor
2015-02-27 03:47:25 -04:00