cocos2d-x shader

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是根据传入的索引列表,绘制,

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值