Example #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);
        }
Example #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");
        }
Example #3
0
 /// <summary>
 /// <para>The parameters of a program can be retrieved directly by name using cgGetNamedParameter.</para>
 /// <para>The names of the parameters in a program can be discovered by iterating through the program's parameters (see cgGetNextParameter), calling cgGetParameterName for each one in turn.</para>
 /// <para>ERROR: CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle.</para>
 /// <para>VERSION: cgGetNamedParameter was introduced in Cg 1.1.</para>
 /// </summary>
 /// <param name="program">The program from which to retrieve the param.</param>
 /// <param name="name">The name of the param to retrieve.</param>
 /// <returns>Returns the named param from the program. Returns NULL if the program has no param corresponding to name.</returns>
 public static CgParameter GetNamedParameter(CgProgram program, [In]string name)
 {
     return cgGetNamedParameter(program, name);
 }
Example #4
0
 /// <summary>
 /// <para>cgEvaluateProgram evaluates a Cg program at a set of regularly spaced points in one, two, or three dimensions.</para>
 /// <para>The program must have been compiled with the CG_PROFILE_GENERIC profile.</para>
 /// <para>The value returned from the program via the COLOR semantic is stored in the given buffer for each evaluation point, and any varying parameters to the program with POSITION semantic take on the (x,y,z) position over the range zero to one at which the program is evaluated at each point.</para>
 /// <para>The PSIZE semantic can be used to find the spacing between evaluating points.</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 program's profile is not CG_PROFILE_GENERIC. CG_INVALID_PARAMETER_ERROR is generated if buf is NULL, any of nx, ny, or nz is less than zero, or ncomps is not 0, 1, 2, or 3.</para>
 /// <para>VERSION: cgEvaluateProgram was introduced in Cg 1.4.</para>
 /// </summary>
 /// <param name="program">The program to be evalutated.</param>
 /// <param name="ncomps">Number of components to store for each returned program value.</param>
 /// <param name="nx">Number of points at which to evaluate the program in the x direction.</param>
 /// <param name="ny">Number of points at which to evaluate the program in the y direction.</param>
 /// <param name="nz">Number of points at which to evaluate the program in the z direction.</param>
 /// <returns>Buffer in which to store the results of program evaluation.</returns>
 public static float[] EvaluateProgram(CgProgram program, int ncomps, int nx, int ny, int nz)
 {
     var retValue = new float[ncomps * nx * ny * nz];
     cgEvaluateProgram(program, retValue, ncomps, nx, ny, nz);
     return retValue;
 }
Example #5
0
 /// <summary>
 /// <para>cgDestroyProgram removes the specified program object and all its associated data.</para>
 /// <para>Any CgProgram variables that reference this program will become invalid after the program is deleted.</para>
 /// <para>Likewise, any objects contained by this program (e.g. CgParameter objects) will also become invalid after the program is deleted.</para>
 /// <para>ERROR: CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle.</para>
 /// <para>VERSION: cgDestroyProgram was introduced in Cg 1.1.</para>
 /// </summary>
 /// <param name="program">The program object to delete.</param>
 public static void DestroyProgram(CgProgram program)
 {
     cgDestroyProgram(program);
 }
Example #6
0
 /// <summary>
 /// <para>cgUpdateProgramParameters performs the appropriate 3D API commands to set the 3D API resources for all of program's parameters that are marked update deferred and clears the update deferred state of these parameters.</para>
 /// <para>cgUpdateProgramParameters does nothing when none of program's parameters are marked update deferred.</para>
 /// <para>ERROR: CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle.</para>
 /// <para>VERSION: cgUpdateProgramParameters was introduced in Cg 2.0.</para>
 /// </summary>
 /// <param name="program">The program for which deferred parameters will be sent to the corresponding 3D API parameters.</param>
 public static void UpdateProgramParameters(CgProgram program)
 {
     cgUpdateProgramParameters(program);
 }
Example #7
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);
 }
Example #8
0
 /// <summary>
 /// <para>Given the handle to a program specified in a pass in a CgFX file, cgSetPassProgramParameters sets the values of the program's uniform parameters given the expressions in the compile statement in the CgFX file.</para>
 /// <para>ERROR: CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle.</para>
 /// <para>VERSION: cgSetPassProgramParameters was introduced in Cg 1.4.</para>
 /// </summary>
 /// <param name="program">The program.</param>
 public static void SetPassProgramParameters(CgProgram program)
 {
     cgSetPassProgramParameters(program);
 }
Example #9
0
 /// <summary>
 /// <para>cgGetProgramBuffer returns the buffer handle associated with a given buffer index from program.</para>
 /// <para>The returned value can be NULL if no buffer is associated with this index or if an error occurs.</para>
 /// <para>ERROR: CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle. CG_BUFFER_INDEX_OUT_OF_RANGE_ERROR is generated if bufferIndex is not within the valid range of buffer indices for program.</para>
 /// <para>VERSION: cgGetProgramBuffer was introduced in Cg 2.0.</para>
 /// </summary>
 /// <param name="program">The program from which the associated buffer will be retrieved.</param>
 /// <param name="bufferIndex">The buffer index for which the associated buffer will be retrieved.</param>
 /// <returns>Returns a buffer handle on success. Returns NULL if an error occurs.</returns>
 public static CgBuffer GetProgramBuffer(CgProgram program, int bufferIndex)
 {
     return cgGetProgramBuffer(program, bufferIndex);
 }
Example #10
0
 /// <summary>
 /// <para>cgCopyProgram creates a new program object that is a copy of program and adds it to the same context as program.</para>
 /// <para>cgCopyProgram is useful for creating a new instance of a program whose param properties have been modified by the run-time API.</para>
 /// <para>ERROR: CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle.</para>
 /// <para>VERSION: cgCopyProgram was introduced in Cg 1.1. cgCopyProgram is operational as of Cg 3.0.</para>
 /// </summary>
 /// <param name="program">The program object to copy.</param>
 /// <returns>Returns a copy of program on success. Returns NULL if program is invalid or the copy fails.</returns>
 public static CgProgram CopyProgram(CgProgram program)
 {
     return cgCopyProgram(program);
 }
Example #11
0
 /// <summary>
 /// <para>cgGetNumProgramDomains returns the number of domains in a combined program.</para>
 /// <para>For example, if the combined program contained a vertex program and a fragment program, cgGetNumProgramDomains will return 2.</para>
 /// <para>ERROR: CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle.</para>
 /// <para>VERSION: cgGetNumProgramDomains was introduced in Cg 1.5.</para>
 /// </summary>
 /// <param name="program">The combined program object to be queried.</param>
 /// <returns>Returns the number of domains in the combined program program. Returns 0 if an error occurs.</returns>
 public static int GetNumProgramDomains(CgProgram program)
 {
     return cgGetNumProgramDomains(program);
 }
Example #12
0
 /// <summary>
 /// <para>The programs within a context can be iterated over by using cgGetNextProgram.</para>
 /// <para>ERROR: CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle.</para>
 /// <para>VERSION: cgGetNextProgram was introduced in Cg 1.1.</para>
 /// </summary>
 /// <param name="program">The current program.</param>
 /// <returns>Returns the next program in the context's internal sequence of programs. Returns NULL when program is the last program in the context.</returns>
 public static CgProgram GetNextProgram(CgProgram program)
 {
     return cgGetNextProgram(program);
 }
Example #13
0
 /// <summary>
 /// <para>cgGetNamedProgramParameter is essentially identical to  cgGetNamedParameter except it limits the search of the param to the name space specified by name_space.</para>
 /// <para>ERROR: CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle.</para>
 /// <para>VERSION: cgGetNamedProgramParameter was introduced in Cg 1.2.</para>
 /// </summary>
 /// <param name="program">The program from which to retrieve the param.</param>
 /// <param name="name_space">Specifies the namespace of the param to iterate through.  Currently CG_PROGRAM and CG_GLOBAL are supported.</param>
 /// <param name="name">Specifies the name of the param to retrieve.</param>
 /// <returns>Returns the named param from the program. Returns NULL if the program has no param corresponding to name.</returns>
 public static CgParameter GetNamedProgramParameter(CgProgram program, CgEnum name_space, string name)
 {
     return cgGetNamedProgramParameter(program, name_space, name);
 }
Example #14
0
 /// <summary>
 /// <para>The annotations associated with a program can be retrieved directly by name using cgGetNamedProgramAnnotation.</para>
 /// <para>The names of a program's annotations can be discovered by iterating through the annotations (see cgGetFirstProgramAnnotation and cgGetNextAnnotation), calling cgGetAnnotationName for each one in turn.</para>
 /// <para>ERROR: CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle.</para>
 /// <para>VERSION: cgGetNamedProgramAnnotation was introduced in Cg 1.4.</para>
 /// </summary>
 /// <param name="program">The program from which to retrieve the annotation.</param>
 /// <param name="name">The name of the annotation to retrieve.</param>
 /// <returns>Returns the named annotation. Returns NULL if the program has no annotation corresponding to name.</returns>
 public static CgAnnotation GetNamedProgramAnnotation(CgProgram prog, [In]string name)
 {
     return cgGetNamedProgramAnnotation(prog, name);
 }
Example #15
0
 /// <summary>
 /// <para>cgCompileProgram compiles the specified Cg program for its target profile.</para>
 /// <para>A program must be compiled before it can be loaded (by the API-specific part of the runtime).</para>
 /// <para>It must also be compiled before its parameters can be inspected.</para>
 /// <para>ERROR: CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle. CG_COMPILER_ERROR is generated if compilation fails.</para>
 /// <para>VERSION: cgCompileProgram was introduced in Cg 1.1.</para>
 /// </summary>
 /// <param name="program">The program object to compile.</param>
 public static void CompileProgram(CgProgram program)
 {
     cgCompileProgram(program);
 }
Example #16
0
 /// <summary>
 /// <para>cgIsProgram return CG_TRUE if program references a valid program object.</para>
 /// <para>Note that this does not imply that the program has been successfully compiled.</para>
 /// <para>VERSION: cgIsProgram was introduced in Cg 1.1.</para>
 /// </summary>
 /// <param name="program">The program handle to check.</param>
 /// <returns>Returns CG_TRUE if program references a valid program object. Returns CG_FALSE otherwise.</returns>
 public static CgBool IsProgram(CgProgram program)
 {
     return cgIsProgram(program);
 }
Example #17
0
 /// <summary>
 /// <para>cgIsProgramCompiled returns CG_TRUE if program has been compiled and CG_FALSE otherwise.</para>
 /// <para>ERROR: CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle.</para>
 /// <para>VERSION: cgIsProgramCompiled was introduced in Cg 1.1.</para>
 /// </summary>
 /// <param name="program">The program.</param>
 /// <returns>Returns CG_TRUE if program has been compiled. Returns CG_FALSE otherwise.</returns>
 public static CgBool IsProgramCompiled(CgProgram program)
 {
     return cgIsProgramCompiled(program);
 }
Example #18
0
 /// <summary>
 /// <para>cgGetProgramContext allows the application to retrieve a handle to the context to which a given program belongs.</para>
 /// <para>ERROR: CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle.</para>
 /// <para>VERSION: cgGetProgramContext was introduced in Cg 1.1.</para>
 /// </summary>
 /// <param name="program">The program.</param>
 /// <returns>Returns a CgContext handle to the parent context. Returns NULL if an error occurs.</returns>
 public static CgContext GetProgramContext(CgProgram program)
 {
     return cgGetProgramContext(program);
 }
Example #19
0
 /// <summary>
 /// <para>cgSetProgramBuffer sets the buffer for a given buffer index of a program.</para>
 /// <para>A NULL buffer handle means the given buffer index should not be bound to a buffer.</para>
 /// <para>ERROR: CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle. CG_INVALID_BUFFER_HANDLE_ERROR is generated if buffer is not a valid buffer. CG_BUFFER_INDEX_OUT_OF_RANGE_ERROR is generated if bufferIndex is not within the valid range of buffer indices for program.</para>
 /// <para>VERSION: cgSetProgramBuffer was introduced in Cg 2.0.</para>
 /// </summary>
 /// <param name="program">The program for which the buffer will be set.</param>
 /// <param name="bufferIndex">The buffer index of program to which buffer will be bound.</param>
 /// <param name="buffer">The buffer to be bound.</param>
 public static void SetProgramBuffer(CgProgram program, int bufferIndex, CgBuffer buffer)
 {
     cgSetProgramBuffer(program, bufferIndex, buffer);
 }
Example #20
0
 /// <summary>
 /// <para>cgGetProgramDomain retrieves the domain enumerant currently associated with a program.</para>
 /// <para>This is a convenience routine which essentially calls cgGetProgramProfile followed by cgGetProfileDomain.</para>
 /// <para>ERROR: CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle.</para>
 /// <para>VERSION: cgGetProgramDomain was introduced in Cg 2.2.</para>
 /// </summary>
 /// <param name="program">The program.</param>
 /// <returns>Returns the domain enumerant associated with program.</returns>
 public static CgDomain GetProgramDomain(CgProgram program)
 {
     return cgGetProgramDomain(program);
 }
Example #21
0
 /// <summary>
 /// <para>cgSetProgramStateAssignment sets the value of a state assignment of program type.</para>
 /// <para>ERROR: CG_INVALID_STATE_ASSIGNMENT_HANDLE_ERROR is generated if sa is not a valid state assignment. CG_STATE_ASSIGNMENT_TYPE_MISMATCH_ERROR is generated if sa is not a state assignment of a program type. CG_ARRAY_SIZE_MISMATCH_ERROR is generated if sa is an array and not a scalar. CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle.</para>
 /// <para>VERSION: cgSetProgramStateAssignment was introduced in Cg 1.5.</para>
 /// </summary>
 /// <param name="sa">A handle to a state assignment of type CG_PROGRAM_TYPE.</param>
 /// <param name="program">The program object to which sa will be set.</param>
 /// <returns>Returns CG_TRUE if it succeeds in setting the state assignment. Returns CG_FALSE otherwise.</returns>
 public static CgBool SetProgramStateAssignment(CgStateAssignment sa, CgProgram program)
 {
     return cgSetProgramStateAssignment(sa, program);
 }
Example #22
0
 /// <summary>
 /// <para>A combined program consists of multiple domain programs.</para>
 /// <para>For example, a combined program may contain a vertex domain program and a fragment domain program.</para>
 /// <para>cgGetProgramDomainProgram gets the indexed domain program of the specified combined program.</para>
 /// <para>ERROR: CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle. CG_INVALID_PARAMETER_ERROR is generated if index is less than 0 or greater than or equal to the number of domains in program.</para>
 /// <para>VERSION: cgGetProgramDomainProgram was introduced in Cg 2.1.</para>
 /// </summary>
 /// <param name="program">The handle of the combined program object.</param>
 /// <param name="index">The index of the program's domain program to be queried.</param>
 /// <returns>Returns the program handle for the program with the given domain index. Returns 0 if an error occurs.</returns>
 public static CgProgram GetProgramDomainProgram(CgProgram program, int index)
 {
     return cgGetProgramDomainProgram(program, index);
 }
Example #23
0
 /// <summary>
 /// <para>cgCreateProgramAnnotation adds a new annotation to a program.</para>
 /// <para>ERROR: CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle. CG_DUPLICATE_NAME_ERROR is generated if name is already used by an annotation for this program. CG_INVALID_ENUMERANT_ERROR is generated if type is not CG_INT, CG_FLOAT, CG_BOOL, or CG_STRING.</para>
 /// <para>VERSION: cgCreateProgramAnnotation was introduced in Cg 1.5.</para>
 /// </summary>
 /// <param name="program">The program to which the new annotation will be added.</param>
 /// <param name="name">The name of the new annotation.</param>
 /// <param name="type">The type of the new annotation.</param>
 /// <returns>Returns the new CGannotation handle on success. Returns NULL if an error occurs.</returns>
 public static CgAnnotation CreateProgramAnnotation(CgProgram program, [In]string name, CgType type)
 {
     return cgCreateProgramAnnotation(program, name, type);
 }
Example #24
0
        /// <summary>
        /// <para>cgGetProgramOptions allows the application to retrieve the set of options used to compile the program.</para>
        /// <para>ERROR: CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle.</para>
        /// <para>VERSION: cgGetProgramOptions was introduced in Cg 1.4.</para>
        /// </summary>
        /// <param name="program">The Cg program to query.</param>
        /// <returns>Returns the options used to compile the program as an array of NULL-terminated strings. Returns NULL if no options exist, or if an error occurs.</returns>
        public static string[] GetProgramOptions(CgProgram program)
        {
            IntPtr ptr = cgGetProgramOptions(program);

            if (ptr == IntPtr.Zero) return null;

            unsafe
            {
                var byteArray = (byte**)ptr;
                var lines = new List<string>();
                var buffer = new List<byte>();

                for (; ; )
                {
                    byte* b = *byteArray;
                    for (; ; )
                    {
                        if (b == null || *b == '\0')
                        {
                            if (buffer.Count > 0)
                            {
                                char[] cc = Encoding.ASCII.GetChars(buffer.ToArray());
                                lines.Add(new string(cc));
                                buffer.Clear();
                            }
                            break;
                        }
                        buffer.Add(*b);
                        b++;
                    }
                    byteArray++;

                    if (b == null) break;
                }
                return lines.Count == 0 ? null : lines.ToArray();
            }
        }
Example #25
0
 /// <summary>
 /// <para>cgEvaluateProgram evaluates a Cg program at a set of regularly spaced points in one, two, or three dimensions.</para>
 /// <para>The program must have been compiled with the CG_PROFILE_GENERIC profile.</para>
 /// <para>The value returned from the program via the COLOR semantic is stored in the given buffer for each evaluation point, and any varying parameters to the program with POSITION semantic take on the (x,y,z) position over the range zero to one at which the program is evaluated at each point.</para>
 /// <para>The PSIZE semantic can be used to find the spacing between evaluating points.</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 program's profile is not CG_PROFILE_GENERIC. CG_INVALID_PARAMETER_ERROR is generated if buf is NULL, any of nx, ny, or nz is less than zero, or ncomps is not 0, 1, 2, or 3.</para>
 /// <para>VERSION: cgEvaluateProgram was introduced in Cg 1.4.</para>
 /// </summary>
 /// <param name="program">The program to be evalutated.</param>
 /// <param name="buf">Buffer in which to store the results of program evaluation.</param>
 /// <param name="ncomps">Number of components to store for each returned program value.</param>
 /// <param name="nx">Number of points at which to evaluate the program in the x direction.</param>
 /// <param name="ny">Number of points at which to evaluate the program in the y direction.</param>
 /// <param name="nz">Number of points at which to evaluate the program in the z direction.</param>
 public static void EvaluateProgram(CgProgram program, [In][Out]float[] buf, int ncomps, int nx, int ny, int nz)
 {
     cgEvaluateProgram(program, buf, ncomps, nx, ny, nz);
 }
Example #26
0
 /// <summary>
 /// <para>cgGetProgramOutput returns the program output enumerant.</para>
 /// <para>ERROR: CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle.</para>
 /// <para>VERSION: cgGetProgramOutput was introduced in Cg 2.0.</para>
 /// </summary>
 /// <param name="program">A program handle.</param>
 /// <returns>Returns a program output enumerant. If the program is a vertex or fragment program, it returns CG_VERTEX or CG_FRAGMENT, respectively. For geometry programs the output is one of: CG_POINT_OUT, CG_LINE_OUT, or CG_TRIANGLE_OUT. For tessellation control programs the output is CG_PATCH. Returns CG_UNKNOWN if the output is unknown.</returns>
 public static CgEnum GetProgramOutput(CgProgram program)
 {
     return cgGetProgramOutput(program);
 }
Example #27
0
 /// <summary>
 /// <para>cgGetProgramProfile retrieves the profile enumerant currently associated with a program.</para>
 /// <para>ERROR: CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle.</para>
 /// <para>VERSION: cgGetProgramProfile was introduced in Cg 1.1.</para>
 /// </summary>
 /// <param name="program">The program.</param>
 /// <returns>Returns the profile enumerant associated with program.</returns>
 public static CgProfile GetProgramProfile(CgProgram program)
 {
     return cgGetProgramProfile(program);
 }
Example #28
0
 /// <summary>
 /// <para>cgGetProgramString allows the application to retrieve program strings that have been set via functions that modify program state.</para>
 /// <para>ERROR: CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle. CG_INVALID_ENUMERANT_ERROR is generated if enum is not CG_PROGRAM_SOURCE, CG_PROGRAM_ENTRY, CG_PROGRAM_PROFILE, or CG_COMPILED_PROGRAM.</para>
 /// <para>VERSION: cgGetProgramString was introduced in Cg 1.1.</para>
 /// </summary>
 /// <param name="program">The program to query.</param>
 /// <param name="sourceType">Specifies the string to retrieve. enum can be one of CG_PROGRAM_SOURCE, CG_PROGRAM_ENTRY, CG_PROGRAM_PROFILE, or CG_COMPILED_PROGRAM.</param>
 /// <returns>Returns a NULL-terminated string based on the value of enum. Returns an empty string if an error occurs.</returns>
 public static string GetProgramString(CgProgram program, CgEnum sourceType)
 {
     return Marshal.PtrToStringAnsi(cgGetProgramString(program, sourceType));
 }
Example #29
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);
        }
Example #30
0
 /// <summary>
 /// <para>The annotations associated with a program can be retrieved using cgGetFirstProgramAnnotation.</para>
 /// <para>The remainder of the program's annotations can be discovered by iterating through the parameters, calling cgGetNextAnnotation to get to the next one.</para>
 /// <para>ERROR: CG_INVALID_PROGRAM_HANDLE_ERROR is generated if program is not a valid program handle.</para>
 /// <para>VERSION: cgGetFirstProgramAnnotation was introduced in Cg 1.4.</para>
 /// </summary>
 /// <param name="program">The program from which to retrieve the annotation.</param>
 /// <returns>Returns the first annotation from the given program. Returns NULL if the program has no annotations.</returns>
 public static CgAnnotation GetFirstProgramAnnotation(CgProgram program)
 {
     return cgGetFirstProgramAnnotation(program);
 }