GL 2.0 and programmable pipelines

Well, a surely simple question, but as I never made any shaders, I wonder many things.

If I have a gl 2.0 implementation on my computer, does it mean I’ll be able to use GLSL instead of Cg or HLSL ? Or does GLSL is inside older versions (like 1.5) ?

Now, how to use GLSL ? Should I use vertex/fragment programs ? Do I need any extra compiler (like for Cg) ?

Originally posted by jide:
[b]Well, a surely simple question, but as I never made any shaders, I wonder many things.

If I have a gl 2.0 implementation on my computer, does it mean I’ll be able to use GLSL instead of Cg or HLSL ? Or does GLSL is inside older versions (like 1.5) ?

Now, how to use GLSL ? Should I use vertex/fragment programs ? Do I need any extra compiler (like for Cg) ?[/b]
Yes as part of 2.0 core, yes and yes, as an extension.

Pretty much, get some examples you can send the program in as a string and tell the API you have a glslang vertex of fragment program. You need to write glslang programs for vertex and fragment shader objects, link them in a shader and use the shader. No you don’t need an extra compiler, it’s part of the driver, get the API entry points and you’re good to go, just like the ARB assembly style programs.

Thanks a lot for your precisions. I wondered many things and that mades me be confused.

So I can directly include a shader code inside any program (I mean I’m not obliged to create an extra file for those shaders, isn’t it ?).

GLSL shader is like HLSL, It’s only a piece of codes.

You should create ShaderObjects . and a ProgramObject. then provide the source code(just charator string) for the ShaderObjects. as C/C++ program. now you should COMPILE and LINK the ShaderObjects.
If all thinks get ok. you can get a executale ProgramObject. install the ProgramObject whenever you need it.

Thank you. Well, do you mean that I can ‘prebuild’ all the shaders, then keep them in a binary format, then reuse them as I wish ? Another thing, do shaders could be compiled during run-time (or best loading time), or is it a big no no ?

So I can directly include a shader code inside any program (I mean I’m not obliged to create an extra file for those shaders, isn’t it ?)
Of course you can. It’s basically ASCII text.

Well, do you mean that I can ‘prebuild’ all the shaders, then keep them in a binary format
Precompiling is not yet available for GLSL.
Compiling GLSL code is not too expensive. It seems to take about 0.01 seconds for small to medium sized shaders (100 lines), 2 GHz CPU.

I would compile at load time when possible. Some people build dynamically because they have to or they need to have 600 shaders.

I thought this was the GPU that compiles the shaders but I saw that I’m wrong. In fact, this is the cpu that transforms the high-level code into the instructions directly manageable by the pipeline virtual machine (vertex or fragment). Is that true ?

Yes but the distinction is invisible when you send in the strings, the ‘driver’ does it. It is basically a compiler running on the CPU that generates the program that gets loaded to the GPU.