Monday, May 28, 2012

Some quick notes on running Cg on OpenGL under MingW

This is more a post for my own reference.

The Cg library and include files are installed here:
C:\Program Files (x86)\NVIDIA Corporation\Cg\lib

For MingW they should be copied here:
C:\MinGW\lib
C:\MinGW\include

Then they can be referred to when building like so:
g++ -Wall main.cpp -o OpenGLFake  -lopengl32 -lcg -lcgGL

And referenced in the code:
#include "Cg/Cg.h"
#include "Cg/cgGL.h"

These should be angle brackets above but blogger really can't handle escaping them so I can't use that character!
CGprofile cgFragmentProfile;
CGprogram cgVertexShader;
CGprogram cgFragmentShader;
Here's a quick print error function, to find out why your shader doesn't compile :D

void printCGError(CGcontext cgContext)
{
    CGerror err = cgGetError();
    printf("Error:%s\n", cgGetErrorString(err));
    printf("\n%s", cgGetLastListing(cgContext));
} 


Post a Comment