openGL之API学习(一一六)glAttachShader

将着色器对象附加到program对象。多个同类型(例如都是vertex shader类型,或都是fragment shader类型)的shader对象不能被附着到同一个program对象上(来自https://www.khronos.org/registry/OpenGL-Refpages/es3.0/,OpenGL ES 3.0 and OpenGL ES Shading Language 3.00 )。但是,单个shader对象可以被附着到多个program对象上,但是osgEarth的代码中会将多个shader绑定到同一个program上(见osgEarth的Rex引擎原理分析问题129)(It is permissible to attach multiple shader objects of the same type because each may contain a portion of the complete shader.来自https://www.khronos.org/opengl/wiki/GLAPI/glAttachShader,这是和OpenGL 4.5 and OpenGL Shading Language 4.50 一致的)。看来不同版本对此函数的说明是不同的。

void glAttachShader(     GLuint program,
      GLuint shader);

program

    Specifies the program object to which a shader object will be attached.

    指定着色器对象将附加到的program对象。
shader

    Specifies the shader object that is to be attached.

    指定要附加的着色器对象。

发布了388 篇原创文章 · 获赞 36 · 访问量 12万+

猜你喜欢

转载自blog.csdn.net/hankern/article/details/104026876