   Cg and OpenGL
  Sorry couldn't really figure out where to post this (is Cg not popular enough to have its own forums?)I am having a problem getting my shaders to compile. At first I couldn't get Cg to recognise that my fx5600 had any shader capabilities at all. Then I eventually found out that if the Pixelformat is not set correctly for the OpenGL render context then the software implementation will be fallen back on. I found out that I have to use a 32bit zbuffer in order to get cgGLIsProfileSupported to return anything except false. So after fixing the zbuffer to 32bit it returns true for CG_PROFILE_ARBFP1. But now my cgCreateProgramFromFile call returns CG_PROFILE_NOT_SUPPORTED, even though I am passing the profile I just verified as supported:    if (cgGLIsProfileSupported(CG_PROFILE_ARBFP1))   m_cgpBestFragmentProfile = CG_PROFILE_ARBFP1; // this gets executed    else    {   // try FP30   if (cgGLIsProfileSupported(CG_PROFILE_FP30))  m_cgpBestFragmentProfile = CG_PROFILE_FP30;   else   {  return(false);   }    }    prog = cgCreateProgramFromFile(m_cgcContext,   CG_SOURCE,   name.c_str(),   m_cgpBestFragmentProfile,   funcname.c_str(),   NULL);Any ideas?I am using a few other gl rendering contexts in my program, running in other threads, and one running in the same thread, but these calls are all made within one function.Thanks.billw   
  Since you're picking ARBFP1 first, is it at all possible that what you're trying to compile isn't supported by ARBFP1?   ;  Sorry it is CG_INVALID_PROFILE_ERROR that is being returned. Surely if the Cg code is at fault it will return CG_COMPILE_ERROR? I tried swapping the order of checks and now it succeeds in finding CG_PROFILE_FP30, but still the same problem when I try to load and compile the shader from file. The reference documentation for Cg is pretty awfull, from what I have seen of it so far (everything related to what I am trying to do I have been over a few times). Its got spelling mistakes, grammer mistakes and the absolute minumum of useful information. What shading language do most people use?   ;  unfortunately, this doesn't answer your question but i was curious. if you are using OGL then why use the GLSL shading language? is it not equivalent to Cg? doesn't GLSL integrate better to OGL than Cg does?   ;  Just because I have heard more about Cg. Also I thought that GLSL was only in OpenGL 2.0, which you don't get on Windows XP.I am tempted to switch. But I have invested time and money in Cg and don't want to drop it quite yet (I have already written the shaders, and am pretty sure they will work just fine, never thought the problem would just be getting them to load!).;  Curiouser and curiouser! After alot of fiddling about I have managed to get get the required program to load and compile, but only if I call cgCreateProgramFromFile from within the init function, and not if I call my own Load function which then calls cgCreateProgramFromFile.i.e.This works:bool WWCgImageProcessor::Init(){    m_cgcContext = cgCreateContext();    if(m_cgcContext == NULL)   return(false);    m_cgpBestFragmentProfile = cgGLGetLatestProfile(CG_GL_FRAGMENT);    cgGLSetOptimalOptions(m_cgpBestFragmentProfile);    m_cgpHorizConvolution1_8 = cgCreateProgramFromFile(m_cgcContext,   CG_SOURCE,   "F:/Programming/Geometrix/Cg Shaders/horiz_convolve_sigma_1_8.cg",   m_cgpBestFragmentProfile,   "FragmentProgram",   NULL);// ....}This does not work:bool WWCgImageProcessor::Init(){    m_cgcContext = cgCreateContext();    if(m_cgcContext == NULL)   return(false);    m_cgpBestFragmentProfile = cgGLGetLatestProfile(CG_GL_FRAGMENT);    cgGLSetOptimalOptions(m_cgpBestFragmentProfile);    if(!LoadProgram(&m_cgpHorizConvolution1_8, "FragmentProgram",   "F:/Programming/Geometrix/Cg Shaders/horiz_convolve_sigma_1_8.cg"))   return(false);// ....}bool WWCgImageProcessor::LoadProgram(CGprogram *prog, const char *funcname, const char *name){*prog = cgCreateProgramFromFile(m_cgcContext,   CG_SOURCE,   name,   m_cgpBestFragmentProfile,   funcname,   NULL);// ....}What the hell is going on?[Edited by - bluntman on June 8, 2005 8:49:27 AM];  The version that does not work creates a new context which does not have a profile set. Maybe you should create a context only once.   ;  Yeah sorry that was debug code I had left in by accident, I have fixed the code above. I was just checking that the context is indeed new and valid. I get the same result regardless of that line of code.   ;Quote:Original post by bluntmanJust because I have heard more about Cg. Also I thought that GLSL was only in OpenGL 2.0, which you don't get on Windows XP.I am tempted to switch. But I have invested time and money in Cg and don't want to drop it quite yet (I have already written the shaders, and am pretty sure they will work just fine, never thought the problem would just be getting them to load!).IIRC, the OpenGL 1.4 API spec introduced the GLSL properly. It IS supported on any platform that runs OpenGL 1.4 (yes, even XP..*wink*), you just need to make sure you've got an updated set of video drivers from your board manufacturer.I could be wrong, but I'm under the impression that on non-nvidia hardware (ie. ATI), Cg calls are using the GLSL "under the hood". At least that's the impression I get on the documentation I've seen.hth,   