Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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");
        }
Exemplo n.º 3
0
 /// <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);
 }
Exemplo n.º 4
0
 private static extern void cgGLSetOptimalOptions(CgProfile profile);
Exemplo n.º 5
0
 /// <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);
 }
Exemplo n.º 6
0
 /// <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);
 }
Exemplo n.º 7
0
 /// <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);
 }
Exemplo n.º 8
0
 /// <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);
 }
Exemplo n.º 9
0
 private static extern IntPtr cgCreateProgramFromEffect(CgEffect effect, CgProfile profile, [In] string entry, [In] string[] args);
Exemplo n.º 10
0
 private static extern void cgSetStateLatestProfile(CgState state, CgProfile profile);
Exemplo n.º 11
0
 private static extern void cgSetProgramProfile(CgProgram prog, CgProfile profile);
Exemplo n.º 12
0
 private static extern CgObj cgCreateObjFromFile(CgContext context, CgEnum program_type, [In] string source_file, CgProfile profile, [In] string[] args);
Exemplo n.º 13
0
 private static extern CgBool cgIsProfileSupported(CgProfile profile);
Exemplo n.º 14
0
 private static extern void cgGLUnbindProgram(CgProfile profile);
Exemplo n.º 15
0
 private static extern void cgGLEnableProfile(CgProfile profile);
Exemplo n.º 16
0
 /// <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);
 }
Exemplo n.º 17
0
 /// <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);
 }
Exemplo n.º 18
0
 private static extern CgProgram cgCreateProgramFromFile(CgContext context, CgEnum program_type, [In] string program_file, CgProfile profile, [In] string entry, [In] string[] args);
Exemplo n.º 19
0
 /// <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);
 }
Exemplo n.º 20
0
 private static extern CgDomain cgGetProfileDomain(CgProfile profile);
Exemplo n.º 21
0
 /// <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);
 }
Exemplo n.º 22
0
 private static extern CgBool cgGetProfileProperty(CgProfile profile, CgEnum query);
Exemplo n.º 23
0
 /// <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);
 }
Exemplo n.º 24
0
 private static extern string cgGetProfileString(CgProfile profile);
Exemplo n.º 25
0
 private static extern int cgGetProgramBufferMaxSize(CgProfile profile);
Exemplo n.º 26
0
 /// <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);
 }
Exemplo n.º 27
0
        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);
        }
Exemplo n.º 28
0
 private static extern IntPtr cgGLGetOptimalOptions(CgProfile profile);