Difference between revisions of "love.graphics.getCanvasFormats"

m (0.11.0 -> 11.0)
m
 
Line 9: Line 9:
 
None.
 
None.
 
=== Returns ===
 
=== Returns ===
{{param|table|formats|A table containing [[CanvasFormat]]s as keys, and a boolean indicating whether the format is supported as values. Not all systems support all formats.}}
+
{{param|table|formats|A table containing [[PixelFormat]]s as keys, and a boolean indicating whether the format is supported as values. Not all systems support all formats.}}
  
 
== Function ==
 
== Function ==
Line 20: Line 20:
 
{{param|boolean|readable|If true, the returned formats will only be indicated as supported if [[love.graphics.newCanvas]] will work with the [[Texture:isReadable|readable]] flag set to true for that format, and vice versa if the parameter is false.}}
 
{{param|boolean|readable|If true, the returned formats will only be indicated as supported if [[love.graphics.newCanvas]] will work with the [[Texture:isReadable|readable]] flag set to true for that format, and vice versa if the parameter is false.}}
 
=== Returns ===
 
=== Returns ===
{{param|table|formats|A table containing [[CanvasFormat]]s as keys, and a boolean indicating whether the format is supported as values (taking into account the readable parameter). Not all systems support all formats.}}
+
{{param|table|formats|A table containing [[PixelFormat]]s as keys, and a boolean indicating whether the format is supported as values (taking into account the readable parameter). Not all systems support all formats.}}
  
 
== Examples ==
 
== Examples ==
Line 47: Line 47:
 
== See Also ==
 
== See Also ==
 
* [[parent::love.graphics]]
 
* [[parent::love.graphics]]
* [[CanvasFormat]]
+
* [[PixelFormat]]
 
* [[love.graphics.newCanvas]]
 
* [[love.graphics.newCanvas]]
 
* [[Canvas]]
 
* [[Canvas]]
 
[[Category:Functions]]
 
[[Category:Functions]]
 
{{#set:Sub-Category=SystemInfo}}
 
{{#set:Sub-Category=SystemInfo}}
{{#set:Description=Gets the available [[CanvasFormat|Canvas formats]], and whether each is supported.}}
+
{{#set:Description=Gets the available [[PixelFormat|Canvas formats]], and whether each is supported.}}
 
== Other Languages ==
 
== Other Languages ==
 
{{i18n|love.graphics.getCanvasFormats}}
 
{{i18n|love.graphics.getCanvasFormats}}

Latest revision as of 16:11, 28 December 2020

Available since LÖVE 0.9.2
This function is not supported in earlier versions.

Gets the available Canvas formats, and whether each is supported.

Function

Synopsis

formats = love.graphics.getCanvasFormats( )

Arguments

None.

Returns

table formats
A table containing PixelFormats as keys, and a boolean indicating whether the format is supported as values. Not all systems support all formats.

Function

Available since LÖVE 11.0
This variant is not supported in earlier versions.

Synopsis

formats = love.graphics.getCanvasFormats( readable )

Arguments

boolean readable
If true, the returned formats will only be indicated as supported if love.graphics.newCanvas will work with the readable flag set to true for that format, and vice versa if the parameter is false.

Returns

table formats
A table containing PixelFormats as keys, and a boolean indicating whether the format is supported as values (taking into account the readable parameter). Not all systems support all formats.

Examples

Create a canvas with the format 'rgba16f' if it is supported

local formats = love.graphics.getCanvasFormats()
if formats.rgba16f then
    canvas = love.graphics.newCanvas(800, 600, "rgba16f")
else
    -- The 'rgba16f' format isn't supported. We could have some fallback code, or trigger a message telling the user their system is unsupported.
end

Display a list of the canvas formats on the screen

canvasformats = love.graphics.getCanvasFormats()

function love.draw()
    local y = 0
    for formatname, formatsupported in pairs(canvasformats) do
        local str = string.format("Supports format '%s': %s", formatname, tostring(formatsupported))
        love.graphics.print(str, 10, y)
        y = y + 20
    end
end

See Also


Other Languages