CountMipmaps

This function gets the number of mipmaps a texture contains.

Syntax

Returns

Returns the number of mipmaps the texture contains.

Example

window = Window:Create()
context = Context:Create(window)

--Load a texture
texture = Texture:Load("Materials/Grass/grass01.tex")

while true do
if window:Closed() or window:KeyHit(Key.Escape) then return false end

context:SetColor(0,0,0)
context:Clear()

--Display the textures on screen so we can compare the difference
local x = 2 local y = 22
context:SetColor(1,1,1)
context:SetBlendMode(Blend.Alpha)

context:DrawText(texture:CountMipmaps() .. " mipmaps",2,2)
for i = 0, texture:CountMipmaps()-1 do
context:DrawText("Mipmap " .. i .. ": " .. texture:GetMipmapSize(i) .. " bytes",x,y)
y = y + 20
end

context:SetBlendMode(Blend.Solid)
context:DrawImage(texture,x,y)

context:Sync()
end