dtk_load_image(3) Load an image file as a texture

SYNOPSIS

#include <drawtk.h>

dtk_htex dtk_load_image(const char *filename, unsigned int mxlvl);

DESCRIPTION

This function load the image file specified by filename argument. It will creates the mipmaps until level mxlvl. Upon creation, the texture will then been tracked by an internal texture manager so that the next call using the same filename argument will return the same texture handle, thus sparing the resources of the system.

There is no need for a valid window to create successfully a texture, i.e. creation of textures are completely decoupled from the creation of others resources and can even be created in one thread to be used in another one.

Mipmaps are version of the same image at lower resolution (every power of two). Mipmap at level 0 is the original image. Given the size of the texture displayed in the framebuffer, the closest mipmaps are used to interpolate the value of displayed pixels. Do a research on internet for further details about mipmaps.

RETURN VALUE

In case of success, the function returns the handle to the created texture. In case of failure, NULL is returned.

THREAD SAFETY

dtk_load_image() is thread-safe.