Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

CgObjects Class Reference

Global Cg Objects maintenance class. More...

#include <Cg.h>

List of all members.

Public Member Functions

 CgObjects ()
virtual ~CgObjects ()
CGprofile fragmentProfile ()
const CGprofile fragmentProfile () const
CGprofile vertexProfile ()
const CGprofile vertexProfile () const
CGcontext shaderContext ()
const CGcontext shaderContext () const

Static Private Member Functions

void cgErrorCallback (void)

Private Attributes

CGprofile _fragmentProfile
CGprofile _vertexProfile
CGcontext _shaderContext


Detailed Description

Global Cg Objects maintenance class.

The single allowed instance of this object is constructed in the first call to Cg() and released using releaseCg().

Definition at line 66 of file Cg.h.


Constructor & Destructor Documentation

CgObjects::CgObjects  ) 
 

Definition at line 9 of file Cg.cpp.

References _fragmentProfile, _shaderContext, _vertexProfile, and cgErrorCallback().

00010 {
00011   // profiles
00012   if (cgGLIsProfileSupported(CG_PROFILE_FP30)) {
00013     printf( "fragment program profile fp30 ... " );
00014     _fragmentProfile = CG_PROFILE_FP30;
00015   }
00016   /*  else if (cgGLIsProfileSupported(CG_PROFILE_FP20)) {
00017     printf( "fragment program profile fp20 ... " );
00018     _fragmentProfile = CG_PROFILE_FP20;
00019   }
00020   else if (cgGLIsProfileSupported(CG_PROFILE_ARBFP1)) {
00021     printf( "fragment program profile arbfp1 ... " );
00022     _fragmentProfile = CG_PROFILE_ARBFP1;
00023   }
00024   */
00025   else {
00026     printf( "Fragment programming extensions (GL_ARB_fragment_program or "
00027            "GL_NV_fragment_program) not supported, exiting...\n" );
00028     assert( false );
00029   }
00030   
00031   if (cgGLIsProfileSupported(CG_PROFILE_ARBVP1))
00032     _vertexProfile = CG_PROFILE_ARBVP1;
00033   else if (cgGLIsProfileSupported(CG_PROFILE_VP20))
00034     _vertexProfile = CG_PROFILE_VP20;
00035   else {
00036     printf( "Vertex programming extensions (GL_ARB_vertex_program or "
00037            "GL_NV_vertex_program) not supported, exiting...\n" );
00038     assert( false );
00039   }
00040 
00041   cgSetErrorCallback(cgErrorCallback);
00042   _shaderContext = cgCreateContext();
00043 }

CgObjects::~CgObjects  )  [virtual]
 

Definition at line 45 of file Cg.cpp.

00046 {
00047 }


Member Function Documentation

void CgObjects::cgErrorCallback void   )  [static, private]
 

Definition at line 76 of file Cg.cpp.

References Cg(), and shaderContext().

Referenced by CgObjects().

00077 {
00078   CGerror LastError = cgGetError();
00079   
00080   if(LastError) {
00081     printf( "Cg Error.\n" );
00082     const char *Listing = cgGetLastListing(Cg()->shaderContext());
00083     printf( "\n---------------------------------------------------\n");
00084     printf("%s\n\n", cgGetErrorString(LastError));
00085     printf("%s\n", Listing);
00086     printf("---------------------------------------------------\n");
00087     printf("Cg error, exiting...\n");
00088     assert( false );
00089   }
00090 }

const CGprofile CgObjects::fragmentProfile  )  const
 

Definition at line 53 of file Cg.cpp.

References _fragmentProfile.

00054 {
00055   return _fragmentProfile;
00056 }

CGprofile CgObjects::fragmentProfile  ) 
 

Definition at line 49 of file Cg.cpp.

References _fragmentProfile.

00050 {
00051   return _fragmentProfile;
00052 }

const CGcontext CgObjects::shaderContext  )  const
 

Definition at line 71 of file Cg.cpp.

References _shaderContext.

00072 {
00073   return _shaderContext;
00074 }

CGcontext CgObjects::shaderContext  ) 
 

Definition at line 67 of file Cg.cpp.

References _shaderContext.

Referenced by cgErrorCallback().

00068 {
00069   return _shaderContext;
00070 }

const CGprofile CgObjects::vertexProfile  )  const
 

Definition at line 62 of file Cg.cpp.

References _vertexProfile.

00063 {
00064   return _vertexProfile;
00065 }

CGprofile CgObjects::vertexProfile  ) 
 

Definition at line 58 of file Cg.cpp.

References _vertexProfile.

00059 {
00060   return _vertexProfile;
00061 }


Member Data Documentation

CGprofile CgObjects::_fragmentProfile [private]
 

Definition at line 94 of file Cg.h.

Referenced by CgObjects(), and fragmentProfile().

CGcontext CgObjects::_shaderContext [private]
 

Definition at line 98 of file Cg.h.

Referenced by CgObjects(), and shaderContext().

CGprofile CgObjects::_vertexProfile [private]
 

Definition at line 96 of file Cg.h.

Referenced by CgObjects(), and vertexProfile().


The documentation for this class was generated from the following files:
Generated on Thu Jan 20 02:47:13 2005 for Projective_Texture_Effect_Demo by doxygen 1.3.6