Those who are learning GLSL and who came from the fixed functionality pipeline, first few days of your learning GLSL must have been a nightmare, there are so many things that could go wrong while writing a GLSL program.
I went through the same phase about 4 months back when I started learning GLSL, after working on about half dozen small indie projects in the now deprecated fixed functionality pipeline.
The first weird thing that you come across when you start doing GLSL is that there is a separate compiler for GLSL, and you are the one who is supposed to compile, and link GLSL programs. Its quite overwhelming when you read it for first time, especially to people who are used to IDE’s, but its quite simple. These are mere function calls which do this thing for you.
Here are the steps which are required in order to make your GLSL program run..
You write your shaders put them in a text file, or a string (because they eventually will be retrieved from the file and passed to GLSL compiler using strings). I would recommend keeping your code in file, because its both easier to debug, and its always a good idea to modularise your code.
- load your code from file to strings
- create shader
- convert your strings into shader source
- compile shader
- create program
- attach your shader to a program
- and use
I used these function calls, and found out, doing all these things every time you write a GLSL program takes a lot of your time,
lets face it, you’re here to do 3D programming, so I would rather concentrate on that instead of spending my time on these things.
So I decided to put the things which are common in a set of classes to make using shaders easier where there are multiple shader programs.
It sure did took me some time to do this, but now its ever easier to add a GLSL program to my existing app program.