Difference between revisions of "love.graphics.getTextureFormats"

(Created page)
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{newin|[[12.0]]|120|type=function}}
+
{{newin|[[12.0]]|120|type=function|text=It has replaced [[love.graphics.getImageFormats]] and [[love.graphics.getCanvasFormats]]}}
 
Gets the available [[PixelFormat|pixel formats]], and whether each is supported for the given [[Texture]] usage configuration.
 
Gets the available [[PixelFormat|pixel formats]], and whether each is supported for the given [[Texture]] usage configuration.
 
== Function ==
 
== Function ==
Line 17: Line 17:
 
=== Create a canvas with the format 'rgba16f' if it is supported ===
 
=== Create a canvas with the format 'rgba16f' if it is supported ===
 
<source lang="Lua">
 
<source lang="Lua">
local formats = love.graphics.getPixelFormats({canvas=true})
+
local formats = love.graphics.getTextureFormats({canvas=true})
 
if formats.rgba16f then
 
if formats.rgba16f then
 
     canvas = love.graphics.newCanvas(800, 600, {format="rgba16f"} )
 
     canvas = love.graphics.newCanvas(800, 600, {format="rgba16f"} )
Line 36: Line 36:
 
{{#set:Description=Gets the available [[PixelFormat|pixel formats]], and whether each is supported for the given [[Texture]] usage configuration.}}
 
{{#set:Description=Gets the available [[PixelFormat|pixel formats]], and whether each is supported for the given [[Texture]] usage configuration.}}
 
== Other Languages ==
 
== Other Languages ==
{{i18n|love.graphics.getPixelFormats}}
+
{{i18n|love.graphics.getTextureFormats}}

Latest revision as of 00:08, 12 June 2024

Available since LÖVE 12.0
It has replaced love.graphics.getImageFormats and love.graphics.getCanvasFormats.

Gets the available pixel formats, and whether each is supported for the given Texture usage configuration.

Function

Synopsis

formats = love.graphics.getTextureFormats( usage )

Arguments

table usage
A table containing fields describing how the pixel formats will be used.
boolean canvas
If true, the returned formats will only be listed as supported if they can be used with a canvas-capable Texture.
boolean readable (nil)
If true, the returned formats will only be listed as supported if they can be used with the readable flag set to true for a Texture using that format, and vice versa if the field is false. When the field is nil, color pixel formats are assumed to be readable and depth/stencil formats are non-readable.
boolean computewrite (false)
If true, the returned formats will only be listed as supported if they can be used with the computewrite flag set to true for a Texture using that format.

Returns

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

Examples

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

local formats = love.graphics.getTextureFormats({canvas=true})
if formats.rgba16f then
    canvas = love.graphics.newCanvas(800, 600, {format="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

See Also


Other Languages