Applying texture to our shape

Now that we're all set up to use the SOIL library, let's go to our triangle code and make the necessary changes to load our shape and apply texture to it. Follow these steps:

  1. So, we'll first include the SOIL library into our code; for that, type in the following line at the start of your code:
#include SOIL2/SOIL2.h

Here, we have typed SOIL2/SOIL2.h because our library is inside the SOIL2 folder.

  1. The next thing we're going to do is enable the alpha support for images with extension such as PNG. To do that, type in the following lines of code after we have defined out glViewport() :
// enable alpha support glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

In the preceding lines of ...

Get Learn OpenGL 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.