PDA

View Full Version : Cg profile problem!


billw
06-06-2005, 05:23 PM
Please help! Cg is driving me a bit nuts. I have got all the libraries linked in, and the various bits of setup code implemented (I am using OpenGL with BCB). Firstly I could only get Cg to detect the best profile if I called cgGLGetLatestProfile before initialising OpenGL. That didn't make any sense to me. I finally managed to get it to return CG_PROFILE_FP30 (I am using an FX 5600). But then when I tried to compile my program in runtime the compiler returned CG_INVALID_PROFILE_ERROR! How can this be? What am I doing wrong? Why doesn't nVidia have a Cg forum!?

Thanks in advance,
Billw

playmesumch00ns
06-07-2005, 09:46 AM
Can you post what you're doing in your init routines? When you say you're getting the profile before intializing OpenGL, what exactly do you mean?

you could try the forums at opengl.org, gamedev.net or flipcode.com too

billw
06-07-2005, 12:14 PM
Sure thing, heres the code!
Heres my base initialisation:

WWOpenGLOffscreenBuffer ofsbuffer;
WWCgImageProcessor improc;
if(!improc.Init())
return(false);
if(!ofsbuffer.Initialise(width, height, handle))
return(false);
Heres improc.Init():


m_cgcContext = cgCreateContext();
if(m_cgcContext == NULL)
return(false);
m_cgpBestFragmentProfile = cgGLGetLatestProfile(CG_GL_FRAGMENT);
//CGprofile BestVertexProfile = cgGLGetLatestProfile(CG_GL_VERTEX);
if(m_cgpBestFragmentProfile == CG_PROFILE_UNKNOWN)
return(false);
cgGLSetOptimalOptions(m_cgpBestFragmentProfile);

The next bit is the bit that fails:
if(!LoadProgram(m_cgpHorizConvolution1_8, "FragmentProgram",
"horiz_convolve_sigma_1_8.cg"))
return(false);

ofsbuffer.Initialise() just does standard OpenGL initalisation of an offscreen buffer using the DC of a bitmap.

LoadProgram() looks like:
bool LoadProgram(CGprogram &prog, std::string funcname, std::string name)
{
// cgGLEnableProfile(m_cgpBestFragmentProfile); <- tried that aswell
prog = cgCreateProgramFromFile(m_cgcContext,
CG_SOURCE,
name.c_str(),
m_cgpBestFragmentProfile,
funcname.c_str(),
NULL);

CGerror error = cgGetError();

if(error != CG_NO_ERROR)
return(false);

return(true);
}

billw
06-07-2005, 12:56 PM
Okay so I have found a bit of insight into this problem: turns out the initialisation of OpenGL is important to whether the shaders can be supported. If the Pixelformat forces OpenGL to fall back on software then the shaders cannot be used. So I fixed it so that the correct profile can now be detected, and it is, but the program will not LOAD now. Says CG_PROFILE_NOT_SUPPORTED even though its own routine just said it was!! I mean wtf.

CGTalk Moderation
06-07-2005, 12:56 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.