protected override void OnLoad(EventArgs e) { context = Cg.CreateContext(); Cg.SetErrorCallback(errorDelegate); cgVertexProfile = CgGL.GetLatestProfile(CgGLEnum.Vertex); string[] args = CgGL.GetOptimalOptions(cgVertexProfile); if (cgVertexProfile != CgProfile.Unknown) { if (CgGL.IsProfileSupported(cgVertexProfile)) { CgGL.SetOptimalOptions(cgVertexProfile); } } cgVertexProgram = Cg.CreateProgramFromFile( context, // Cg runtime context CgEnum.Source, // Program in human-readable form vertexProgramFileName, // Name of file containing program cgVertexProfile, // Profile: OpenGL ARB vertex program cgVertexEntryFuncName, // Entry function name args); // Extra compiler options CgGL.LoadProgram(cgVertexProgram); }
protected override void OnLoad(EventArgs e) { context = Cg.CreateContext(); Cg.SetErrorCallback(errorDelegate); cgVertexProfile = CgGL.GetLatestProfile(CgGLEnum.Vertex); string[] vArgs = CgGL.GetOptimalOptions(cgVertexProfile); if (cgVertexProfile != CgProfile.Unknown) { if (CgGL.IsProfileSupported(cgVertexProfile)) { CgGL.SetOptimalOptions(cgVertexProfile); } } cgVertexProgram = Cg.CreateProgramFromFile( context, // Cg runtime context CgEnum.Source, // Program in human-readable form vertexProgramFileName, // Name of file containing program cgVertexProfile, // Profile: OpenGL ARB vertex program cgVertexEntryFuncName, // Entry function name vArgs); // Extra compiler options CgGL.LoadProgram(cgVertexProgram); vertexParamModelViewProj = Cg.GetNamedParameter(cgVertexProgram, "modelViewProj"); cgFragmentProfile = CgGL.GetLatestProfile(CgGLEnum.Fragment); string[] fArgs = CgGL.GetOptimalOptions(cgFragmentProfile); if (cgFragmentProfile != CgProfile.Unknown) { if (CgGL.IsProfileSupported(cgFragmentProfile)) { CgGL.SetOptimalOptions(cgFragmentProfile); } } cgFragmentProgram = Cg.CreateProgram( context, // Cg runtime context */ CgEnum.Source, // Program in human-readable form */ "float4 main(uniform float4 c) : COLOR { return c; }", cgFragmentProfile, // Profile: OpenGL ARB vertex program */ "main", // Entry function name */ fArgs); // Extra compiler options */ CgGL.LoadProgram(cgFragmentProgram); fragmentParamColor = Cg.GetNamedParameter(cgFragmentProgram, "c"); }
/// <summary> /// <para>cgGetProfileProperty returns property information about the given profile.</para> /// <para>ERROR: CG_INVALID_PARAMETER_ERROR is generated if profile is not supported by this version of the Cg library. CG_INVALID_ENUMERANT_ERROR is generated if query is not CG_IS_OPENGL_PROFILE, CG_IS_DIRECT3D_PROFILE, CG_IS_DIRECT3D_8_PROFILE, CG_IS_DIRECT3D_9_PROFILE, CG_IS_DIRECT3D_10_PROFILE, CG_IS_DIRECT3D_11_PROFILE, CG_IS_VERTEX_PROFILE, CG_IS_FRAGMENT_PROFILE, CG_IS_GEOMETRY_PROFILE, CG_IS_TESSELLATION_CONTROL_PROFILE, CG_IS_TESSELLATION_EVALUATION_PROFILE, CG_IS_TRANSLATION_PROFILE, CG_IS_HLSL_PROFILE, or CG_IS_GLSL_PROFILE</para> /// <para>VERSION: cgGetProfileProperty was introduced in Cg 2.2.</para> /// </summary> /// <param name="profile">The profile to query.</param> /// <param name="query">An enumerant describing the property to be queried. The following enumerants are allowed:</param> /// <returns>Returns CG_TRUE if profile holds the property expressed by query. Returns CG_FALSE otherwise.</returns> public static CgBool GetProfileProperty(CgProfile profile, CgEnum query) { return cgGetProfileProperty(profile, query); }
private static extern void cgGLSetOptimalOptions(CgProfile profile);
/// <summary> /// <para>cgCreateProgramFromFile generates a new CgProgram object and adds it to the specified Cg context.</para> /// <para>ERROR: CG_INVALID_CONTEXT_HANDLE_ERROR is generated if context is not a valid context. CG_INVALID_ENUMERANT_ERROR is generated if program_type is not CG_SOURCE or CG_OBJECT. CG_UNKNOWN_PROFILE_ERROR is generated if profile is not a supported profile. CG_COMPILER_ERROR is generated if compilation fails.</para> /// <para>VERSION: cgCreateProgramFromFile was introduced in Cg 1.1.</para> /// </summary> /// <param name="context">The context to which the new program will be added.</param> /// <param name="program_type">An enumerant describing the contents of the program_file. The following enumerants are allowed: CG_SOURCE - source contains Cg source code. CG_OBJECT - source contains object code that resulted from the precompilation of some Cg source code.</param> /// <param name="program_file">Name of a file containing source or object code. See program_type for more information. </param> /// <param name="profile">The profile enumerant for the program. </param> /// <param name="entry">The entry point to the program in the Cg source. If NULL, the entry point defaults to "main". </param> /// <param name="args">If args is not NULL it is assumed to be an array of NULL-terminated strings that will be passed directly to the compiler as arguments. The last value of the array must be a NULL.</param> /// <returns>Returns a CgProgram handle on success. Returns NULL if an error occurs.</returns> public static CgProgram CreateProgramFromFile(CgContext context, CgEnum program_type, [In]string program_file, CgProfile profile, [In]string entry, string[] args) { return cgCreateProgramFromFile(context, program_type, program_file, profile, entry, args); }
/// <summary> /// <para>cgSetStateLatestProfile sets the specified state's designated latest profile for states of type CG_PROGRAM_TYPE.</para> /// <para>ERROR: CG_INVALID_STATE_HANDLE_ERROR is generated if state is not a valid state. CG_STATE_ASSIGNMENT_TYPE_MISMATCH_ERROR is generated if the type of state is not CG_PROGRAM_TYPE.</para> /// <para>VERSION: cgSetStateLatestProfile was introduced in Cg 2.2.</para> /// </summary> /// <param name="state">The state handle.</param> /// <param name="profile">The profile to designate as the state's latest profile.</param> public static void SetStateLatestProfile(CgState state, CgProfile profile) { cgSetStateLatestProfile(state, profile); }
/// <summary> /// <para>cgCreateObjFromFile creates a new CGobj which is a source source object similar to a.</para> /// <para>obj or.</para> /// <para>o in C/C++ programming where various forms of data can be extracted.</para> /// <para>This can be used, for example, to create user defined data types from a Cg source string.</para> /// <para>ERROR: CG_INVALID_CONTEXT_HANDLE_ERROR is generated if context is not a valid context. CG_INVALID_ENUMERANT_ERROR is generated if program_type is not CG_SOURCE or CG_OBJECT. CG_UNKNOWN_PROFILE_ERROR is generated if profile is not a supported profile. CG_COMPILER_ERROR is generated if compilation fails.</para> /// <para>VERSION: cgCreateObjFromFile was introduced in Cg 2.0.</para> /// </summary> /// <param name="context">The context to which the new object will be added. </param> /// <param name="program_type">An enumerant describing the contents of the source string. The following enumerants are allowed: CG_SOURCE - source contains Cg source code. CG_OBJECT - source contains object code that resulted from the precompilation of some Cg source code.</param> /// <param name="source_file">Name of a file containing source or object code. See program_type for more information. </param> /// <param name="profile">The profile enumerant for the program.</param> /// <param name="args">If args is not NULL it is assumed to be an array of NULL-terminated strings that will be passed directly to the compiler as arguments. The last value of the array must be a NULL.</param> /// <returns>Returns a CGobj handle on success. Returns NULL if an error occurs.</returns> public static CgObj CreateObjFromFile(CgContext context, CgEnum program_type, [In]string source_file, CgProfile profile, [In]string[] args) { return cgCreateObjFromFile(context, program_type, source_file, profile, args); }
/// <summary> /// <para>cgGetProgramBufferMaxSize returns the maximum size of a buffer for a profile in bytes.</para> /// <para>cgGetProgramBufferMaxSize will return 0 if an invalid profile is passed.</para> /// <para>VERSION: cgGetProgramBufferMaxSize was introduced in Cg 2.0.</para> /// </summary> /// <param name="profile">The target for determining the maximum buffer size.</param> /// <returns>Returns the size of a buffer for the given profile in bytes. Returns 0 if an error occurs.</returns> public static int GetProgramBufferMaxSize(CgProfile profile) { return cgGetProgramBufferMaxSize(profile); }
private static extern IntPtr cgCreateProgramFromEffect(CgEffect effect, CgProfile profile, [In] string entry, [In] string[] args);
private static extern void cgSetStateLatestProfile(CgState state, CgProfile profile);
private static extern void cgSetProgramProfile(CgProgram prog, CgProfile profile);
private static extern CgObj cgCreateObjFromFile(CgContext context, CgEnum program_type, [In] string source_file, CgProfile profile, [In] string[] args);
private static extern CgBool cgIsProfileSupported(CgProfile profile);
private static extern void cgGLUnbindProgram(CgProfile profile);
private static extern void cgGLEnableProfile(CgProfile profile);
/// <summary> /// <para>cgGetProfileString returns the profile name associated with a profile enumerant.</para> /// <para>VERSION: cgGetProfileString was introduced in Cg 1.1.</para> /// </summary> /// <param name="profile">The profile enumerant.</param> /// <returns>Returns the profile string of the enumerant profile. Returns NULL if profile is not a valid profile.</returns> public static string GetProfileString(CgProfile profile) { return cgGetProfileString(profile); }
/// <summary> /// <para>cgGetProgramBufferMaxIndex returns the maximum buffer index for a profile.</para> /// <para>cgGetProgramBufferMaxIndex will return 0 if an invalid profile is passed.</para> /// <para>VERSION: cgGetProgramBufferMaxIndex was introduced in Cg 2.0.</para> /// </summary> /// <param name="profile">The target for determining the maximum buffer index.</param> /// <returns>Returns the maximum buffer index for a given profile. Returns 0 if an error occurs.</returns> public static int GetProgramBufferMaxIndex(CgProfile profile) { return cgGetProgramBufferMaxIndex(profile); }
private static extern CgProgram cgCreateProgramFromFile(CgContext context, CgEnum program_type, [In] string program_file, CgProfile profile, [In] string entry, [In] string[] args);
/// <summary> /// <para>cgIsProfileSupported checks whether profile is supported by this version of the Cg library.</para> /// <para>VERSION: cgIsProfileSupported was introduced in Cg 2.2.</para> /// </summary> /// <param name="profile">The profile enumerant to test.</param> /// <returns>Returns CG_TRUE if profile is supported.</returns> public static CgBool IsProfileSupported(CgProfile profile) { return cgIsProfileSupported(profile); }
private static extern CgDomain cgGetProfileDomain(CgProfile profile);
/// <summary> /// <para>cgSetProgramProfile allows the application to specify the profile to be used when compiling the given program.</para> /// <para>When called, the program will be unloaded if it is currently loaded, and marked as uncompiled.</para> /// <para>When the program is next compiled (see cgSetAutoCompile), the given profile will be used.</para> /// <para>cgSetProgramProfile can be used to override the profile specified in a CgFX compile statement, or to change the profile associated with a program created by a call to cgCreateProgram.</para> /// <para>ERROR: CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle. CG_INVALID_PROFILE_ERROR is generated if profile is not a valid profile enumerant.</para> /// <para>VERSION: cgSetProgramProfile was introduced in Cg 1.4.</para> /// </summary> /// <param name="program">The program.</param> /// <param name="profile">The profile to be used when compiling the program.</param> public static void SetProgramProfile(CgProgram program, CgProfile profile) { cgSetProgramProfile(program, profile); }
private static extern CgBool cgGetProfileProperty(CgProfile profile, CgEnum query);
/// <summary> /// <para>cgCreateProgramFromEffect generates a new CgProgram object and adds it to the effect's Cg context.</para> /// <para>ERROR: CG_INVALID_EFFECT_HANDLE_ERROR is generated if effect is not a valid effect. CG_UNKNOWN_PROFILE_ERROR is generated if profile is not a supported profile. CG_COMPILER_ERROR is generated if compilation fails.</para> /// <para>VERSION: cgCreateProgramFromEffect was introduced in Cg 1.4.</para> /// </summary> /// <param name="effect">The effect containing the program source source from which to create the program.</param> /// <param name="profile">The profile enumerant for the program.</param> /// <param name="entry">The entry point to the program in the Cg source. If NULL, the entry point defaults to "main".</param> /// <param name="args">If args is not NULL it is assumed to be an array of NULL-terminated strings that will be passed directly to the compiler as arguments. The last value of the array must be a NULL.</param> /// <returns>Returns a CgProgram handle on success. Returns NULL if an error occurs.</returns> public static IntPtr CreateProgramFromEffect(CgEffect effect, CgProfile profile, [In]string entry, [In]string[] args) { return cgCreateProgramFromEffect(effect, profile, entry, args); }
private static extern string cgGetProfileString(CgProfile profile);
private static extern int cgGetProgramBufferMaxSize(CgProfile profile);
/// <summary> /// <para>cgGetProfileDomain returns which type of domain the given profile belongs to.</para> /// <para>VERSION: cgGetProfileDomain was introduced in Cg 1.5. CG_GEOMETRY_DOMAIN was introduced in Cg 2.0.</para> /// </summary> /// <param name="profile">The profile enumerant.</param> /// <returns>Returns: CG_UNKNOWN_DOMAIN CG_VERTEX_DOMAIN CG_FRAGMENT_DOMAIN CG_GEOMETRY_DOMAIN</returns> public static CgDomain GetProfileDomain(CgProfile profile) { return cgGetProfileDomain(profile); }
protected override void OnLoad(EventArgs e) { /* Tightly packed texture data. */ GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1); GL.Enable(EnableCap.Texture2D); GL.BindTexture(TextureTarget.Texture2D, 666); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgb8, 128, 128, 0, PixelFormat.Rgb, PixelType.UnsignedByte, ImageDemon.Array); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); context = Cg.CreateContext(); Cg.SetErrorCallback(errorDelegate); cgVertexProfile = CgGL.GetLatestProfile(CgGLEnum.Vertex); string[] vArgs = CgGL.GetOptimalOptions(cgVertexProfile); if (cgVertexProfile != CgProfile.Unknown) { if (CgGL.IsProfileSupported(cgVertexProfile)) { CgGL.SetOptimalOptions(cgVertexProfile); } } cgVertexProgram = Cg.CreateProgramFromFile( context, // Cg runtime context CgEnum.Source, // Program in human-readable form VertexProgramFileName, // Name of file containing program cgVertexProfile, // Profile: OpenGL ARB vertex program CgVertexEntryFuncName, // Entry function name vArgs); // Extra compiler options CgGL.LoadProgram(cgVertexProgram); cgFragmentProfile = CgGL.GetLatestProfile(CgGLEnum.Fragment); string[] fArgs = CgGL.GetOptimalOptions(cgVertexProfile); if (cgFragmentProfile != CgProfile.Unknown) { if (CgGL.IsProfileSupported(cgFragmentProfile)) { CgGL.SetOptimalOptions(cgFragmentProfile); } } cgFragmentProgram = Cg.CreateProgramFromFile( context, // Cg runtime context */ CgEnum.Source, // Program in human-readable form */ FragmentProgramFileName, // Name of file containing program */ cgFragmentProfile, // Profile: OpenGL ARB vertex program */ CgFragmentEntryFuncName, // Entry function name */ fArgs); // Extra compiler options */ CgGL.LoadProgram(cgFragmentProgram); fragmentParamDecal = Cg.GetNamedParameter(cgFragmentProgram, "decal"); CgGL.SetTextureParameter(fragmentParamDecal, 666); }
private static extern IntPtr cgGLGetOptimalOptions(CgProfile profile);