本文整理汇总了C++中CCGLProgram::autorelease方法的典型用法代码示例。如果您正苦于以下问题:C++ CCGLProgram::autorelease方法的具体用法?C++ CCGLProgram::autorelease怎么用?C++ CCGLProgram::autorelease使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCGLProgram
的用法示例。
在下文中一共展示了CCGLProgram::autorelease方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadShader
void ShaderManager::loadShader(const char* key, const GLchar* vertexShader, const GLchar* fragShader)
{
CCGLProgram * ccProgram = CCShaderCache::sharedShaderCache()->programForKey(key);
if (ccProgram == NULL)
{
ccProgram = new CCGLProgram();
ccProgram->autorelease();
CCShaderCache::sharedShaderCache()->addProgram(ccProgram, key);
}
else
{
ccProgram->reset();
}
ccProgram->initWithVertexShaderByteArray(vertexShader, fragShader);
CHECK_GL_ERROR_DEBUG();
ccProgram->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);
ccProgram->addAttribute(kCCAttributeNameColor, kCCVertexAttrib_Color);
ccProgram->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);
CHECK_GL_ERROR_DEBUG();
// 自定义着色器链接
ccProgram->link();
CHECK_GL_ERROR_DEBUG();
// 设置移动、缩放、旋转矩阵
ccProgram->updateUniforms();
CHECK_GL_ERROR_DEBUG();
}
示例2: loadCustomShader
void CCShaders::loadCustomShader(const string& key) {
if(!CCShaderCache::sharedShaderCache()->programForKey(key.c_str())) {
// load shader
CCGLProgram* p = new CCGLProgram();
p->autorelease();
LOAD_PROGRAM_IF(flash);
LOAD_PROGRAM_IF(blur);
// add attribute
if(false) {
// non-default situation
} else {
p->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);
p->addAttribute(kCCAttributeNameColor, kCCVertexAttrib_Color);
p->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);
}
// link it
p->link();
// add custom uniform
if(key == kCCShader_flash) {
ADD_UNIFORM(flashColor);
ADD_UNIFORM(flashTime);
} else if(key == kCCShader_blur) {
ADD_UNIFORM(blurSize);
ADD_UNIFORM(blurSubtract);
}
// add standard uniforms
p->updateUniforms();
// add program
CCShaderCache::sharedShaderCache()->addProgram(p, key.c_str());
}
}