DemoGL::Reference::Functions::DEMOGL_TextureLoad

DEMOGL_TextureLoad

DEMOGL_TextureLoad creates a new texture in the texture store of DemoGL from the data loaded from the file with the filename pointed by pszFilename.

GLuint
DEMOGL_TextureLoad(
	const char *pszFilename,
	const int iFileType,
	const int iDepth,
	const GLint iWrapS, 
	const GLint iWrapT,
	const GLint iMinFilter,
	const GLint iMagFilter,
	const bool bMipMaps,	
	const bool bCreateAlphaFromColor,	
	const int iBorder,
	const GLint iTexUploadHint,
	const int iDimensions
);
	
Parameters.
pszFilename
Pointer to a zero-terminated string which contains the filename, inclusive relative path, that contains the texturedata.
iFileType
Specifies the filetype used in the file specified with pszFilename. iFileType can be one of the following values:

FileType Description
DGL_FTYPE_JPGFILE Imagedata stored using the JPEG format.
DGL_FTYPE_TGAFILE Imagedata stored using the TGA format.
DGL_FTYPE_BMPFILE Imagedata stored using the BMP format.
DGL_FTYPE_DDSFILE Imagedata stored using the DDS format (DirectX compressed: DXT1, DXT3 or DXT5 format).

iDepth
Specifies the depth of the texture, which pixeldata is stored in the buffer pointed by pbyBuffer in pixels. This is the 3rd dimension of the texture. For 2D textures, specify 0. 3D texture support is implemented in DemoGL allthough not directly usable due to the lack of OpenGL 1.2 functionality in the Windows implementation of OpenGL.
iWrapS
Sets the wrap parameter for texture coordinate s to either GL_CLAMP or GL_REPEAT. GL_CLAMP causes s coordinates to be clamped to the range [0,1] and is useful for preventing wrapping artifacts when mapping a single image onto an object. GL_REPEAT causes the integer part of the s coordinate to be ignored; OpenGL uses only the fractional part, thereby creating a repeating pattern. Border texture elements are accessed only if wrapping is set to GL_CLAMP. Initially, GL_TEXTURE_WRAP_S is set to GL_REPEAT.
iWrapT
As iWrapS but now for texture coordinate t.
iMinFilter
Sets the texture minifying function. Can be one of the following values:

Value Meaning
GL_NEAREST Returns the value of the texture element that is nearest (in Manhattan distance) to the center of the pixel being textured.
GL_LINEAR Returns the weighted average of the four texture elements that are closest to the center of the pixel being textured. These can include border texture elements, depending on the values of iWrapS, iWrapT, and on the exact mapping. GL_NEAREST is generally faster than GL_LINEAR, but it can produce textured images with sharper edges because the transition between texture elements is not as smooth.
GL_NEAREST_MIPMAP_NEAREST Chooses the mipmap that most closely matches the size of the pixel being textured and uses the GL_NEAREST criterion (the texture element nearest to the center of the pixel) to produce a texture value.
GL_LINEAR_MIPMAP_NEAREST Chooses the mipmap that most closely matches the size of the pixel being textured and uses the GL_LINEAR criterion (a weighted average of the four texture elements that are closest to the center of the pixel) to produce a texture value.
GL_NEAREST_MIPMAP_LINEAR Chooses the two mipmaps that most closely match the size of the pixel being textured and uses the GL_NEAREST criterion (the texture element nearest to the center of the pixel) to produce a texture value from each mipmap. The final texture value is a weighted average of those two values.
GL_LINEAR_MIPMAP_LINEAR Chooses the two mipmaps that most closely match the size of the pixel being textured and uses the GL_LINEAR criterion (a weighted average of the four texture elements that are closest to the center of the pixel) to produce a texture value from each mipmap. The final texture value is a weighted average of those two values.

iMagFilter
Sets the texture magnification function. The texture magnification function is used when the pixel being textured maps to an area less than or equal to one texture element. It sets the texture magnification function to either GL_NEAREST or GL_LINEAR.
bMipMaps
Specifies if DemoGL should create mipmaps from the supplied texture data (true) or not (false).
bCreateAlphaFromColor
Specifies if DemoGL should fill in the Alpha byte in the RGBA value for each pixel using a luminance formula (true) or that it should fill in 0xFF as alpha value, if the texture loaded doesn't contain an alpha channel (false). The luminance formula used is: Alpha = (0.35 * Red) + (0.45 * Green) + (0.20 * Blue).
iBorder
Specifies the width of the textureborder in OpenGL for this texture, normally 0 or 1.
iTexUploadHint
Specifies the upload hint which should be used when DemoGL uploads the texture data to OpenGL. This hint is ment for the situation when the user has selected 16bit textures ONLY. In this situation normally DemoGL selects GL_RGBA4 as texturehint for the upload process to OpenGL, so you'll get better alphachannel support. If this isn't necessary in a situation, because the texture doesn't use the alphavalues, you can specify an overruling hint for DemoGL to pass on to OpenGL in 16bit. A good hint for nonalpha textures is GL_RGB5_A1. In situations where the user has selected 32bit textures (recommended, since the driver will transform these to 16bit if necessary and will dither, which gives better results) this hint is ignored and GL_RGBA8 is used. If DemoGL should use the default hint for this texture whenever it has to, set iTexUploadHint to DGL_TEXHINT_USEDEFAULT.
iDimensions
Specifies the amount of dimensions of the texture, needed for the upload process of the texture data to OpenGL. Can be one of the following values: DGL_TEXTUREDIMENSION_1D for 1D textures (only iWidth is used), DGL_TEXTUREDIMENSION_2D for 2D textures (only iWidth and iHeight are used) or DGL_TEXTUREDIMENSION_3D for 3D textures, which is currently not implemented in full in DemoGL.

Return values.
If the function succeeds, it returns the TextureID, or texture name, usable with functions in OpenGL like glBindTexture.
If the function failes, 0 is returned.

Remarks.
Support for 3D textures is not fully implemented in DemoGL due to the lack of OpenGL 1.2 support in the Windows OpenGL implementation. When you load a texture with a filename the same as pszFilename DemoGL will increase the reference counter to the loaded texture instead of loading the texturedata again. When you load a DDS file as a texture, be sure that the data in the texture is stored in one of the following formats: DXT1, DXT3 or DXT5. A DDS file is stored upside down, and will not be reverted, so when you're texturing geometry using a texture which was loaded from a DDS file, be sure to flip along the horizontal axis. When a DDS texture is loaded, bCreateAlphaFromColor is ignored. When available, DemoGL will create hardware generated mipmaps, if bMipMaps is set to true

When loading a DDS file, the hardware has to support compressed textures, thus has to support the GL_ARB_texture_compression or GL_EXT_texture_compression extension.

Example.

Requirements.
DemoGL v1.3 (build 0112 or higher). For DDS file support: DemoGL v1.31 (build 0528 or higher) and support for compressed textures in hardware.

See also.
DEMOGL_TextureDelete, DEMOGL_TextureUnUpload, DEMOGL_TextureUpload

Last changed on 28-may-2001

©1999-2001 Solutions Design