void CCShaders::setFlash(float r, float g, float b, float t) {
	loadCustomShader(kCCShader_flash);
    CCGLProgram* p = CCShaderCache::sharedShaderCache()->programForKey(kCCShader_flash);
    p->use();
    p->setUniformLocationWith3f(sUniform_pos_CC_flashColor, r, g, b);
    p->setUniformLocationWith1f(sUniform_pos_CC_flashTime, t);
}
Beispiel #2
0
static int tolua_CCGLProgram_CCGLProgram_setUniformLocationWith1f00(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));
  float f1 = ((float)  tolua_tonumber(tolua_S,3,0));
#ifndef TOLUA_RELEASE
  if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setUniformLocationWith1f'", NULL);
#endif
  {
   self->setUniformLocationWith1f(location,f1);
  }
 }
 return 0;
#ifndef TOLUA_RELEASE
 tolua_lerror:
 tolua_error(tolua_S,"#ferror in function 'setUniformLocationWith1f'.",&tolua_err);
 return 0;
#endif
}
Beispiel #3
0
void RawStencilBufferTest4::setupStencilForClippingOnPlane(GLint plane)
{
    RawStencilBufferTest::setupStencilForClippingOnPlane(plane);
    glDepthMask(GL_FALSE);

#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
    glEnable(GL_ALPHA_TEST);
    glAlphaFunc(GL_GREATER, _alphaThreshold);
#else
    CCGLProgram *program = CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTextureColorAlphaTest);
    GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), kCCUniformAlphaTestValue);
    program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold);
    m_pSprite->setShaderProgram(program );
#endif
}
void BatchNodeManager::setBatchNodeAlphaTestValue(float _value)
{
    CCGLProgram* alphashader = CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTextureColorAlphaTest);
    CHECK_GL_ERROR_DEBUG();
    
    
    alphashader->initWithVertexShaderByteArray(ccPositionTextureColor_vert, ccPositionTextureColorAlphaTest_frag);
    
    alphashader->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);
    alphashader->addAttribute(kCCAttributeNameColor, kCCVertexAttrib_Color);
    alphashader->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);
    alphashader->link();
    
    alphashader->updateUniforms();
    
    unsigned loc = glGetUniformLocation(alphashader->getProgram(), kCCUniformAlphaTestValue);
    CHECK_GL_ERROR_DEBUG();
    
    alphashader->setUniformLocationWith1f(loc, _value);
    CHECK_GL_ERROR_DEBUG();
}
Beispiel #5
0
void RawStencilBufferTest6::setupStencilForClippingOnPlane(GLint plane)
{
    GLint planeMask = 0x1 << plane;
    glStencilMask(planeMask);
    glStencilFunc(GL_NEVER, 0, planeMask);
    glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP);
    ccDrawSolidRect(CCPointZero, ccpFromSize(CCDirector::sharedDirector()->getWinSize()), ccc4f(1, 1, 1, 1));
    glStencilFunc(GL_NEVER, planeMask, planeMask);
    glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP);
    glDisable(GL_DEPTH_TEST);
    glDepthMask(GL_FALSE);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
    glEnable(GL_ALPHA_TEST);
    glAlphaFunc(GL_GREATER, _alphaThreshold);
#else
    CCGLProgram *program = CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTextureColorAlphaTest);
    GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), kCCUniformAlphaTestValue);
    program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold);
    m_pSprite->setShaderProgram(program);
#endif
    glFlush();
}