0

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

Edited by uonsin

1
Contributor
1
Reply
19
Views
3 Years
Discussion Span
Last Post by uonsin
0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.