How to do it...

To apply a projected texture to a scene, use the following steps:

  1. In the OpenGL application, load the texture into texture unit zero. While the texture object is bound to the GL_TEXTURE_2D target, use the following code to set the texture's settings:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,                  GL_LINEAR); 
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,  
                GL_LINEAR); 
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,  
                GL_CLAMP_TO_BORDER); 
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,   
                GL_CLAMP_TO_BORDER); 
  1. Also within the OpenGL application, set up your transformation matrix for the slide projector and assign it to the uniform ProjectorMatrix. Use the following code to do this. Note that this code makes use ...

Get OpenGL 4 Shading Language Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.