本文整理汇总了C++中CCGLProgram::setUniformLocationWithMatrix4fv方法的典型用法代码示例。如果您正苦于以下问题:C++ CCGLProgram::setUniformLocationWithMatrix4fv方法的具体用法?C++ CCGLProgram::setUniformLocationWithMatrix4fv怎么用?C++ CCGLProgram::setUniformLocationWithMatrix4fv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCGLProgram
的用法示例。
在下文中一共展示了CCGLProgram::setUniformLocationWithMatrix4fv方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setEffect
bool FragmentEffect::setEffect(CCNode* pNode,unsigned int sel)
{
if(sel<0 || sel>=m_matrices.size())
return false;
std::vector<EffectListNode>::iterator i = m_nodeList.begin();
std::vector<EffectListNode>::iterator end = m_nodeList.end();
while (i != end)
{
if(i->_pNode == pNode)
{
CCGLProgram* program = i->_pNode->getShaderProgram();
program->use();
program->setUniformLocationWithMatrix4fv(i->_uniformMatrix,
m_matrices[sel]._matrix,
1);
i->_effectSelect = sel;
return true;
}
i++;
}
return false;
}
示例2:
static int tolua_CCGLProgram_CCGLProgram_setUniformLocationWithMatrix4fv00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"CCGLProgram",0,&tolua_err) ||
!tolua_isnumber(tolua_S,2,0,&tolua_err) ||
!tolua_isnumber(tolua_S,3,0,&tolua_err) ||
!tolua_isnumber(tolua_S,4,0,&tolua_err) ||
!tolua_isnoobj(tolua_S,5,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
CCGLProgram* self = (CCGLProgram*) tolua_tousertype(tolua_S,1,0);
int location = ((int) tolua_tonumber(tolua_S,2,0));
float matrixArray = ((float) tolua_tonumber(tolua_S,3,0));
unsigned int numberOfMatrices = ((unsigned int) tolua_tonumber(tolua_S,4,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setUniformLocationWithMatrix4fv'", NULL);
#endif
{
self->setUniformLocationWithMatrix4fv(location,&matrixArray,numberOfMatrices);
tolua_pushnumber(tolua_S,(lua_Number)matrixArray);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'setUniformLocationWithMatrix4fv'.",&tolua_err);
return 0;
#endif
}
示例3: addEffectNode
int FragmentEffect::addEffectNode(CCNode* pNode)
{
do
{
CCGLProgram* program = new CCGLProgram();
GLchar* pszFragSource =
"#ifdef GL_ES \n \
precision mediump float; \n \
#endif \n \
uniform sampler2D u_texture; \n \
varying vec2 v_texCoord; \n \
varying vec4 v_fragmentColor; \n \
uniform mat4 matrixEffect; \n \
void main(void) \n \
{ \n \
gl_FragColor = texture2D(u_texture, v_texCoord)*matrixEffect; \n \
}";
program->initWithVertexShaderByteArray(ccPositionTextureColor_vert, //顶点找色器,这里是引擎自带的
pszFragSource); //像素找色器,这里是自己写的
//将生成的shader程序传给CCSprite类
pNode->setShaderProgram(program);
//要release一次,在上面的setShaderProgram将pProgram托管给CCSprite
//setShaderProgram只调用了pProgram->retain(),没有release(),现在pProgram的m_uReference是2
program->release();
CHECK_GL_ERROR_DEBUG();
//启用顶点着色器的attribute变量,坐标、纹理坐标、颜色 ,去掉其中一个或两个还能工作
program->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);
program->addAttribute(kCCAttributeNameColor, kCCVertexAttrib_Color);
program->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);
CHECK_GL_ERROR_DEBUG();
//自定义着色器链接
program->link();
CHECK_GL_ERROR_DEBUG();
// 设置移动、缩放、旋转矩阵
program->updateUniforms();
CHECK_GL_ERROR_DEBUG();
EffectListNode listNode;
listNode._pNode = pNode;
listNode._effectSelect = 0;
listNode._uniformMatrix = program->getUniformLocationForName("matrixEffect");
program->use();
program->setUniformLocationWithMatrix4fv(listNode._uniformMatrix,
m_matrices[0]._matrix,
1);
m_nodeList.push_back(listNode);
return m_nodeList.size()-1;
} while (0);
return -1;
}