Shading Language Library : A C++ wrapper over GLSL

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.

  1. load your code from file to strings
  2. create shader
  3. convert your strings into shader source
  4. compile shader
  5. create program
  6. attach your shader to a program
  7. link
  8. 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.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s