JOGL demos - what should cg demo show?

Hello,
I’m experimenting with cg and jogl and started by running the included cg demo. My question is, what is this demo supposed to display?

Here’s what I get, when running cgGL_vertex_example I get the output listed at the end of this post, and the frame that opens just displays a black scene.

When I run runtime_ogl_vertex_fragment there is no output, and I see a completely black sphere (not shaded) against a grey background. I think it’s a sphere because by looking at the edges it appears to be rotating, but I can’t tell for sure since it’s not shaded at all.

I am using jogl 1.1.1
I have an NVIDIA GeForce 7600 GS

I’m assuming this isn’t what the demos are supposed to look like. Any advice on figuring out what’s wrong? CG should be compatible with my 3d card because I have been able to run a program written in c++ that uses cg shaders.

I haven’t seen any discussion or screenshots for this demo online or in the documentation so I would really appreciate your help. If anything just a screenshot or description of what the demos are supposed to look like.
Thanks.

Output for cgGL_vertex_example:
LAST LISTING----null----

---- PROGRAM BEGIN ----
!!VP1.1

cgc version 2.1.0016, build date Nov 20 2008

command line args: -q -profile vp20 -entry main

#vendor NVIDIA Corporation
#version 2.1.0.16
#profile vp20
#program main
#semantic main.Kd
#semantic main.ModelViewProj
#var float4 IN.position : $vin.POSITION : ATTR0 : 0 : 1
#var float3 IN.normal : $vin.NORMAL : : 0 : 0
#var float3 IN.color : $vin.DIFFUSE : : 0 : 0
#var float3 IN.TestColor : $vin.SPECULAR : ATTR4 : 0 : 1
#var float4 Kd : : c[4] : 1 : 1
#var float4x4 ModelViewProj : : c[0], 4 : 2 : 1
#var float4 main.HPOS : $vout.POSITION : HPOS : -1 : 1
#var float4 main.COL0 : $vout.COLOR0 : COL0 : -1 : 1
#const c[5] = 1
MUL o[COL0].xyz, v[4], c[4];
DP4 o[HPOS].w, v[0], c[3];
DP4 o[HPOS].z, v[0], c[2];
DP4 o[HPOS].y, v[0], c[1];
DP4 o[HPOS].x, v[0], c[0];
MOV o[COL0].w, c[5].x;
END

6 instructions, 0 R-regs

---- PROGRAM END ----

Did a little reading on CG basics. after playing around with cgGL_vertex_example.cg I changed the main function to


vfconn main(appdata IN,
            uniform float4 Kd,
            uniform float4x4 ModelViewProj)
{
    vfconn OUT;
OUT.HPOS = mul(ModelViewProj, IN.position);
    OUT.COL0 = float4(1,0,0,1);

    return OUT;
} // main


Which renders all vertices red and transforms the cube to the current viewpoint.

When I change the OUT.COL0 assignment to what it is in the demo


OUT.COL0.xyz = Kd.xyz * IN.TestColor.xyz;
OUT.COL0.w = 1.0;

I get the black screen again. Even if I just set OUT.COL0 = IN.TestColor.xyz I get black. It’s like opengl isn’t assigning the TestColor parameter correctly, even though it is assigning the Kd parameter just fine. The jogl code looks correct.


    for(i = 0; i < 6; i++) 
    {
      gl.glBegin(GL.GL_QUADS);

      gl.glNormal3f(CubeNormals[i][0], CubeNormals[i][1], CubeNormals[i][0]);
      CgGL.cgGLSetParameter3f(TestColorParam, 1.0f, 0.0f, 0.0f);
      float[] verts = CubeVertices[CubeFaces[i][0]];
      gl.glVertex3f(verts[0], verts[1], verts[2]);

      CgGL.cgGLSetParameter3f(TestColorParam, 0.0f, 1.0f, 0.0f);
      verts = CubeVertices[CubeFaces[i][1]];
      gl.glVertex3f(verts[0], verts[1], verts[2]);

      CgGL.cgGLSetParameter3f(TestColorParam, 0.0f, 0.0f, 1.0f);
      verts = CubeVertices[CubeFaces[i][2]];
      gl.glVertex3f(verts[0], verts[1], verts[2]);

      CgGL.cgGLSetParameter3f(TestColorParam, 1.0f, 1.0f, 1.0f);
      verts = CubeVertices[CubeFaces[i][3]];
      gl.glVertex3f(verts[0], verts[1], verts[2]);
    
      gl.glEnd();
    }

This noob has some more playing around to do, unless someone has any ideas? :persecutioncomplex:

Tried the cg demo on another computer with a very high end graphics card to see if there was something wrong with my card. The same black screen showed up. So I got wise and thought maybe jogl wasn’t up to date with the latest version of cg (2.1) so I tried the cg 1.5 libraries and it seems to be working now! Thanks for the help me!

Sometimes nobody knows the answer and I think the regular visitors here use GLSL instead of CG with JOGL.