Skip to content

Textures

TechnologicalTurtle edited this page Jul 20, 2026 · 5 revisions

Texture

LibGui::Texture class is used to render images on objects, it can be initialized in two ways:

Initialization

From LibGui::Image

You can create texture from an LibGui::Image like this:

LibGui::Texture MyTexture(MyImage);

// if you want pixelart (or something pixelated), specify it with smoothed = false
LibGui::Texture MyTexture(MyImage, false);

// you can also set your custom texture slot (if you know what are you doing)
LibGui::Texture MyTexture(MyImage, false, 4);

// lastly you can decide between GL_CLAMP_TO_BORDER (true) and GL_REPEAT (default, false) too
LibGui::Texture MyTexture(MyImage, false, 4, true);

Loading from file

You can directly load from file, without needing an LibGui::Image like this:

LibGui::Texture MyTexture("cool_turtle_image.png");

// if you want pixelart (or something pixelated), specify it with smoothed = false
LibGui::Texture MyTexture("cool_turtle_image.png", false);

// you can too set your custom texture slot (if you know what are you doing)
LibGui::Texture MyTexture("cool_turtle_image.png", false, 4);

// lastly you can decide between GL_CLAMP_TO_BORDER (true) and GL_REPEAT (default, false) too
LibGui::Texture MyTexture("cool_turtle_image.png", false, 4, true);

Methods

Note

I don't talk about LoadFile and LoadImage, becouse these are just backends for image and file constructors

void Bind()

Binds texture, you don't need it, except if you want to use OpenGL simultaneously with LibGui.

void Unbind()

Unbinds texture, you don't need it, except if you want to use OpenGL simultaneously with LibGui.

unsigned int GetID()

Returns OpenGL texture ID.

Properties

unsigned int texSlot

Texture slot is index of unit, the texture is in. More about in texture units part in here

int nrChannels

nrChannels tells you how much color channels had the file you loaded from.

value means
1 RED
2 RED-GREEN
3 RED-GREEN-BLUE
4 RED-GREEN-BLUE-ALPHA

Vec2i size

Size of texture in pixels.

Clone this wiki locally