Graphics Reference
In-Depth Information
You can then assign a number of values to properties of the texture, as is also
shown in the functions in Figure 9.1. The set of values to be assigned is the
same for each texture. If you were implementing this in C++, you could use a
class as a way to envision it:
class TextureObject
{
enum minFilter, maxFilter;
enum storageType;
int numComponents;
int numDimensions;
int numS, numT, numP;
void *image;
};
When you want to make that texture object current, you can dock the
texture with the texture port in the context as shown in Figure 9.1. That is, in
C++ you would make that port in the context point to the address of the proper
texture object. The texture parameters would then “flow” from your program
through the context to the actual texture object. From then on, any time you
want to use that texture, the values in its texture object will have been retained,
so you only need to bind (“dock”) it again:
glActiveTexture( GL_TEXTURE0 );
glBindTexture( GL_TEXTURE_2D, texA );
Texture Environments in the Fixed-Function World
Fixed-function OpenGL includes several standard texture operations to deter-
mine how a texture is used in deciding colors for each fragment. Some of the
standard OpenGL options include the texture modes
blend
,
decal
,
modulate
,
and
replace
. In the OpenGL documentation or standard textbooks (for example
[14]) you will see the exact operation that is required for each of these texture
modes, depending on the kind of data the texture represents. For example, if
the texture is RGB color and the mode is
blend
, then you would
1.
Compute the color of the pixel
C
f
without texture considerations.
2.
Compute the color of the pixel
C
t
from pure texture operations.
3.
Compute the color component product
C
(
)
as the color of the
∗−
1
C
f
t
pixel.
If you are using multitexturing, more than one texture is used to compute
the texture color
C
t
.