我的github
posts - 3243,  comments - 42,  views - 158万

该类有几个成员变量:

复制代码
        private readonly ShaderObjectGL3x _vertexShader;
        private readonly ShaderObjectGL3x _geometryShader;
        private readonly ShaderObjectGL3x _fragmentShader;
        private readonly ShaderProgramNameGL3x _program;
        private readonly FragmentOutputsGL3x _fragmentOutputs;
        private readonly ShaderVertexAttributeCollection _vertexAttributes;
        private readonly IList<ICleanable> _dirtyUniforms;
        private readonly UniformCollection _uniforms;
        private readonly UniformBlockCollection _uniformBlocks;
复制代码

构造函数:

复制代码
public ShaderProgramGL3x(string vertexShaderSource,string geometryShaderSource,string fragmentShaderSource)
{
            _vertexShader = new ShaderObjectGL3x(ShaderType.VertexShader, vertexShaderSource);
            if (geometryShaderSource.Length > 0)
            {
                _geometryShader = new ShaderObjectGL3x(ShaderType.GeometryShaderExt, geometryShaderSource);
            }
            _fragmentShader = new ShaderObjectGL3x(ShaderType.FragmentShader, fragmentShaderSource);

            _program = new ShaderProgramNameGL3x();
            int programHandle = _program.Value;

            GL.AttachShader(programHandle, _vertexShader.Handle);
            if (geometryShaderSource.Length > 0)
            {
                GL.AttachShader(programHandle, _geometryShader.Handle);
            }
            GL.AttachShader(programHandle, _fragmentShader.Handle);

            GL.LinkProgram(programHandle);

            int linkStatus;
            GL.GetProgram(programHandle, ProgramParameter.LinkStatus, out linkStatus);

            if (linkStatus == 0)
            {
                throw new CouldNotCreateVideoCardResourceException("Could not link shader program.  Link Log:  \n\n" + ProgramInfoLog);
            }

            _fragmentOutputs = new FragmentOutputsGL3x(_program);
            _vertexAttributes = FindVertexAttributes(_program);
            _dirtyUniforms = new List<ICleanable>();
            _uniforms = FindUniforms(_program);
            _uniformBlocks = FindUniformBlocks(_program);

            InitializeAutomaticUniforms(_uniforms);
}
复制代码

传入两个参数:vertexShaderSource和fragmentShaderSource,利用ShaderObjectGL3x对它们初始化(编译)。然后将两个shader的句柄handle链接到programHandle。最后获取_fragmentOutputs、 _vertexAttributes、_dirtyUniforms、_uniforms、_uniformBlocks几个变量的值。

posted on   XiaoNiuFeiTian  阅读(4)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
历史上的今天:
2020-10-30 天地图sdk
2020-10-30 C#与COM组件
2020-10-30 C#组件
2019-10-30 java jts
2018-10-30 自然语言处理+语义图像处理(机器视觉)
2015-10-30 制作一个导航卫星绕地球转动的3D Flash动画
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示