Add love.graphics.newTextureView(basetexture, viewsettings). Requires GLSL4 support.
Add 'viewformats' boolean setting to texture setting tables.
Add Texture:hasViewFormats.
The viewsettings table has the following fields:
format = nil, -- set this to a pixel format to override the base format. It must have the same number of bytes per pixel as the original, and the 'viewformats' setting on the original texture must be true for this to work. Cannot be used for compressed or depth/stencil textures.
type = nil, -- set this to a texture type to override the base texture type. 2d base textures can make [2d, array] views. [array, cube] base textures can make [2d, array, cube] views.
mipmapstart = nil, -- set to a number to use a less detailed mipmap level as a base.
mipmapcount = nil, -- set to a number to override the number of mipmaps in the texture view.
layerstart = nil, -- set to a number to use a specific layer or cube face as a base.
layers = nil, -- set to a number to override the number of layers in an array texture view.
Assigning to and accessing extra shader variables can increase VGPR / wave-variant register usage in shaders, which is often a limiting factor for performance in non-trivial shaders. Accessing the uniforms directly should bypass that.
With this commit you can draw very simple textures.
The following code will showcase it:
```lua
function love.run()
local data = love.image.newImageData(40, 40)
for i = 0,39 do
for j=0,39 do
if i <= 20 then
if j <= 20 then
data:setPixel(i, j, 1, 0, 0, 1)
else
data:setPixel(i, j, 0, 1, 0, 1)
end
else
if j <= 20 then
data:setPixel(i, j, 0, 0, 1, 1)
else
data:setPixel(i, j, 1, 1, 1, 1)
end
end
end
end
local texture
texture = love.graphics.newTexture(data)
return function()
love.event.pump()
for name, a,b,c,d,e,f in love.event.poll() do
if name == "quit" then
if not love.quit or not love.quit() then
return a or 0
end
end
love.handlers[name](a,b,c,d,e,f)
end
love.graphics.origin()
love.graphics.clear()
love.graphics.draw(texture, 50, 500)
love.graphics.present()
end
end
```
The only field currently read from the table is 'defines', which can contain either an array of define names, or name-value pairs.
For example: newShader(file, {defines={"MYFEATURE_ENABLED", MYSETTING=1}})
Fixes#1577