we will load an image using an image loader.
In the template code, there is a helper class CTexture. We can use it load a texture like this:
our VBO, we can include texture coordinates as vertex attributes. For example, interleaved attributes:
- The method Load() will
generate a texture object, bind the texture, and transfer it to the GPU
the VBO is highly configurable and could include additional vertex
attributes. In the template, the VBO
- Texture coordinate
the fragment shader, we will use a sampler to
read texels at different fragment locations.
On the client side, we must indicate which texture unit the sampler will
use. For example:pMainProgram->SetUniform("sampler0", 0);
This will instruct the sampler “sampler0” in
the fragment shader to use texture unit 0 (more on this later).
rendering, we must bind the texture to make it active:m_texture.Bind();
occurs with the function glDrawArrays()
one of its variants.