本文整理汇总了C++中CCGLProgram::setUniformLocationWith1i方法的典型用法代码示例。如果您正苦于以下问题:C++ CCGLProgram::setUniformLocationWith1i方法的具体用法?C++ CCGLProgram::setUniformLocationWith1i怎么用?C++ CCGLProgram::setUniformLocationWith1i使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCGLProgram
的用法示例。
在下文中一共展示了CCGLProgram::setUniformLocationWith1i方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
//--------------------------------------------------------
void CShaderNode::draw()
{
CC_NODE_DRAW_SETUP();
//传递uniform变量
CCGLProgram* shader = getShaderProgram();
shader->setUniformLocationWith2f(m_unUniformResolution, m_tagResolutionPos.x, m_tagResolutionPos.y);
shader->setUniformLocationWith1i(m_unUniformTex0, 0);
glUniform1f(m_unUniformTime, m_fTime);
//获取attribute变量
CCSize size = this->getContentSize();
float w = size.width;
float h = size.height;
ccGLBindTexture2D(m_pTexture); //绑定纹理到槽位
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, w, h, 0); //截取屏幕数据到纹理
glEnableVertexAttribArray(m_unAttributePosition);
//传递attribute变量
GLfloat vertices[12] = {
0, 0, //左下0
w, 0, //右下1
w, h, //右上2
0, 0, //左下0
0, h, //左上3
w, h, //右上2
};
glVertexAttribPointer(m_unAttributePosition, 2, GL_FLOAT, GL_FALSE, 0, vertices);
glVertexAttrib4fv(m_unAttributeColor, m_fColor);
//绘制
glDrawArrays(GL_TRIANGLES, 0, 6);
}
示例2:
static int tolua_CCGLProgram_CCGLProgram_setUniformLocationWith1i00(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_isnoobj(tolua_S,4,&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));
int i1 = ((int) tolua_tonumber(tolua_S,3,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setUniformLocationWith1i'", NULL);
#endif
{
self->setUniformLocationWith1i(location,i1);
}
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'setUniformLocationWith1i'.",&tolua_err);
return 0;
#endif
}