当前位置: 首页>>代码示例>>C#>>正文


C# Program.Load方法代码示例

本文整理汇总了C#中Program.Load方法的典型用法代码示例。如果您正苦于以下问题:C# Program.Load方法的具体用法?C# Program.Load怎么用?C# Program.Load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Program的用法示例。


在下文中一共展示了Program.Load方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnLoad

        /// <summary>
        /// Setup OpenGL and load resources here.
        /// </summary>
        /// <param name="e">Not used.</param>
        protected override void OnLoad(EventArgs e)
        {
            GL.ClearColor(0.1f, 0.3f, 0.6f, 0.0f); /* Blue background */

            this.CgContext = CgNet.Context.Create();
            CgGL.SetDebugMode(false);
            this.CgContext.ParameterSettingMode = ParameterSettingMode.Deferred;

            vertexProfile = ProfileClass.Vertex.GetLatestProfile();
            vertexProfile.SetOptimalOptions();

            vertexProgram =
                this.CgContext.CreateProgramFromFile(
                    ProgramType.Source, /* Program in human-readable form */
                    VertexProgramFileName, /* Name of file containing program */
                    vertexProfile, /* Profile: OpenGL ARB vertex program */
                    VertexProgramName, /* Entry function name */
                    null); /* No extra compiler options */
            vertexProgram.Load();

            fragmentProfile = ProfileClass.Fragment.GetLatestProfile();
            fragmentProfile.SetOptimalOptions();

            fragmentProgram =
                this.CgContext.CreateProgramFromFile(
                    ProgramType.Source, /* Program in human-readable form */
                    FragmentProgramFileName, /* Name of file containing program */
                    fragmentProfile, /* Profile: OpenGL ARB vertex program */
                    FragmentProgramName, /* Entry function name */
                    null); /* No extra compiler options */
            fragmentProgram.Load();
        }
开发者ID:himanshugoel2797,项目名称:CrossEngine,代码行数:36,代码来源:VertexAndFragmentProgram.cs

示例2: OnLoad

        /// <summary>
        /// Setup OpenGL and load resources here.
        /// </summary>
        /// <param name="e">Not used.</param>
        protected override void OnLoad(EventArgs e)
        {
            GL.ClearColor(0.1f, 0.3f, 0.6f, 0.0f); /* Blue background */

            GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1); /* Tightly packed texture data. */
            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);

            this.CgContext = CgNet.Context.Create();

            CgGL.SetDebugMode(false);
            this.CgContext.ParameterSettingMode = ParameterSettingMode.Deferred;

            vertexProfile = ProfileClass.Vertex.GetLatestProfile();
            vertexProfile.SetOptimalOptions();

            vertexProgram =
                this.CgContext.CreateProgramFromFile(
                    ProgramType.Source, /* Program in human-readable form */
                    VertexProgramFileName, /* Name of file containing program */
                    vertexProfile, /* Profile: OpenGL ARB vertex program */
                    VertexProgramName, /* Entry function name */
                    null); /* No extra compiler options */

            vertexProgram.Load();

            /* No uniform vertex program parameters expected. */
            fragmentProfile = ProfileClass.Fragment.GetLatestProfile();
            fragmentProfile.SetOptimalOptions();

            fragmentProgram =
                this.CgContext.CreateProgramFromFile(
                    ProgramType.Source, /* Program in human-readable form */
                    FragmentProgramFileName, /* Name of file containing program */
                    fragmentProfile, /* Profile: OpenGL ARB vertex program */
                    FragmentProgramName, /* Entry function name */
                    null); /* No extra compiler options */

            fragmentProgram.Load();

            this.fragmentParamDecal = fragmentProgram.GetNamedParameter("decal");

            this.fragmentParamDecal.SetTexture(666);
        }
开发者ID:corngood,项目名称:cgnet,代码行数:53,代码来源:TextureSampling.cs

示例3: OnLoad

        /// <summary>
        /// Setup OpenGL and load resources here.
        /// </summary>
        /// <param name="e">Not used.</param>
        protected override void OnLoad(EventArgs e)
        {
            GL.ClearColor(0.1f, 0.3f, 0.6f, 0.0f); /* Blue background */

            this.CgContext = CgNet.Context.Create();

            CgGL.SetDebugMode(false);
            this.CgContext.ParameterSettingMode = ParameterSettingMode.Deferred;

            vertexProfile = ProfileClass.Vertex.GetLatestProfile();
            vertexProfile.SetOptimalOptions();

            this.CgContext.SetCompilerIncludeString("shader/output.cg",
            @"
            struct Output {
                float4 position : POSITION;
                float3 color    : COLOR;
            };");

            this.CgContext.SetCompilerIncludeString("shader/vertexProgram.cg",
            @"
            #include ""output.cg""
            Output vertexProgram(float2 position : POSITION)
            {
                Output OUT;
                OUT.position = float4(position,0,1);
                OUT.color = float3(0,1,0);
                return OUT;
            }");

            vertexProgram =
              this.CgContext.CreateProgram(
                ProgramType.Source,                 /* Program in human-readable form */
               "#include \"vertexProgram.cg\"\n",
                vertexProfile,         /* Profile: OpenGL ARB vertex program */
                "vertexProgram",           /* Entry function name */
                Args);                    /* Include path options */
            vertexProgram.Load();
        }
开发者ID:himanshugoel2797,项目名称:CrossEngine,代码行数:43,代码来源:IncludeString.cs

示例4: OnLoad

        /// <summary>
        /// Setup OpenGL and load resources here.
        /// </summary>
        /// <param name="e">Not used.</param>
        protected override void OnLoad(EventArgs e)
        {
            this.ResetParticles();

            GL.ClearColor(0.2f, 0.6f, 1.0f, 1); /* Blue background */
            GL.PointSize(6.0f);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            GL.Enable(EnableCap.PointSmooth);
            GL.Enable(EnableCap.Blend);
            GL.Enable(EnableCap.Texture1D);
            this.CgContext = CgNet.Context.Create();
            CgGL.SetDebugMode(false);

            vertexProfile = ProfileClass.Vertex.GetLatestProfile();
            vertexProfile.SetOptimalOptions();

            vertexProgram =
                this.CgContext.CreateProgramFromFile(
                    ProgramType.Source, /* Program in human-readable form */
                    VertexProgramFileName, /* Name of file containing program */
                    vertexProfile, /* Profile: OpenGL ARB vertex program */
                    VertexProgramName, /* Entry function name */
                    null); /* No extra compiler options */

            vertexProgram.Load();

            this.vertexParamGlobalTime =
                vertexProgram.GetNamedParameter("globalTime");

            this.vertexParamAcceleration =
                vertexProgram.GetNamedParameter("acceleration");

            this.vertexParamModelViewProj =
                vertexProgram.GetNamedParameter("modelViewProj");

            fragmentProfile = ProfileClass.Fragment.GetLatestProfile();
            fragmentProfile.SetOptimalOptions();

            fragmentProgram =
                this.CgContext.CreateProgramFromFile(
                    ProgramType.Source, /* Program in human-readable form */
                    FragmentProgramFileName, /* Name of file containing program */
                    fragmentProfile, /* Profile: OpenGL ARB vertex program */
                    FragmentProgramName, /* Entry function name */
                    null); /* No extra compiler options */
            fragmentProgram.Load();
        }
开发者ID:corngood,项目名称:cgnet,代码行数:51,代码来源:ParticleSystem.cs

示例5: OnLoad

        /// <summary>
        /// Setup OpenGL and load resources here.
        /// </summary>
        /// <param name="e">Not used.</param>
        protected override void OnLoad(EventArgs e)
        {
            GL.ClearColor(0.1f, 0.3f, 0.6f, 0.0f); /* Blue background */
            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.Texture2D);
            GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1); /* Tightly packed texture data. */

            GL.GenTextures(2, texObj);

            GL.BindTexture(TextureTarget.Texture2D, texObj[1]);
            /* Load each mipmap level of range-compressed 128x128 brick normal
               map texture. */
            unsafe
            {
                fixed (byte* b = ImageBrick.Array)
                {
                    byte* image = b;

                    int size;
                    int level;
                    for (size = 128, level = 0;
                         size > 0;
                         image += 3 * size * size, size /= 2, level++)
                    {
                        GL.TexImage2D(TextureTarget.Texture2D, level,
                                      PixelInternalFormat.Rgba8, size, size, 0,
                                      PixelFormat.Rgb, PixelType.UnsignedByte, new IntPtr(image));
                    }
                }
            }

            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)All.LinearMipmapLinear);

            GL.BindTexture(TextureTarget.TextureCubeMap, texObj[0]);
            /* Load each 32x32 face (without mipmaps) of range-compressed "normalize
               vector" cube map. */
            unsafe
            {
                fixed (byte* b = ImageNormcm.Array)
                {
                    byte* image = b;

                    int face;
                    for (face = 0;
                         face < 6;
                         face++, image += 3 * 32 * 32)
                    {
                        GL.TexImage2D(TextureTarget.TextureCubeMapPositiveX + face, 0,
                                      PixelInternalFormat.Rgba8, 32, 32, 0,
                                      PixelFormat.Rgb, PixelType.UnsignedByte, new IntPtr(image));
                    }
                }
            }

            GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureMinFilter, (int)All.Linear);
            GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureWrapS, (int)All.ClampToEdge);
            GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureWrapT, (int)All.ClampToEdge);

            this.CgContext = CgNet.Context.Create();
            CgGL.SetDebugMode(false);
            this.CgContext.ParameterSettingMode = ParameterSettingMode.Deferred;
            this.CgContext.SetManageTextureParameters(true);

            vertexProfile = ProfileClass.Vertex.GetLatestProfile();
            vertexProfile.SetOptimalOptions();

            vertexProgram =
                this.CgContext.CreateProgramFromFile(
                    ProgramType.Source, /* Program in human-readable form */
                    VertexProgramFileName, /* Name of file containing program */
                    vertexProfile, /* Profile: OpenGL ARB vertex program */
                    VertexProgramName, /* Entry function name */
                    null); /* No extra compiler options */
            vertexProgram.Load();

            this.myCgVertexParam_lightPosition =
                vertexProgram.GetNamedParameter("lightPosition");

            this.myCgVertexParam_eyePosition =
                vertexProgram.GetNamedParameter("eyePosition");

            this.myCgVertexParam_modelViewProj =
                vertexProgram.GetNamedParameter("modelViewProj");

            fragmentProfile = ProfileClass.Fragment.GetLatestProfile();
            fragmentProfile.SetOptimalOptions();

            fragmentProgram =
                this.CgContext.CreateProgramFromFile(
                    ProgramType.Source, /* Program in human-readable form */
                    FragmentProgramFileName, /* Name of file containing program */
                    fragmentProfile, /* Profile: OpenGL ARB vertex program */
                    FragmentProgramName, /* Entry function name */
                    null); /* No extra compiler options */
            fragmentProgram.Load();

//.........这里部分代码省略.........
开发者ID:himanshugoel2797,项目名称:CrossEngine,代码行数:101,代码来源:SpecularBumpMap.cs

示例6: OnLoad

        /// <summary>
        /// Setup OpenGL and load resources here.
        /// </summary>
        /// <param name="e">Not used.</param>
        protected override void OnLoad(EventArgs e)
        {
            GL.ClearColor(0.1f, 0.3f, 0.6f, 0.0f); /* Blue background */
            GL.Enable(EnableCap.DepthTest);
            this.CgContext = CgNet.Context.Create();
            CgGL.SetDebugMode(false);
            this.CgContext.ParameterSettingMode = ParameterSettingMode.Deferred;

            vertexProfile = ProfileClass.Vertex.GetLatestProfile();
            vertexProfile.SetOptimalOptions();

            vertexProgram =
                this.CgContext.CreateProgramFromFile(
                    ProgramType.Source, /* Program in human-readable form */
                    VertexProgramFileName, /* Name of file containing program */
                    vertexProfile, /* Profile: OpenGL ARB vertex program */
                    VertexProgramName, /* Entry function name */
                    null); /* No extra compiler options */
            vertexProgram.Load();

            this.vertexParamModelViewProj = vertexProgram.GetNamedParameter("modelViewProj");
            this.vertexParamTime = vertexProgram.GetNamedParameter("time");
            this.vertexParamFrequency = vertexProgram.GetNamedParameter("frequency");
            this.vertexParamScaleFactor = vertexProgram.GetNamedParameter("scaleFactor");
            this.vertexParamKd = vertexProgram.GetNamedParameter("Kd");
            this.vertexParamShininess = vertexProgram.GetNamedParameter("shininess");
            this.vertexParamEyePosition = vertexProgram.GetNamedParameter("eyePosition");
            this.vertexParamLightPosition = vertexProgram.GetNamedParameter("lightPosition");
            this.vertexParamLightColor = vertexProgram.GetNamedParameter("lightColor");

            /* Set light source color parameters once. */
            this.vertexParamLightColor.Set(myLightColor);

            this.vertexParamScaleFactor.Set(0.3f);
            this.vertexParamFrequency.Set(2.4f);
            this.vertexParamShininess.Set(35f);

            fragmentProfile = ProfileClass.Fragment.GetLatestProfile();
            fragmentProfile.SetOptimalOptions();

            fragmentProgram =
                this.CgContext.CreateProgram(
                    ProgramType.Source, /* Program in human-readable form */
                    "float4 main(float4 c : COLOR) : COLOR { return c; }",
                    fragmentProfile, /* Profile: OpenGL ARB vertex program */
                    "main", /* Entry function name */
                    null); /* No extra compiler options */
            fragmentProgram.Load();

            /* Specify vertex program for rendering the light source with a string. */
            this.lightVertexProgram =
                this.CgContext.CreateProgram(
                    ProgramType.Source, /* Program in human-readable form */
                    @"void main(inout float4 p : POSITION,
                uniform float4x4 modelViewProj,
                out float4 c : COLOR)
                { p = mul(modelViewProj, p); c = float4(1,1,0,1); }",
                    vertexProfile, /* Profile: latest fragment profile */
                    "main", /* Entry function name */
                    null); /* No extra compiler options */

            this.lightVertexProgram.Load();

            this.lightVertexParamModelViewProj =
                this.lightVertexProgram.GetNamedParameter("modelViewProj");
        }
开发者ID:himanshugoel2797,项目名称:CrossEngine,代码行数:70,代码来源:Bulge.cs

示例7: OnLoad

        /// <summary>
        /// Setup OpenGL and load resources here.
        /// </summary>
        /// <param name="e">Not used.</param>
        protected override void OnLoad(EventArgs e)
        {
            GL.ClearColor(0.1f, 0.3f, 0.6f, 0.0f); /* Blue background */
            GL.Enable(EnableCap.DepthTest);
            this.CgContext = CgNet.Context.Create();

            CgGL.SetDebugMode(false);
            this.CgContext.ParameterSettingMode = ParameterSettingMode.Deferred;

            vertexProfile = ProfileClass.Vertex.GetLatestProfile();
            vertexProfile.SetOptimalOptions();

            vertexProgram =
                this.CgContext.CreateProgramFromFile(
                    ProgramType.Source, /* Program in human-readable form */
                    vertexProgramFileName, /* Name of file containing program */
                    vertexProfile, /* Profile: OpenGL ARB vertex program */
                    vertexProgramName, /* Entry function name */
                    null); /* No extra compiler options */
            vertexProgram.Load();

            this.myCgVertexParam_modelViewProj = vertexProgram.GetNamedParameter("modelViewProj");

            fragmentProfile = ProfileClass.Fragment.GetLatestProfile();
            fragmentProfile.SetOptimalOptions();

            /* Specify "color passthrough" fragment program with a string. */
            fragmentProgram =
                this.CgContext.CreateProgramFromFile(
                    ProgramType.Source, /* Program in human-readable form */
                    fragmentProgramFileName,
                    fragmentProfile, /* Profile: latest fragment profile */
                    fragmentProgramName, /* Entry function name */
                    null); /* No extra compiler options */
            fragmentProgram.Load();

            this.myCgFragmentParam_globalAmbient = fragmentProgram.GetNamedParameter("globalAmbient");
            this.myCgFragmentParam_lightColor = fragmentProgram.GetNamedParameter("lightColor");
            this.myCgFragmentParam_lightPosition = fragmentProgram.GetNamedParameter("lightPosition");
            this.myCgFragmentParam_eyePosition = fragmentProgram.GetNamedParameter("eyePosition");
            this.myCgFragmentParam_Ke = fragmentProgram.GetNamedParameter("Ke");
            this.myCgFragmentParam_Ka = fragmentProgram.GetNamedParameter("Ka");
            this.myCgFragmentParam_Kd = fragmentProgram.GetNamedParameter("Kd");
            this.myCgFragmentParam_Ks = fragmentProgram.GetNamedParameter("Ks");
            this.myCgFragmentParam_shininess = fragmentProgram.GetNamedParameter("shininess");

            /* Set light source color parameters once. */
            this.myCgFragmentParam_globalAmbient.Set(this.myGlobalAmbient);
            this.myCgFragmentParam_lightColor.Set(this.myLightColor);
        }
开发者ID:himanshugoel2797,项目名称:CrossEngine,代码行数:54,代码来源:FragmentLighting.cs

示例8: OnLoad

        /// <summary>
        /// Setup OpenGL and load resources here.
        /// </summary>
        /// <param name="e">Not used.</param>
        protected override void OnLoad(EventArgs e)
        {
            GL.ClearColor(0.1f, 0.1f, 0.1f, 0.0f);
            GL.Enable(EnableCap.DepthTest);
            this.CgContext = CgNet.Context.Create();

            CgGL.SetDebugMode(false);
            this.CgContext.ParameterSettingMode = ParameterSettingMode.Deferred;
            this.CgContext.SetManageTextureParameters(true);

            vertexProfile = ProfileClass.Vertex.GetLatestProfile();
            vertexProfile.SetOptimalOptions();

            vertexProgram =
                this.CgContext.CreateProgramFromFile(
                    ProgramType.Source, /* Program in human-readable form */
                    VertexProgramFileName, /* Name of file containing program */
                    vertexProfile, /* Profile: OpenGL ARB vertex program */
                    VertexProgramName, /* Entry function name */
                    null); /* No extra compiler options */
            vertexProgram.Load();

            this.myCgVertexParamModelViewProj = vertexProgram.GetNamedParameter("modelViewProj");
            this.myCgVertexParamLightPosition = vertexProgram.GetNamedParameter("lightPosition");
            this.myCgVertexParamKd = vertexProgram.GetNamedParameter("Kd");
            this.myCgVertexParamTextureMatrix = vertexProgram.GetNamedParameter("textureMatrix");

            /* Set light source color parameters once. */
            this.myCgVertexParamKd.Set(this.kd);

            fragmentProfile = ProfileClass.Fragment.GetLatestProfile();
            fragmentProfile.SetOptimalOptions();

            /* Specify "color passthrough" fragment program with a string. */
            fragmentProgram =
                this.CgContext.CreateProgramFromFile(
                    ProgramType.Source, /* Program in human-readable form */
                    FragmentProgramFileName,
                    fragmentProfile, /* Profile: latest fragment profile */
                    FragmentProgramName, /* Entry function name */
                    null); /* No extra compiler options */
            fragmentProgram.Load();
            this.SetupDemonSampler();
        }
开发者ID:corngood,项目名称:cgnet,代码行数:48,代码来源:ProjectiveTexturing.cs

示例9: CreateCgPrograms

        private void CreateCgPrograms()
        {
            CgD3D9.SetDevice(this.device);
            /* Determine the best profile once a device to be set. */
            vertexProfile = CgD3D9.GetLatestVertexProfile();

            string[] profileOpts = CgD3D9.GetOptimalOptions(vertexProfile);

            vertexProgram =
                CgContext.CreateProgramFromFile(
                    ProgramType.Source, /* Program in human-readable form */
                    VertexProgramFileName, /* Name of file containing program */
                    vertexProfile, /* Profile: OpenGL ARB vertex program */
                    VertexProgramName, /* Entry function name */
                    profileOpts); /* Pass optimal compiler options */

            fragmentProfile = CgD3D9.GetLatestPixelProfile();
            profileOpts = CgD3D9.GetOptimalOptions(fragmentProfile);
            fragmentProgram =
                CgContext.CreateProgramFromFile(
                    ProgramType.Source,
                    FragmentProgramFileName,
                    fragmentProfile,
                    FragmentProgramName,
                    profileOpts);

            vertexProgram.Load(false, 0);
            fragmentProgram.Load(false, 0);
        }
开发者ID:himanshugoel2797,项目名称:CrossEngine,代码行数:29,代码来源:VertexFragmentProgram.cs

示例10: OnLoad

        /// <summary>
        /// Setup OpenGL and load resources here.
        /// </summary>
        /// <param name="e">Not used.</param>
        protected override void OnLoad(EventArgs e)
        {
            GL.ClearColor(0.1f, 0.3f, 0.6f, 0.0f); /* Blue background */

            this.CgContext = CgNet.Context.Create();
            CgGL.SetDebugMode(false);
            this.CgContext.ParameterSettingMode = ParameterSettingMode.Deferred;

            geometryProfile = ProfileType.GlslG;
            CgGL.SetOptimalOptions(geometryProfile);

            geometryProgram =
             Program.CreateFromFile(
                CgContext,                /* Cg runtime context */
                ProgramType.Source,                  /* Program in human-readable form */
                GeometryProgramFileName,  /* Name of file containing program */
                geometryProfile,        /* Profile: OpenGL ARB geometry program */
                GeometryProgramName,      /* Entry function name */
                null);                      /* No extra compiler options */

            var x = CgContext.LastListing;

            vertexProfile = ProfileType.GlslV;
            vertexProfile.SetOptimalOptions();

            vertexProgram =
               Program.CreateFromFile(
                 CgContext,              /* Cg runtime context */
                 ProgramType.Source,                /* Program in human-readable form */
                 VertexProgramFileName,  /* Name of file containing program */
                 vertexProfile,        /* Profile: OpenGL ARB vertex program */
                 VertexProgramName,      /* Entry function name */
                 null);                    /* No extra compiler options */

            fragmentProfile = ProfileType.GlslF;
             fragmentProfile.SetOptimalOptions();

            fragmentProgram =
              Program.CreateFromFile(
                CgContext,                /* Cg runtime context */
                ProgramType.Source,                  /* Program in human-readable form */
                FragmentProgramFileName,  /* Name of file containing program */
                fragmentProfile,        /* Profile: OpenGL ARB fragment program */
                FragmentProgramName,      /* Entry function name */
                null);                      /* No extra compiler options */

            combinedProgram = Program.Combine(vertexProgram, fragmentProgram, geometryProgram);
            combinedProgram.Load();
            Debug.Assert(combinedProgram.DomainsCount == 3);

            vertexProgram.Dispose();
            geometryProgram.Dispose();
            fragmentProgram.Dispose();

            paramShrinkFactor = combinedProgram.GetNamedParameter("shrinkFactor");
        }
开发者ID:corngood,项目名称:cgnet,代码行数:60,代码来源:GsShrinky.cs

示例11: OnLoad

        /// <summary>
        /// Setup OpenGL and load resources here.
        /// </summary>
        /// <param name="e">Not used.</param>
        protected override void OnLoad(EventArgs e)
        {
            GL.ClearColor(0.1f, 0.3f, 0.6f, 0.0f); /* Blue background */

            this.CgContext = CgNet.Context.Create();
            CgGL.SetDebugMode(false);
            this.CgContext.ParameterSettingMode = ParameterSettingMode.Deferred;

            geometryProfile = CgGL.GetLatestProfile(ProfileClass.Geometry);
            if (geometryProfile == ProfileType.Unknown)
            {
                if (ProfileType.GlslG.IsSupported())
                    geometryProfile = ProfileType.GlslG;
                else
                {
                    Environment.Exit(0);
                }
            }

            CgGL.SetOptimalOptions(geometryProfile);

            geometryProgram =
             Program.CreateFromFile(
                CgContext,                /* Cg runtime context */
                ProgramType.Source,                  /* Program in human-readable form */
                GeometryProgramFileName,  /* Name of file containing program */
                geometryProfile,        /* Profile: OpenGL ARB geometry program */
                GeometryProgramName,      /* Entry function name */
                null);                      /* No extra compiler options */

            vertexProfile = ProfileClass.Vertex.GetLatestProfile();
            if (geometryProfile == ProfileType.GlslG)
            {
                vertexProfile = ProfileType.GlslV;
            }

            vertexProfile.SetOptimalOptions();

            vertexProgram =
               Program.CreateFromFile(
                 CgContext,              /* Cg runtime context */
                 ProgramType.Source,                /* Program in human-readable form */
                 VertexProgramFileName,  /* Name of file containing program */
                 vertexProfile,        /* Profile: OpenGL ARB vertex program */
                 VertexProgramName,      /* Entry function name */
                 null);                    /* No extra compiler options */

            fragmentProfile = ProfileClass.Fragment.GetLatestProfile();
            if (geometryProfile == ProfileType.GlslG)
            {
                fragmentProfile = ProfileType.GlslF;
            }

            fragmentProfile.SetOptimalOptions();

            fragmentProgram =
              Program.CreateFromFile(
                CgContext,                /* Cg runtime context */
                ProgramType.Source,                  /* Program in human-readable form */
                FragmentProgramFileName,  /* Name of file containing program */
                fragmentProfile,        /* Profile: OpenGL ARB fragment program */
                FragmentProgramName,      /* Entry function name */
                null);                      /* No extra compiler options */

            if (vertexProfile == ProfileType.GlslV
                && geometryProfile == ProfileType.GlslG
                && fragmentProfile == ProfileType.GlslF)
            {
                /* Combine programs for GLSL... */
                combinedProgram = Program.Combine(vertexProgram, geometryProgram, fragmentProgram);
                combinedProgram.Load();
            }
            else
            {
                /* ...otherwise load programs orthogonally */
                vertexProgram.Load();
                geometryProgram.Load();
                fragmentProgram.Load();
            }
        }
开发者ID:corngood,项目名称:cgnet,代码行数:84,代码来源:GsSimple.cs

示例12: OnLoad

        /// <summary>
        /// Setup OpenGL and load resources here.
        /// </summary>
        /// <param name="e">Not used.</param>
        protected override void OnLoad(EventArgs e)
        {
            GL.ClearColor(0.1f, 0.3f, 0.6f, 0.0f); /* Blue background */

            this.CgContext = CgNet.Context.Create();
            CgGL.SetDebugMode(false);
            this.CgContext.ParameterSettingMode = ParameterSettingMode.Deferred;

            vertexProfile = ProfileClass.Vertex.GetLatestProfile();
            vertexProfile.SetOptimalOptions();

            vertexProgram =
                this.CgContext.CreateProgramFromFile(
                    ProgramType.Source, /* Program in human-readable form */
                    VertexProgramFileName, /* Name of file containing program */
                    vertexProfile, /* Profile: OpenGL ARB vertex program */
                    VertexProgramName, /* Entry function name */
                    null); /* No extra compiler options */
            vertexProgram.Load();

            this.vertexParamModelViewProj = vertexProgram.GetNamedParameter("modelViewProj");

            fragmentProfile = ProfileClass.Fragment.GetLatestProfile();
            fragmentProfile.SetOptimalOptions();

            /* Specify fragment program with a string. */
            fragmentProgram =
                this.CgContext.CreateProgram(
                    ProgramType.Source, /* Program in human-readable form */
                    "float4 main(uniform float4 c) : COLOR { return c; }",
                    fragmentProfile, /* Profile: latest fragment profile */
                    "main", /* Entry function name */
                    null); /* No extra compiler options */
            fragmentProgram.Load();

            this.fragmentParamC = fragmentProgram.GetNamedParameter("c");
        }
开发者ID:himanshugoel2797,项目名称:CrossEngine,代码行数:41,代码来源:VertexTransform.cs


注:本文中的Program.Load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。