Difference between revisions of "love.graphics.newCanvas"
m |
(→See Also) |
||
(10 intermediate revisions by 4 users not shown) | |||
Line 25: | Line 25: | ||
== Function == | == Function == | ||
− | {{newin|[[0.9.0]]|090|type=variant}} | + | {{newin|[[11.0]]|110|type=variant}} |
+ | Creates a 2D or [[TextureType|cubemap]] Canvas using the given settings. | ||
+ | === Synopsis === | ||
+ | <source lang="lua"> | ||
+ | canvas = love.graphics.newCanvas( width, height, settings ) | ||
+ | </source> | ||
+ | === Arguments === | ||
+ | {{param|number|width|The desired width of the Canvas.}} | ||
+ | {{param|number|height|The desired height of the Canvas.}} | ||
+ | {{param|table|settings|A table containing the given fields:}} | ||
+ | {{subparam|TextureType|type ("2d")|The type of Canvas to create.}} | ||
+ | {{subparam|PixelFormat|format ("normal")|The format of the Canvas.}} | ||
+ | {{subparam|boolean|readable|Whether the Canvas is [[Texture:isReadable|readable]] (drawable and accessible in a [[Shader]]). True by default for regular formats, false by default for depth/stencil formats.}} | ||
+ | {{subparam|number|msaa (0)|The desired number of multisample antialiasing (MSAA) samples used when drawing to the Canvas.}} | ||
+ | {{subparam|number|dpiscale ([[love.graphics.getDPIScale]]())|The [[Texture:getDPIScale|DPI scale factor]] of the Canvas, used when drawing to the Canvas as well as when drawing the Canvas to the screen.}} | ||
+ | {{subparam|MipmapMode|mipmaps ("none")|Whether the Canvas has mipmaps, and whether to automatically regenerate them if so.}} | ||
+ | === Returns === | ||
+ | {{param|Canvas|canvas|A new Canvas with specified width and height.}} | ||
+ | === Notes === | ||
+ | Some Canvas formats have higher system requirements than the default format. Use [[love.graphics.getCanvasFormats]] to check for support. | ||
+ | |||
+ | == Function == | ||
+ | {{newin|[[11.0]]|110|type=variant}} | ||
+ | Creates a [[TextureType|volume or array]] texture-type Canvas. | ||
+ | === Synopsis === | ||
+ | <source lang="lua"> | ||
+ | canvas = love.graphics.newCanvas( width, height, layers, settings ) | ||
+ | </source> | ||
+ | === Arguments === | ||
+ | {{param|number|width|The desired width of the Canvas.}} | ||
+ | {{param|number|height|The desired height of the Canvas.}} | ||
+ | {{param|number|layers|The number of array layers (if the Canvas is an Array Texture), or the volume depth (if the Canvas is a Volume Texture).}} | ||
+ | {{param|table|settings|A table containing the given fields:}} | ||
+ | {{subparam|TextureType|type ("array")|The type of Canvas to create.}} | ||
+ | {{subparam|PixelFormat|format ("normal")|The format of the Canvas.}} | ||
+ | {{subparam|boolean|readable|Whether the Canvas is [[Texture:isReadable|readable]] (drawable and accessible in a [[Shader]]). True by default for regular formats, false by default for depth/stencil formats.}} | ||
+ | {{subparam|number|msaa (0)|The desired number of multisample antialiasing (MSAA) samples used when drawing to the Canvas.}} | ||
+ | {{subparam|number|dpiscale ([[love.graphics.getDPIScale]]())|The [[Texture:getDPIScale|DPI scale factor]] of the Canvas, used when drawing to the Canvas as well as when drawing the Canvas to the screen.}} | ||
+ | {{subparam|MipmapMode|mipmaps ("none")|Whether the Canvas has mipmaps, and whether to automatically regenerate them if so.}} | ||
+ | === Returns === | ||
+ | {{param|Canvas|canvas|A new Canvas with specified width and height.}} | ||
+ | === Notes === | ||
+ | Not all texture types are supported by all systems. [[love.graphics.getTextureTypes]] can check for support. | ||
+ | |||
+ | == Function == | ||
+ | {{newinoldin|[[0.9.0]]|090|[[11.0]]|110|type=variant}} | ||
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
Line 37: | Line 82: | ||
{{param|Canvas|canvas|A new Canvas with specified width and height.}} | {{param|Canvas|canvas|A new Canvas with specified width and height.}} | ||
=== Notes === | === Notes === | ||
− | Some Canvas | + | Some Canvas formats have higher system requirements than the default format. Use [[love.graphics.getCanvasFormats]] to check for support. |
== Function == | == Function == | ||
− | {{ | + | {{newinoldin|[[0.9.1]]|091|[[11.0]]|110|type=variant}} |
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
Line 50: | Line 95: | ||
{{param|CanvasFormat|format ("normal")|The desired texture format of the Canvas.}} | {{param|CanvasFormat|format ("normal")|The desired texture format of the Canvas.}} | ||
{{param|number|msaa (0)|The desired number of multisample antialiasing (MSAA) samples used when drawing to the Canvas.}} | {{param|number|msaa (0)|The desired number of multisample antialiasing (MSAA) samples used when drawing to the Canvas.}} | ||
− | |||
=== Returns === | === Returns === | ||
{{param|Canvas|canvas|A new Canvas with specified width and height.}} | {{param|Canvas|canvas|A new Canvas with specified width and height.}} | ||
− | |||
− | |||
− | If the number of MSAA samples specified is greater than the maximum supported by the system, the Canvas will still be created but only using the maximum supported amount (this includes 0.) | + | == Notes == |
+ | * Not all texture types are supported by all systems. [[love.graphics.getTextureTypes]] can check for support. | ||
+ | * Some Canvas formats have higher system requirements than the default format. Use [[love.graphics.getCanvasFormats]] to check for support. | ||
+ | * The supported maximum number of MSAA samples varies depending on the system. Use [[love.graphics.getSystemLimits]] to check. | ||
+ | * If the number of MSAA samples specified is greater than the maximum supported by the system, the Canvas will still be created but only using the maximum supported amount ('''this includes 0.''') | ||
== See Also == | == See Also == | ||
* [[parent::love.graphics]] | * [[parent::love.graphics]] | ||
+ | * [[love.graphics.draw]] | ||
* [[Constructs::Canvas]] | * [[Constructs::Canvas]] | ||
* [[love.graphics.setCanvas]] | * [[love.graphics.setCanvas]] |
Latest revision as of 14:38, 28 July 2021
Available since LÖVE 0.8.0 |
It has been renamed from love.graphics.newFramebuffer. |
Creates a new Canvas object for offscreen rendering.
This function can be slow if it is called repeatedly, such as from love.update or love.draw. If you need to use a specific resource often, create it once and store it somewhere it can be reused! |
Contents
Function
Synopsis
canvas = love.graphics.newCanvas( )
Arguments
None.
Returns
Canvas canvas
- A new Canvas with dimensions equal to the window's size in pixels.
Function
Synopsis
canvas = love.graphics.newCanvas( width, height )
Arguments
Returns
Canvas canvas
- A new Canvas with specified width and height.
Function
Available since LÖVE 11.0 |
This variant is not supported in earlier versions. |
Creates a 2D or cubemap Canvas using the given settings.
Synopsis
canvas = love.graphics.newCanvas( width, height, settings )
Arguments
number width
- The desired width of the Canvas.
number height
- The desired height of the Canvas.
table settings
- A table containing the given fields:
TextureType type ("2d")
- The type of Canvas to create.
PixelFormat format ("normal")
- The format of the Canvas.
boolean readable
- Whether the Canvas is readable (drawable and accessible in a Shader). True by default for regular formats, false by default for depth/stencil formats.
number msaa (0)
- The desired number of multisample antialiasing (MSAA) samples used when drawing to the Canvas.
number dpiscale (love.graphics.getDPIScale())
- The DPI scale factor of the Canvas, used when drawing to the Canvas as well as when drawing the Canvas to the screen.
MipmapMode mipmaps ("none")
- Whether the Canvas has mipmaps, and whether to automatically regenerate them if so.
Returns
Canvas canvas
- A new Canvas with specified width and height.
Notes
Some Canvas formats have higher system requirements than the default format. Use love.graphics.getCanvasFormats to check for support.
Function
Available since LÖVE 11.0 |
This variant is not supported in earlier versions. |
Creates a volume or array texture-type Canvas.
Synopsis
canvas = love.graphics.newCanvas( width, height, layers, settings )
Arguments
number width
- The desired width of the Canvas.
number height
- The desired height of the Canvas.
number layers
- The number of array layers (if the Canvas is an Array Texture), or the volume depth (if the Canvas is a Volume Texture).
table settings
- A table containing the given fields:
TextureType type ("array")
- The type of Canvas to create.
PixelFormat format ("normal")
- The format of the Canvas.
boolean readable
- Whether the Canvas is readable (drawable and accessible in a Shader). True by default for regular formats, false by default for depth/stencil formats.
number msaa (0)
- The desired number of multisample antialiasing (MSAA) samples used when drawing to the Canvas.
number dpiscale (love.graphics.getDPIScale())
- The DPI scale factor of the Canvas, used when drawing to the Canvas as well as when drawing the Canvas to the screen.
MipmapMode mipmaps ("none")
- Whether the Canvas has mipmaps, and whether to automatically regenerate them if so.
Returns
Canvas canvas
- A new Canvas with specified width and height.
Notes
Not all texture types are supported by all systems. love.graphics.getTextureTypes can check for support.
Function
Available since LÖVE 0.9.0 and removed in LÖVE 11.0 |
This variant is not supported in earlier or later versions. |
Synopsis
canvas = love.graphics.newCanvas( width, height, format )
Arguments
number width (window_width)
- The desired width of the Canvas.
number height (window_height)
- The desired height of the Canvas.
CanvasFormat format ("normal")
- The desired texture format of the Canvas.
Returns
Canvas canvas
- A new Canvas with specified width and height.
Notes
Some Canvas formats have higher system requirements than the default format. Use love.graphics.getCanvasFormats to check for support.
Function
Available since LÖVE 0.9.1 and removed in LÖVE 11.0 |
This variant is not supported in earlier or later versions. |
Synopsis
canvas = love.graphics.newCanvas( width, height, format, msaa )
Arguments
number width (window_width)
- The desired width of the Canvas.
number height (window_height)
- The desired height of the Canvas.
CanvasFormat format ("normal")
- The desired texture format of the Canvas.
number msaa (0)
- The desired number of multisample antialiasing (MSAA) samples used when drawing to the Canvas.
Returns
Canvas canvas
- A new Canvas with specified width and height.
Notes
- Not all texture types are supported by all systems. love.graphics.getTextureTypes can check for support.
- Some Canvas formats have higher system requirements than the default format. Use love.graphics.getCanvasFormats to check for support.
- The supported maximum number of MSAA samples varies depending on the system. Use love.graphics.getSystemLimits to check.
- If the number of MSAA samples specified is greater than the maximum supported by the system, the Canvas will still be created but only using the maximum supported amount (this includes 0.)
See Also
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info