Texture Coordinates

Texture coordinates are the coordinates within the texture at which to sample the image. These are often supplied per vertex, and then interpolated over the area of the resulting geometry to provide a per-fragment coordinate. This coordinate is used in the fragment shader to read from the texture and retrieve a color from the texture for the resulting fragment. The texture coordinates in the example of Examples 6.7 and 6.8 is supplied by the application, passed to the vertex shader in in_tex_coord, interpolated by OpenGL, and then passed to the fragment shader in vs_tex_coord before being used to read from the texture.

The application side code to set up a simple set of texture coordinates is shown in Example 6.9.

Example ...

Get OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.