PEXCreateMipmapTMFromResources - Create Mipmap Color Texture Map From Resources (5.2)


Synopsis

 
   PEXTextureMap PEXCreateMipmapTMFromResources(
             Display *display,
             int dimensionality,
             int texel_type,
             Drawable drawable,
             unsigned short luminance_channel,
             unsigned short alpha_channel,
             int num_levels,
             PEXTexelDimension *dimensions,
             XID *color_data,
             XID *alpha_data
       )

Arguments

display
A pointer to a display structure returned by a successful XOpenDisplay call.

dimensionality
The dimension of the texture map (PEXTMDimension1D, PEXTMDimension2D, or PEXTMDimension3D).

texel_type
The type of texel data in the mipmap (PEXTexelTypeLum, PEXTexelTypeLum8, PEXTexelTypeLum16, PEXTexelTypeLumA, PEXTexelTypeLumA8, PEXTexelTypeLumA16, PEXTexelTypeRGB, PEXTexelTypeRGB8, PEXTexelTypeRGB16, PEXTexelTypeRGBA, PEXTexelTypeRGBA8 or PEXTexelTypeRGBA16).

drawable
An example drawable indicating the visual type of the resources.

luminance_channel
Indicates source of data used to form luminance data (PEXTMChannelRed, PEXTMChannelGreen, PEXTMChannelBlue or PEXTMChannelNTSC).

alpha_channel
Indicates source of data used to form alpha data (PEXTMChannelRed, PEXTMChannelGreen, PEXTMChannelBlue or PEXTMChannelNTSC).

num_levels
The number of levels in the mipmap.

dimensions
Specifies the dimensions in each direction of each level of the mipmap.

color_data
List of IDs of the resources data is taken from to form texture map.

alpha_data
List of IDs of the resources data from which data is taken to form alpha component of texture map, if alpha is part of the indicated texel type.

Returns

The resource ID for a PEX Texture Map.

Description

Invoke PEXCreateMipmapTMFromResources to create a mipmap texture resource that you can reference from a texture mapping LUT.

If the texture map is one-dimensional, then one color resource and, optionally, one alpha resource define each level of the texture map, starting with the base level. Texture coordinate t0 = 0.0 corresponds to the lower lower-left of the image defined by the resource. Subsequent texel values are taken from the bottom row of the resource along the x direction. The rows of the resource are conceptually wrapped, so it is possible for a texture map level's dimension to exceed the x dimension of the resource. The wrapping occurs by moving up to the left end of the next higher row as each row is exhausted.The dimension of each level of the texture map is defined by argument dimension, which is an array with a member for each level of the texture map. The texture map coordinates are normalized, so the first through c0th texel, where c0 is the t0 dimension, correspond to the t0 coordinate range from 0.0 to 1.0.

In the two-dimensional texture map case, again one color resource, and optionally one alpha resource, defines each level of the texture map, starting with the base level. Texture map coordinate t0 = t1 = 0.0 corresponds to the lower-left of the image defined by the source. The x direction of the resource corresponds to the t0 direction of the texture map. The texture map dimensions for a given level cannot exceed the corresponding resource dimensions.

In the three-dimension texture map case, c2 color resources, and optionally c2 alpha resources, define each level of the texture map. c2, defined by argument dimension for each level, is the third dimension of the level. The c2 resources defining each level are ordered from t2 = 0.0 to t2 = 1.0. All c2 resources defining the base level are given first, followed by all the resources defining the next level, and so on.

The dimensionality argument indicates the dimension of the texture map. The list of color and alpha resource IDs provides the actual texel data. The visual of the drawable specified by drawable indicates the source texel format.

Texel_type indicates the texel components of the newly created texture resource. If the texel_type indicates luminance is included, then luminance_channel indicates whether one of three channels of RGB are given as luminance data, or if all three channels are combined into a single luminance value. If the texel_type indicates that the luminance is not included (in the destination texels), then the implementation ignores the luminance_channel. If the texel_type indicates alpha is included, then the alpha_channel argument indicates whether one of three channels of RGB are given as alpha data, or if all three channels are combined into a single alpha value. If the texel_type indicates that alpha is not included, then the implementation ignores alpha_data and alpha_channel.

PEXlib defines the following values for the channel selection constants (luminance_channel and alpha_channel):

PEXTMChannelRed
selects the red channel. (5.2)

PEXTMChannelGreen
selects the green channel. (5.2)

PEXTMChannelBlue
selects the blue channel. (5.2)

PEXTMChannelNTSC
indicates the three channels of red, green and blue are to be combined into a single luminance or alpha value using the NTSC encoded values as follows:
0.299*red + 0.587*green + 0.114*blue (5.2)

Inquire MaxFastTMSize with the function PEXGetImpDepConstants to determine whether there is a maximum size for any dimension on the base level which must be respected to achieve optimized implementation. If PEX has such a limit, it treats larger texture maps in an implementation-dependent way. PEX implementations may have other restrictions on the dimensions of each level of the texture map. Inquire PowerOfTwoTMRequired with PEXGetImpDepConstants to determine if each dimension must be a power of two. Inquire SquareTMRequired with the same request to determine if all the dimensions on each level must be equal to one another.

Drawable indicates the visual of the resources. Both the color_data and alpha_data resources must be of the same visual class. If the visual is of class PseudoColor, then the colormap associated with the drawable is used to determine the color values. The visual indicates the source texel format.

Not all resource types are supported for creating texture map resources. PEXlib defines the following texel resources. Invoke PEXGetEnumTypeInfo to determine which resources types your implementation supports.

PEXWindowResource
The supplied resource is a mapped window. Treatment of obscured portions of the window is implementation-dependent if there is no backing store for the window. Consistent results require a completely unobscured window. (5.2)

PEXPixmapResource
The supplied resource is a pixmap. (5.2)

PEXBufferResource
The supplied resource is a MBX buffer. If the buffer is currently displayed, treatment of obscured portions is implementation-dependent if there is no backing store for the buffer. Consistent results require a completely unobscured buffer. (5.2)

PEXPhotomapResource
The supplied resource is an XIE Photomap. (5.2)

Once this function returns, all texel data source resources may be reused for other purposes

Errors

BadAlloc
The implementation failed to allocate the resource necessary to complete request.

BadDrawable
drawable is invalid.

BadMatch
A specified resource does not contain luminance data appropriate to the texel type and channel.

BadMatch
A specified resource does not contain alpha data appropriate to the texel type and channel.

BadMatch
A specified resource is of an unsupported type.

BadMatch
A pixmap is not a valid example drawable for this request.

BadValue
The specified texture map dimension is not valid.

BadValue
The specified texture map texel type is not valid.

BadValue
The specified number of resources does not match the number of resources expected.

BadValue
The texture map size is required to be a power of two.

BadValue
The texture map size is required to be square.

BadValue
Luminance channel value or alpha channel value is invalid.

See Also

For a list of related topics and for a list of all texture mapping functions, see Texture Mapping.