# This .cfg file provides common options used among all Cg glue code
# generated for Jogl on all platforms.
Package net.java.games.cg
ImplPackage net.java.games.cg.impl
JavaClass CgGL
Style AllStatic
JavaOutputDir ../build/gensrc/classes
NativeOutputDir ../build/gensrc/native/jogl_cg
HierarchicalNativeOutput false

# Generate "flattened" NIO variants for routines taking C primitive
# pointers that aren't of type void*
NioMode ALL_POINTERS
FlattenNIOVariants true

#
# Map const char* return values to Java strings for these functions
#
ReturnsString cgGetEnumString
ReturnsString cgGetErrorString
ReturnsString cgGetLastErrorString
ReturnsString cgGetLastListing
ReturnsString cgGetParameterName
ReturnsString cgGetParameterSemantic
ReturnsString cgGetProfileString
ReturnsString cgGetProgramString
ReturnsString cgGetResourceString
ReturnsString cgGetString
ReturnsString cgGetTypeString

ArgumentIsString cgCreateProgram 2 4 5
ArgumentIsString cgCreateProgramFromFile 2 4 5
ArgumentIsString cgGetEnum 0
ArgumentIsString cgGetNamedParameter 1
ArgumentIsString cgGetNamedProgramParameter 2
ArgumentIsString cgGetNamedStructParameter 1
ArgumentIsString cgGetNamedUserType 1
ArgumentIsString cgGetProfile 0
ArgumentIsString cgGetType 0
ArgumentIsString cgGetResource 0
ArgumentIsString cgSetParameterSemantic 1

# Opaque definitions
Opaque boolean CGbool

#
# FIXME!!!!  Ignore these functions for now because we can't
# automatically handle C callbacks
#
Ignore cgGetErrorCallback
Ignore cgSetErrorCallback

#
# FIXME!!!!  Ignore these functions for now because bugs in the
# emitter code can't handle them
#
Ignore cgGetParameterValues

#
# Need to import New IO for Buffer classes
#
Import java.nio.*
# and java.security.* to allow unsigned Cg applications
Import java.security.*

# Raise CgException instead of RuntimeException in glue code
RuntimeExceptionType CgException

#
# Make sure the right definitions and include files are added to the
# generated C code
#

CustomCCode #include <stdlib.h>
CustomCCode #include <Cg/cgGL.h>

CustomJavaCode CgGL static {
CustomJavaCode CgGL   AccessController.doPrivileged(new PrivilegedAction() {
CustomJavaCode CgGL     public Object run() {
CustomJavaCode CgGL       try {
CustomJavaCode CgGL         // Workaround so that these don't need to be in the system
CustomJavaCode CgGL         // path but can be referenced from java.library.path
CustomJavaCode CgGL         // (this is intended to help with Webstarted applications)
CustomJavaCode CgGL         System.loadLibrary("cg");
CustomJavaCode CgGL         System.loadLibrary("cgGL");
CustomJavaCode CgGL       } catch (UnsatisfiedLinkError e) {
CustomJavaCode CgGL         // Consider this non-fatal
CustomJavaCode CgGL       }
CustomJavaCode CgGL       // Load the actual Cg binding
CustomJavaCode CgGL       System.loadLibrary("jogl_cg");
CustomJavaCode CgGL       return null;
CustomJavaCode CgGL     }
CustomJavaCode CgGL   });
CustomJavaCode CgGL }