CCShaderCache 储存不同的shader
CCGLProgram是cocos封装的shader类
包含变量m_uProgram是opengl的shader
m_uVertShader是渲染定点的着色器
m_uFragShader是片源着色器
shader程序glCreateProgram-》compileShader-》glAttachShader-》glLinkProgram-》ccGLUseProgram 完成着色器的使用
CCDrawNode中的渲染方式是,glGenBuffers-》glBindBuffer-》glBufferData
使用glEnableVertexAttribArray和glVertexAttribPointer用于开启属性,和定位属性装载的内存位置,glBindAttribLocation把属性绑定到对应的shader变量中,以备使用;
来自glGetAttribLocation 的解释
The association between an attribute variable name and a generic attribute index can be specified at any time by calling glBindAttribLocation. Attribute bindings do not go into effect until glLinkProgram is called. After a program object has been linked successfully, the index values for attribute variables remain fixed until the next link command occurs. The attribute values can only be queried after a link if the link was successful. glGetAttribLocation
returns the binding that actually went into effect the last time glLinkProgram was called for the specified program object. Attribute bindings that have been specified since the last link operation are not returned by glGetAttribLocation
.
意思是glGetAttribLocation 获取的属性来自glBindAttribLocation绑定的结果,而绑定属性名要在glLinkProgram后才生效,而且连接一次后,没办法改变绑定。
glDrawArrays是直接根据mode方式把定点列表绘制
glDrawElements是根据传入的索引列表,绘制,