GetWidth

This function gets the width of a texture.

Syntax

Parameters

Returns

Returns the width of 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);
World* world = NULL;

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

//Set texture properties
texture->SetClampMode(true, true);
texture->SetFilter(Texture::Smooth);


while (true)
{
if (window->Closed() || window->KeyDown(Key::Escape)) return false;
context->SetColor(0, 0, 0, 0);
context->Clear();

//Display texture properties
context->SetColor(1, 1, 1, 0);
context->SetBlendMode(Blend::Alpha);

int x = 2, y = 2;
context->DrawText(String(texture->CountMipmaps()) + " mipmaps", x, y); y += 20;
context->DrawText("Clamp mode: " + String(texture->GetClampMode(0)) + ", " + String(texture->GetClampMode(1)), x, y); y += 20;
context->DrawText("Filter: " + String(texture->GetFilter()), x, y); y += 20;
context->DrawText("Format: " + String(texture->GetFormat()), x, y); y += 20;
context->DrawText("Size: " + String(texture->GetWidth()) + " x " + String(texture->GetHeight()), x, y); y += 20;

context->SetBlendMode(Blend::Solid);
context->DrawImage(texture, 0, y);

context->Sync();
}
return 0;
}