GetMipmapSize
This function returns the size of a texture mipmap's data. This can be used to ensure a buffer's data size is correct when calling Texture::SetPixels().
Syntax
- int GetMipmapSize(int miplevel=0)
Parameters
- miplevel: the mipmap level to return the data size of.
Returns
Returns the size of the data for the specified mipmap level.
Example
#include "Leadwerks.h"
using namespace Leadwerks;
int main(int argc, const char *argv[])
{
Leadwerks::Window* window = Leadwerks::Window::Create();
Context* context = Context::Create(window);
Texture* texture = Texture::Load("Materials/Grass/grass01.tex");
while (true)
{
if (window -> Closed() || window -> KeyDown(Key::Escape)) return false;
context->SetColor(0, 0, 0, 0);
context->Clear();
//Display the textures on screen so we can compare the difference
int x = 2; int y = 22;
context->SetColor(1, 1, 1, 0);
context->SetBlendMode(Blend::Alpha);
context->DrawText(String(texture-> CountMipmaps()) + " mipmaps", 2, 2);
for (int i = 0; i < texture-> CountMipmaps(); i++)
{
context->DrawText("Mipmap " + String(i) + ": " + String(texture->GetMipmapSize(i)) + " bytes", x, y);
y += 20;
}
context->SetBlendMode(Blend::Solid);
context->DrawImage(texture, x, y);
context->Sync();
}
return 0;
}