/*------------------------------------------------------------------*\ author : mathias gumz date : 040120 04:46:20 history: first version \*------------------------------------------------------------------*/ /*------------------------------------------------------------------*\ about : cgdetect is a small tool to detect the capabilities of the cgbackend. build : x11/linux: gcc -o cgdetect cgdetect.c -L/usr/X11R6/lib -lCgGL -lCg -lGLU -lGL -lX11 \*------------------------------------------------------------------*/ /*------------------------------------------------------------------*\ copyright (c) 2004 permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "software"), to deal in the software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software, and to permit persons to whom the software is furnished to do so, subject to the following conditions: THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \*------------------------------------------------------------------*/ #include #include #include #include #include #ifndef WIN32 #include #endif /*------------------------------------------------------------------*\ \*------------------------------------------------------------------*/ #ifndef WIN32 Display* dpy= NULL; Window win; GLXContext context; GLXPbuffer pbuffer; CGcontext cgcontext; #endif /*------------------------------------------------------------------*\ \*------------------------------------------------------------------*/ int printInfo(FILE* fd, CGprofile vprofile, CGprofile fprofile) { if ( !fd ) fd= stdout; fprintf(fd, " CG_PROFILE_ARBVP1 [%s] : %s\n", ( vprofile == CG_PROFILE_ARBVP1 ? "x" : " "), ( cgGLIsProfileSupported(CG_PROFILE_ARBVP1) ? "supported" : "not supported")); fprintf(fd, " CG_PROFILE_VP20 [%s] : %s\n", ( vprofile == CG_PROFILE_VP20 ? "x" : " "), ( cgGLIsProfileSupported(CG_PROFILE_VP20 ) ? "supported" : "not supported")); fprintf(fd, " CG_PROFILE_VP30 [%s] : %s\n", ( vprofile == CG_PROFILE_VP30 ? "x" : " "), ( cgGLIsProfileSupported(CG_PROFILE_VP30 ) ? "supported" : "not supported")); fprintf(fd, " CG_PROFILE_ARBFP1 [%s] : %s\n", ( fprofile == CG_PROFILE_ARBFP1 ? "x" : " "), ( cgGLIsProfileSupported(CG_PROFILE_ARBFP1) ? "supported" : "not supported")); fprintf(fd, " CG_PROFILE_FP20 [%s] : %s\n", ( fprofile == CG_PROFILE_FP20 ? "x" : " "), ( cgGLIsProfileSupported(CG_PROFILE_FP20 ) ? "supported" : "not supported")); fprintf(fd, " CG_PROFILE_FP30 [%s] : %s\n", ( fprofile == CG_PROFILE_FP30 ? "x" : " "), ( cgGLIsProfileSupported(CG_PROFILE_FP30 ) ? "supported" : "not supported")); return 0; } int cleanup_and_exit(int exitstatus) { #ifndef WIN32 glXDestroyPbuffer(dpy,pbuffer); glXDestroyContext(dpy,context); XCloseDisplay(dpy); #endif cgDestroyContext(cgcontext); exit(exitstatus); return 0; } /*------------------------------------------------------------------*\ \*------------------------------------------------------------------*/ int main(int argc, char* argv[]) { CGprofile vprofile= CG_PROFILE_UNKNOWN; CGprofile fprofile= CG_PROFILE_UNKNOWN; #ifndef WIN32 { GLXFBConfigSGIX *fbc; int v_attr_list[]= { GLX_DEPTH_SIZE, 16, GLX_DOUBLEBUFFER, GL_FALSE, None }; int p_attr_list[]= { GLX_PBUFFER_WIDTH, 2, GLX_PBUFFER_HEIGHT, 2, None }; int n; int screen; dpy= XOpenDisplay(0); screen= DefaultScreen(dpy); fbc= glXChooseFBConfig(dpy, screen, v_attr_list, &n); context= glXCreateNewContext(dpy, fbc[1], GLX_RGBA_TYPE, NULL, GL_TRUE); pbuffer= glXCreatePbuffer(dpy, fbc[1],p_attr_list); glXMakeCurrent(dpy, pbuffer, context); } #endif cgcontext= cgCreateContext(); if ( !cgIsContext(cgcontext) ) { fprintf(stderr, "couldnt create a cg-context, exit\n"); cleanup_and_exit(1); return 1; } vprofile= cgGLGetLatestProfile(CG_GL_VERTEX); fprofile= cgGLGetLatestProfile(CG_GL_FRAGMENT); cgGLSetOptimalOptions(vprofile); cgGLSetOptimalOptions(fprofile); printInfo(stdout, vprofile, fprofile); return cleanup_and_exit(0); } /*------------------------------------------------------------------*\ vim:ts=2:tw=0:sw=2 \*------------------------------------------------------------------*/