How to get started with vertex and pixel shader

Hi,
Could someone please show me the basics of using vertex and pixel shaders with OpenGL on Windows?

I do not want to use Cg right now. All I want to know is what program compiles the assembler instructions, and what OpenGL functions are used to call the programs and run them right now. Are there ARB functions for vertex and pixel shaders for all Nvidia (Geforce3+) and ATI cards that are standard?

Thanks

Ok maybe my question was too vague (or everybody is too busy writing some code).

I have a book ShaderX but, of course, it is for DirectX, but I think DirectX is for panzies and like OpenGL better.

However I have no idea how to compile the assembler instructions for OGL or what OpenGL functions are used to set the vertex and pixel shader programs to activate.

I didn’t mean teach me how to make them just what program is used to compile and what functions are used to run in OpenGL :slight_smile:

Thanks

Vertex and fragment programs (e.g. GL_ARB_VERTEX_PROGRAM, GL_ARB_FRAGMENT_PROGRAM and NV equivalents) introduce new OpenGL functions through the extension mechanism.

These new functions are used to load and “compile” the code - there’s no separate compiler. For example, to define and use a pixel shader (fragment program) you would first write your fp source code (per your book) in a text string or file. Then, create a shader program and load it using the following (extension) functions:

glGenProgramsARB(); // generates a “name”
glBindProgramARB(); // bind to the above name
glProgramStringARB(); // load fragment program source code
glEnable(GL_FRAGMENT_PROGRAM_ARB); // enable shader

You can see similarities with texture objects? Once you’ve loaded all of your programs, you bind to whichever you want and enable it.

There are similar functions for vertex programs.

Does this help?

Yes I appreciate. I knew it was extensions (I am not a noob) I just didn’t know which extensions (read on).

I have a GF3 Ti500 and a Radeon 8500. Both are really nice, I like them, especially as I got them for free.

Anyways, neither support ARB_fragment_programs.

I loaded Cg onto the Radeon machine, and, none of the Cg examples will work on it.
HAHA!

I’ve looked at the examples at Nvidia and ATI and of course they do it all different ways in OpenGL using proprietary extensions.

It’s just that I would prefer not to have so many branches in my code to support so many different combinations. It’s bad enough to have to support Pentium 4, 3, 2, Athlon, MMX, 3DNow!, Windows, Linux, Macintosh, but now I got to also suport Geforce < 3, GF3, GF4, Radeon 8000, Radeon 9000, Geforce FX. Yack. Might as well go back to programming in DOS or something hehe…

Thanks for the help.

Ahh oops no, it seems ARB_fragment_programs is identical to ARB_vertex_programs :slight_smile:

Ok that makes it a little easier I guess.

But, in retrospect, supposedly the Cray C compilers had something like 10^18 optimization combinations. Now imagine optimizing for that! That is a boatload of combinations to deal with! a few dozen video cards and cpu types is really nothing compared to that.

See yah.