-
Senior Member
OpenGL Pro
Conditional shader compile
It would be nice to have a possibility to declare #define-like constants from the main app code. This will allow for conditinal compiling of shader code without need for multiply sahders. Like:
App:
glDefineDeclARB(ProgramObject, "ADV_LIGHT");
Shader:
#ifdef ADV_LIGHT
- do some sort of advanced lighting
#else
- simple lighting
#end
I think this possibility will allow better interaction with extensions. For example, nvidia has it's glslang implementation based on cg. One could test the presence of EXT_cg_shader and make use of mixed precision. This could be nice(from my point of view) mechanism for glslang extensions - you can write one shader that would handle everything.
Of cource, a workaround is to manually add #define lines into the code string. But it's not so elegant.
-
Senior Member
OpenGL Guru
Re: Conditional shader compile
Defines already exist. Though you'll have to set up the defines by including extra strings. This is one of the reasons why you pass an array of strings to the compile calls.
-
Senior Member
OpenGL Pro
Re: Conditional shader compile
Oh... Sometimes I'm simply stupid
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules