cocos2d::glprogramstate分析

先看看和glprogram的区别,下面是官方的解释:

/**

GLProgramState holds the 'state' (uniforms and attributes) of the GLProgram.

A GLProgram can be used by thousands of Nodes, but if different uniform values

are going to be used, then each node will need its own GLProgramState

*/


可见大多是对于uniform的赋值


glprogram根据一个program创建:


初始化如下:

init中增加了program的引用计数,然后把program中的attribute和uniform的map保存下来



2、glprogramcache

单例用来缓存shader

回到glprogramstate,默认的外部接口:


从cache中拿到缓存的shader

然后看保存的state中是否有,有则返回,无则加入到缓存state中


注意,programstate最后调用的是program的initWithByteArrays,并没有调用createWithByteArrays,但是和createWithByteArrays的流程一样,initWithByteArrays->link->updateuniform


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 10,127评论 0 23
  • 在打算做一款产品时,有了初步的思路之后,并不着急推进开发,而是带着最初的这个想法去找一些客户来验证我们产品能否满足...
    思考者01阅读 809评论 0 0
  • 你总是一个人 游戏这凡尘 想来就来,想去就去 春风吹梦了无痕 你总是一个人 品尝这苦闷 不与人说,不分与人 酒杯端...
    日梦白阅读 221评论 0 1