Implementing the twirl filter using the fragment shader
We will use a simple image manipulation operator in the fragment shader by implementing the twirl filter on the GPU.
This recipe builds up on the image loading recipe from Chapter 1, Introduction to Modern OpenGL. The code for this recipe is contained in the
How to do it…
Let us get started with the recipe as follows:
- Load the image as in the
ImageLoaderrecipe from Chapter 1, Introduction to Modern OpenGL. Set the texture wrap mode to
int texture_width = 0, texture_height = 0, channels=0; GLubyte* pData = SOIL_load_image(filename.c_str(), &texture_width, &texture_height, &channels, SOIL_LOAD_AUTO); int i,j; for( j = 0; j*2 < texture_height; ...