   Managing multiple shaders in one program
  Hi, for an OpenGL GUI library I thought the addition of shaders would be pretty nice. However, I'm not really experience with shaders yet. I did play around with it once, so loading and simple using them is no problem, however I need a bit more:I thought of a Shader object, which I can then bind to any GUI element, this Shader object would hold one or more actual OpenGL shaders. However, which functions should I call in which order for OGL?Say, the Shader object starts empty with one GLuint for the program ID and an array of GLuint's for shader ID's. Then, when adding a shader I thought of doing the following steps: - create new array element and store an ID using the glCreateShaderObjectARB function - read the shader source from file / memory - use glShaderSourceARB to set the source - compile using glCompileShaderARB - attach to program using glAttachObjectARBAs for the program object, I thought of this: - whenever Shader is initialised, make a new program object using glCreateProgramObjectARB - use glLinkProgramARB to link the program (is this correct!?) - whenever shaders are added, I use glAttachObjectARB to attach it to the program - when library requests to use the shader, use glUseProgramObjectARBIs this correct? I've read the OpenGL docs, but I'm still unsure about the glLinkProgramARB command, does it matter if I attach new shaders after linking?Also, naming convention is unclear to me. I have WinXP, so should I use the ARB behind every function? And some function names in the doc where slightly different, like 'object' and 'shader' were swapped...Thanks!   
  I have an Effects class. Which I can attach to either an object or the output of an FBO.-> Create Effect Class-> Load Shader Source (my class only supports one set of shader sources)-> Create Program-> Link ProgramThen when I'm rendering an object I doEffect->Enable(Which does glUseProgram(EffectID); )And thenEffect->Disable(Which does glUseProgram(0); )This way I can move my Effect's classes between Models/Objects and Camera outputs.   ;  Should be no need for the arb stuff nowadays. I dont think I've used it for ages. (I guess thats the problem with the internet... everythings so out of date.)As for the nomenclature, I'll have a look at my notes if noone else knows off the top of their head.   ;  Thanks AndyEsser, but would it matter if you linked your program before adding new shaders?Quote:Original post by Simon_RothShould be no need for the arb stuff nowadays. I dont think I've used it for ages. (I guess thats the problem with the internet... everythings so out of date.)As for the nomenclature, I'll have a look at my notes if noone else knows off the top of their head.Thanks!   ;  By new Shaders, I'm assuming you mean Shader source. In which case yes it would matter. You have to load the Shader source first and then link.http://www.opengl.org/sdk/docs/man/xhtml/glLinkProgram.xml   ;Quote:Original post by AndyEsserBy new Shaders, I'm assuming you mean Shader source. In which case yes it would matter. You have to load the Shader source first and then link.http://www.opengl.org/sdk/docs/man/xhtml/glLinkProgram.xmlOkay thanks, I just confirmed that with a test. You must link the program every time you attach a new shader to the program. I did read that site before, but it wasn't clear to me that I had to re-link whenever I attach a new shader.And I also confirmed I can use the OpenGL 2.0 syntax, not the ARB syntax.