I'm getting a compiler error when trying to initialize a geometry shader using OpenGL. I'm using VS2013.
Here is how I initialize it on OpenGL

myCgContext = cgCreateContext();
cgGLSetDebugMode(CG_FALSE);

cgSetParameterSettingMode(myCgContext, CG_DEFERRED_PARAMETER_SETTING);

CGprofile gpProfile = cgGLGetLatestProfile(CG_GL_GEOMETRY);


if (gpProfile == CG_PROFILE_UNKNOWN) {
    if (cgGLIsProfileSupported(CG_PROFILE_GLSLG))
        gpProfile = CG_PROFILE_GLSLG;
    else {
        fprintf(stderr, "%s: geometry profile is not available.\n", gpProfile);
        exit(0);
    }
}


cgGLSetOptimalOptions(gpProfile);
OpenGLRenderer::checkForCgError("selecting geometry profile");

CGprogram prog = cgCreateProgram(myCgContext, 
                                    CG_SOURCE, 
                                    "geometry_particles.cg",
                                    gpProfile, 
                                    "geometry_passthru",
                                    NULL);
OpenGLRenderer::checkForCgError("Geometry program");

When I call the function checkForCgError, the compiler throws the following error message: The compiler returned an error. (1) : error C0000: syntax error, unexpected '.', expecting "::" at token '.'

My geometry shader is located in the file "geometry_particles.cg" and the code is

// Geometry pass-through program for colored triangles
void geometry_passthru(AttribArray<float4> position : POSITION, 
                    AttribArray<float4> color   : COLOR)
{
    for (int i = 0; i < 3; i++) 
    {
        emitVertex(position[i] :POSITION, color[i] : COLOR);
    }
}

Any thoughts on why the compiler is throwing that error. Am I missing a flag when setting up the shader?

Thanks in advance

Someone pointed out that I was using cgCreateProgram instead of cgCreateProgramFromFile, that took care of the error, also I forgot to add the input mode on the post, which I have on the actual file

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.