CG flow in Jogl

Hello!

ive been trying to use CG within JOGL and im getting a tad confused and i have a few questions to ask about CG, primarily Vertex Shaders and the overall flow of things…

Ive been looking for another place to post them although the Nvidia site has no tutorials its just full of presentations showing what you can do with CG… so here i am asking you guys!

Here are some things that puzzle me, im sure its not powered by magic so some simple answers would be great:


- In a CG file you have a main() when does this get run? is it whenever a vertex is rendered... i.e: gl.glVertex() is called within glBegin()?
- Ive noticed in alot of tutorials they are using pxxx : POSITION, cxxx : COLOR0... But for some reason they dont BIND position in the app to pxxx inside the shader, so does it just KNOW to get the position from the glVertex() calls? (an example of this: jogl-demos\src\demos\cg\runtime_ogl)
- Whenever you go to render you bind the program, enable the profile, render, disable profile. Before this you load up the program or compile then load it. Logically this seems ok to me, however when i do this, it just doesnt display anything. HOWEVER this is what is puzzling me, i commend out the binding, enabling, disabling... and just call:
 gl.glEnable(GL.GL_DEPTH_TEST);
        gl.glTranslatef(vPosition.fX, vPosition.fY, vPosition.fZ);
        gl.glRotatef(fRotation, 1.0f, 0.5f, 0.1f); 
        gl.glBegin(GL.GL_LINES);
           
            CgGL.cgGLSetParameter3f(VertColor, 0.0f,1.0f,0.0f);                                   
            gl.glVertex3f(vVerts[0].fX, vVerts[0].fY, vVerts[0].fZ);    // Top Right Of The Quad (Top)
            gl.glVertex3f(vVerts[1].fX, vVerts[1].fY, vVerts[1].fZ);    // Top Left Of The Quad (Top)
            gl.glVertex3f(vVerts[2].fX, vVerts[2].fY, vVerts[2].fZ);    // Bottom Left Of The Quad (Top)
            gl.glVertex3f(vVerts[3].fX, vVerts[3].fY, vVerts[3].fZ);    // Bottom Right Of The Quad (Top)

 gl.glEnd();
        gl.glDisable(GL.GL_DEPTH_TEST); 

and it does what its meant to… it sets the color, i even for a laugh made the output position be the color… so this is the code in the shader file… just for a laugh i changed it to:

// vertex shader main entry
VertOut main(VertIn IN, uniform float4x4 modelViewProj) 
{
    VertOut OUT;
    OUT.position = IN.color;
    OUT.color    = IN.color;
    return OUT;
}

I thought that this wouldnt matter as im not binding the program or enabling the profile, but it displays it with wierd lines… like it should do. So why does it work how its meant to when the code is commented out and shouldnt work…?


Thanks for anyone who can take time out to help me with this…

if there is a better place to ask these questions can someone let me know the link… as im sure there must be a pureCG community somewhere… Just cant seem to find it… the one all the sites reference are www.cgshaders.org but this is just an ads page now…

Sorry to bump this but im still a tad baffled by it all and there seem to be very little good CG communities/examples out there… i would have thought with the recent CG deal with PS3 that there would be communities popping up everywhere… The only resources that seem to be plentiful are HLSL, but HLSL is only for DirectX as far as i know? but they are both effectivley the same code… Or should i go with GLSL as thats meant to OpenGL… but i dont want to be limited to only have support for one rendering type…