Drawing a 2D image in a window using the fragment shader and the SOIL image loading library
We will wrap up this chapter with a recipe for creating a simple image viewer in the OpenGL v3.3 core profile using the
SOIL image loading library.
After setting up the Visual Studio environment, we can now work with the SOIL library. The code for this recipe is in the
How to do it…
Let us now implement the image loader by following these steps:
- Load the image using the
SOILlibrary. Since the loaded image from
SOILis inverted vertically, we flip the image on the Y axis.
int texture_width = 0, texture_height = 0, channels=0; GLubyte* pData = SOIL_load_image(filename.c_str(), &texture_width, &texture_height, &channels, ...