Texture wrapping

In the previous section, we used texParameteri to set the filter mode for textures, but as you might expect from the generic function name, that's not all that it can do. Another texture behavior that we can manipulate is the texture wrapping mode.

Texture wrapping describes the behavior of the sampler when the texture coordinates fall outside the range of 0-1.

The wrapping mode can be set independently for both the S and T coordinates, so changing the wrapping mode typically takes two calls:

gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);

Here we're setting both the S and T wrapping modes for the currently bound texture to CLAMP_TO_EDGE, the effects of which we will see in a moment.

As with texture filters, it's easiest to demonstrate the effects of the different wrapping modes via an example and then discuss the results. Let's open up your browser again for another demonstration.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.218.230