Function Load-Texture-2d
(
load-texture-2d < name > < flags > )
Parameters
name
An ISO 8859-1 string holding the name of the file that should be loaded.
flags
Flags for controlling the texture loading process. Valid flags are listed in table 3.7.
Return values
The function returns t if the texture was loaded successfully. Otherwise nil is
returned.
Description
The function reads an image from the file specified by the parameter name and uploads the image to
OpenGL⢠texture memory (using the glTexImage2D function).
If the GLFW_BUILD_MIPMAPS_BIT flag is set, all mipmap levels for the loaded texture are
generated and uploaded to texture memory.
Unless the flag GLFW_ORIGIN_UL_BIT is set, the origin of the texture is the lower left corner of the
loaded image. If the flag GLFW_ORIGIN_UL_BIT is set, however, the first pixel is the upper left
corner.
For single component images (i.e. gray scale), the texture is uploaded as an alpha mask if the flag
GLFW_ALPHA_MAP_BIT flag is set, otherwise it is uploaded as a luminance texture.
Notes
glfwLoadTexture2D supports the Truevision Targa version 1 file format (.TGA). Supported pixel
formats are: 8-bit gray scale, 8-bit paletted (24/32-bit color), 24-bit true color and 32-bit true color +
alpha.
Paletted images are translated into true color or true color + alpha pixel formats.
The read texture is always rescaled to the nearest larger 2m à 2n resolution using bilinear interpolation,
if necessary, since OpenGL⢠requires textures to have a 2m à 2n resolution.
If the GL_SGIS_generate_mipmap extension, which is usually hardware accelerated, is supported by
the OpenGL⢠implementation it will be used for mipmap generation. Otherwise the mipmaps will be
generated by GLFW in software.
Since OpenGL⢠1.0 does not support single component alpha maps, alpha map textures are converted
to RGBA format under OpenGL⢠1.0 when the GLFW_ALPHA_MAP_BIT flag is set and the loaded
texture is a single component texture. The red, green and blue components are set to 1.0.