Cg problem...

Hi to all!

i have an problem…
some time ago i use one time, simple Cg vertex shader, with position,color and texcoords, and all works propertly…
but now, i cant initialize my vertex shader :frowning:

next i will write problems in comments :wink:


cgProfile = CgGL.cgGLGetLatestProfile(CgGL.CG_GL_VERTEX);
if (cgProfile == CgGL.CG_PROFILE_UNKNOWN
        || cgProfile == CgGL.CG_INVALID_ENUMERANT_ERROR) {

    cgSupport = false;
} else {
//profile will equals int 7001 or CG_PROFILE_VP4

/*
* i have an GeForce 8600 GT and latest nVidia drivers with supporting OpenGL 3
* and CgToolkit 2.1, cg.dll and cgGL.dll i have copy to jre/lib/ext
*/

    cgSupport = true;

    cgContex = CgGL.cgCreateContext();
      cgVertexShader = CgGL.cgCreateProgramFromFile
              (cgContex, CgGL.CG_SOURCE, "CgBasics.cg", cgProfile, "main", null);

// context creates normally
// but:
    try {
        cgVertexShader = CgGL.cgCreateProgramFromStream(cgContex,
                CgGL.CG_SOURCE,new FileInputStream("CgBasics.cg"),cgProfile,"main",null);
    } catch (IOException e) {
        e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
    }

// cgVertexShader will not create even if i use CgGL.CreateProgramFromFile(...)
// result will be equals "null"

    CgGL.cgGLLoadProgram(cgVertexShader);

// and after that step cgVertexProgram will equals null

    cgModelViewProj = CgGL.cgGetNamedParameter(cgVertexShader, "modelViewProj");
}

please help :-\

Have you tried to retrieve any error messages from Cg? Prolific calls to a function similar to that below are highly recommended.


private void checkCgError() {
	int err = CgGL.cgGetError();
		
	if (err != CgGL.CG_NO_ERROR) {
			System.out.println("CG error: " + CgGL.cgGetErrorString(err));
			System.out.println(CgGL.cgGetLastListing(context));
			System.exit(1);
	}
}

It would be nice if there was some equivalent to the DebugGL pipeline to do this automatically after each CgGL call. Maybe there already is?

edit: come to think of it, I might start using AspectJ for stuff like this.

Oh relly thanx!!! it help…with findind error in a shader :wink: