当前位置: 首页>>代码示例>>C++>>正文


C++ CCGLProgram::release方法代码示例

本文整理汇总了C++中CCGLProgram::release方法的典型用法代码示例。如果您正苦于以下问题:C++ CCGLProgram::release方法的具体用法?C++ CCGLProgram::release怎么用?C++ CCGLProgram::release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCGLProgram的用法示例。


在下文中一共展示了CCGLProgram::release方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loadShaderVertex

void ShaderNode::loadShaderVertex(const char *vert, const char *frag)
{
	CCGLProgram* shader = new CCGLProgram();
	shader->initWithVertexShaderFilename(vert, frag);   //载入着色器程序  

	//绑定attribute变量  
	shader->addAttribute("a_position", 0);
	shader->addAttribute("a_color", 1);
	shader->link();

	//获取attribute变量标识  
	m_attributeColor = glGetAttribLocation(shader->getProgram(), "a_color");
	m_attributePosition = glGetAttribLocation(
		shader->getProgram(), "a_position");
	shader->updateUniforms();

	//获取uniform变量标识  
	m_uniformResolution = glGetUniformLocation(shader->getProgram(), "resolution");
	m_uniformTime = glGetUniformLocation(shader->getProgram(), "time");
	m_uniformTex0 = glGetUniformLocation(shader->getProgram(), "tex0");

	//使用着色器程序  
	this->setShaderProgram(shader);
	shader->release();
}
开发者ID:huangshucheng,项目名称:MyUtil,代码行数:25,代码来源:ShaderNode.cpp

示例2: initShader

//--------------------------------------------------------
void CShaderNode::initShader( const char *vert, const char *frag)
{
	CCGLProgram* shader = new CCGLProgram();  
	shader->initWithVertexShaderByteArray(vert, frag);   //载入着色器程序  
	//使用着色器程序  
	this->setShaderProgram(shader);  
	shader->release();  
	CHECK_GL_ERROR_DEBUG(); 

	//绑定attribute变量  
	this->getShaderProgram()->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);  
	this->getShaderProgram()->addAttribute(kCCAttributeNameColor, kCCVertexAttrib_Color);  
	this->getShaderProgram()->link();  
	CHECK_GL_ERROR_DEBUG(); 

	//获取attribute变量标识  
	m_unAttributeColor = glGetAttribLocation(this->getShaderProgram()->getProgram(), kCCAttributeNameColor);  
	m_unAttributePosition = glGetAttribLocation(this->getShaderProgram()->getProgram(), kCCAttributeNamePosition);  
	this->getShaderProgram()->updateUniforms();  
	CHECK_GL_ERROR_DEBUG(); 

	//获取uniform变量标识  
	m_unUniformResolution = glGetUniformLocation(this->getShaderProgram()->getProgram(), "resolution");  
	m_unUniformTime = glGetUniformLocation(this->getShaderProgram()->getProgram(), "time");  
	m_unUniformTex0 = glGetUniformLocation(this->getShaderProgram()->getProgram(), "tex0");  

}
开发者ID:Pancho2wang,项目名称:cocos2dx_shader_demo,代码行数:28,代码来源:ShaderNode.cpp

示例3: getGLProgram

/**
@brief pszGLProgramName shader文件名
@param
*/
CCGLProgram* CShaderManager::getGLProgram( const char* pszGLProgramName )
{
	if( pszGLProgramName == NULL )
	{
		return NULL;
	}

	CCGLProgram* pProgram = CCShaderCache::sharedShaderCache()->programForKey( pszGLProgramName );
	if( pProgram )
	{
		return pProgram;
	}

	pProgram = new CCGLProgram();
	if( pProgram == NULL )
	{
		return NULL;
	}

	loadGLProgram( pProgram, pszGLProgramName );
	CCShaderCache::sharedShaderCache()->addProgram( pProgram, pszGLProgramName );
	m_vecGLPrograme.push_back( pszGLProgramName );

	pProgram->release();
	CHECK_GL_ERROR_DEBUG();

	return pProgram;
}
开发者ID:gameview,项目名称:WareCocos2dx,代码行数:32,代码来源:ShaderManager.cpp

示例4: initWithTexture

bool BloodFlashSprite::initWithTexture(CCTexture2D *pTexture, const CCRect& rect)
{
    if (CCSprite::initWithTexture(pTexture, rect)) 
    {
        CCGLProgram *program = new CCGLProgram;
        GLchar *fragSrc = (GLchar *)CCString::createWithContentsOfFile(
            CCFileUtils::sharedFileUtils()->fullPathForFilename(_fragShaderName.c_str()).c_str())->getCString();
        program->initWithVertexShaderByteArray(ccPositionTextureColor_vert, fragSrc);
        setShaderProgram(program);
        program->release();

        CHECK_GL_ERROR_DEBUG();

        getShaderProgram()->link();

        CHECK_GL_ERROR_DEBUG();

        getShaderProgram()->updateUniforms();

        CHECK_GL_ERROR_DEBUG();

        return true;
    }
    return false;
}
开发者ID:elloop,项目名称:cocos2d-x-cpp-demos-2.x,代码行数:25,代码来源:BloodFlashPage.cpp

示例5: initProgram

void SpriteMask::initProgram()
{
	std::string sharderStr = CCFileUtils::getInstance()->fullPathForFilename("Shaders/shader_mask.fsh");
	GLchar * fragSource = (GLchar*)CCString::createWithContentsOfFile(sharderStr.c_str())->getCString();
	CCGLProgram* pProgram = new CCGLProgram();
	pProgram->initWithVertexShaderByteArray(ccPositionTextureColor_vert, fragSource);
	setShaderProgram(pProgram);
	pProgram->release();

	CHECK_GL_ERROR_DEBUG();

	getShaderProgram()->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);
	getShaderProgram()->addAttribute(kCCAttributeNameColor, kCCVertexAttrib_Color);
	getShaderProgram()->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);

	CHECK_GL_ERROR_DEBUG();

	getShaderProgram()->link();

	CHECK_GL_ERROR_DEBUG();

	getShaderProgram()->updateUniforms();

	CHECK_GL_ERROR_DEBUG();

	_maskLocation = glGetUniformLocation(getShaderProgram()->getProgram(), "u_mask");
	_offsetLocation = glGetUniformLocation(getShaderProgram()->getProgram(), "v_offset");

	CHECK_GL_ERROR_DEBUG();
}
开发者ID:ado137,项目名称:shader_cocos2dx,代码行数:30,代码来源:HelloWorldScene.cpp

示例6: initProgram

void SpriteBlur::initProgram()
{
    GLchar * fragSource = (GLchar*) CCString::createWithContentsOfFile(
                                CCFileUtils::sharedFileUtils()->fullPathForFilename("Shaders/example_Blur.fsh").c_str())->getCString();
    CCGLProgram* pProgram = new CCGLProgram();
    pProgram->initWithVertexShaderByteArray(ccPositionTextureColor_vert, fragSource);
    setShaderProgram(pProgram);
    pProgram->release();
    
    CHECK_GL_ERROR_DEBUG();
    
    getShaderProgram()->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);
    getShaderProgram()->addAttribute(kCCAttributeNameColor, kCCVertexAttrib_Color);
    getShaderProgram()->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);
    
    CHECK_GL_ERROR_DEBUG();
    
    getShaderProgram()->link();
    
    CHECK_GL_ERROR_DEBUG();
    
    getShaderProgram()->updateUniforms();
    
    CHECK_GL_ERROR_DEBUG();
    
    subLocation = glGetUniformLocation( getShaderProgram()->getProgram(), "substract");
    blurLocation = glGetUniformLocation( getShaderProgram()->getProgram(), "blurSize");
    
    CHECK_GL_ERROR_DEBUG();
}
开发者ID:wenhulove333,项目名称:ScutServer,代码行数:30,代码来源:ShaderTest.cpp

示例7: CCLOGERROR

CCGLProgram * GAFStencilMaskSprite::programShaderForMask()
{
	CCGLProgram *program = CCShaderCache::sharedShaderCache()->programForKey(kPCStencilMaskAlphaFilterProgramCacheKey);
	
    if (!program)
    {
        program = GAFShaderManager::createWithFragmentFilename(ccPositionTextureColor_vert, kPCStencilMaskAlphaFilterFragmentShaderFilename);
        if (program)
        {
			program->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);
			program->addAttribute(kCCAttributeNameColor,    kCCVertexAttrib_Color);
			program->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);
            program->link();
			program->updateUniforms();
            CHECK_GL_ERROR_DEBUG();
			CCShaderCache::sharedShaderCache()->addProgram(program, kPCStencilMaskAlphaFilterProgramCacheKey);
            program->release();
        }
        else
        {
            CCLOGERROR("Cannot load program for programShaderForMask.");
            return NULL;
        }
    }
	
    program->use();
	return program;
}
开发者ID:digitalassetgroup,项目名称:-BIBS-Game,代码行数:28,代码来源:GAFStencilMaskSprite.cpp

示例8: shaderMulColor

void CSpriteRGBA::shaderMulColor(float r, float g, float b, float a)
{
    CCGLProgram *pShaders = new CCGLProgram;
    pShaders->initWithVertexShaderByteArray(ccPositionTextureColor_vert, SPRITERGBA_SHADER_MUL_COLOR_FSH);
    CHECK_GL_ERROR_DEBUG();

    pShaders->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);
    pShaders->addAttribute(kCCAttributeNameColor, kCCVertexAttrib_Color);
    pShaders->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);
    CHECK_GL_ERROR_DEBUG();

    pShaders->link();
    CHECK_GL_ERROR_DEBUG();

    pShaders->updateUniforms();
    CHECK_GL_ERROR_DEBUG();

    GLint nDotColorLocation = pShaders->getUniformLocationForName("v_dotcolor");
    pShaders->setUniformLocationWith4f(nDotColorLocation, r, g, b, a);

    scale9Image->setShaderProgram(pShaders);
    CHECK_GL_ERROR_DEBUG();

    pShaders->release();
}
开发者ID:jindaw,项目名称:game_sources,代码行数:25,代码来源:SpriteRGBA.cpp

示例9: enableGray

void EXGrayUtility::enableGray(CCSprite* sp)
{
    const 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 \
    void main(void) \n \
    { \n \
    // Convert to greyscale using NTSC weightings \n \
    vec4 col = texture2D(u_texture, v_texCoord); \n \
    float grey = dot(col.rgb, vec3(0.299, 0.587, 0.114)); \n \
    gl_FragColor = vec4(grey, grey, grey, col.a); \n \
    }";
    
    CCGLProgram* pProgram = new CCGLProgram();
    pProgram->initWithVertexShaderByteArray(ccPositionTextureColor_vert, pszFragSource);
    sp->setShaderProgram(pProgram);
    pProgram->release();
    
    sp->getShaderProgram()->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);
    sp->getShaderProgram()->addAttribute(kCCAttributeNameColor, kCCVertexAttrib_Color);
    sp->getShaderProgram()->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);
    
    sp->getShaderProgram()->link();
    sp->getShaderProgram()->updateUniforms();
}
开发者ID:Pattentively,项目名称:cocos2dx-extensions,代码行数:29,代码来源:EXGrayUtility.cpp

示例10: init

bool ShaderRetroEffect::init()
{
    if( ShaderTestDemo::init() ) {

        GLchar * fragSource = (GLchar*) CCString::createWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("Shaders/example_HorizontalColor.fsh"))->getCString();
        CCGLProgram *p = new CCGLProgram();
        p->initWithVertexShaderByteArray(ccPositionTexture_vert, fragSource);

        p->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);
        p->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);

        p->link();
        p->updateUniforms();


        CCDirector *director = CCDirector::sharedDirector();
        CCSize s = director->getWinSize();

        m_pLabel = CCLabelBMFont::create("RETRO EFFECT", "fonts/west_england-64.fnt");

        m_pLabel->setShaderProgram(p);

        p->release();


        m_pLabel->setPosition(ccp(s.width/2,s.height/2));

        addChild(m_pLabel);

        scheduleUpdate();
        return true;
    }

    return false;
}
开发者ID:csdnnet,项目名称:hiygame,代码行数:35,代码来源:ShaderTest.cpp

示例11: setShader

void Ship::setShader(int what){
	do{ 

        GLchar* pszFragSource;
		if(what == 0){
			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 " 
			"void main(void) \n "  
			"{ \n "  
			"// Convert to greyscale using NTSC weightings \n "  
			"vec4 col = texture2D(u_texture, v_texCoord); \n "  
			"gl_FragColor = vec4(col.r, col.g, col.b, col.a); \n " 
			"}";
		}else{
			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 " 
			"void main(void) \n "  
			"{ \n "  
			"// Convert to greyscale using NTSC weightings \n "  
			"float grey = dot(texture2D(u_texture, v_texCoord).rgba, vec4(0.5, 0.0, 0.0,0.7)); \n "  
			"gl_FragColor = vec4(grey, 0.0, 0.0, 0.0); \n " 
			"}";
		}
		
        
        CCGLProgram* pProgram = new CCGLProgram();  
        pProgram->initWithVertexShaderByteArray(ccPositionTextureColor_vert, pszFragSource);  
        this->setShaderProgram(pProgram);  
        pProgram->release();  
        CHECK_GL_ERROR_DEBUG();  
          
        this->getShaderProgram()->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);  
        this->getShaderProgram()->addAttribute(kCCAttributeNameColor, kCCVertexAttrib_Color);  
        this->getShaderProgram()->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);  
        CHECK_GL_ERROR_DEBUG();  
          
        this->getShaderProgram()->link();  
        CHECK_GL_ERROR_DEBUG();  
          
        this->getShaderProgram()->updateUniforms();  
        CHECK_GL_ERROR_DEBUG();   
    } while (0);  
}
开发者ID:jieyaozu,项目名称:FightingSolarSystem,代码行数:53,代码来源:Ship.cpp

示例12: LoadSuperAnimShader

void LoadSuperAnimShader(){
	CCGLProgram* aProgram = new CCGLProgram();
	
	aProgram->initWithVertexShaderByteArray(ccSuperAnim_vert, ccPositionTextureColor_frag);
	aProgram->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);
	aProgram->addAttribute(kCCAttributeNameColor, kCCVertexAttrib_Color);
	aProgram->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);
	aProgram->link();
    aProgram->updateUniforms();
	
	CCShaderCache::sharedShaderCache()->addProgram(aProgram, kCCShaderSuperAnimation);
	aProgram->release();
}
开发者ID:Atomz,项目名称:super-animation-samples,代码行数:13,代码来源:SuperAnimNodeV2.cpp

示例13: loadShaderVertex

void QRSprite::loadShaderVertex(const char *vert, const char *frag)
{
    CCGLProgram *shader = new CCGLProgram();
    shader->initWithVertexShaderByteArray(vert, frag);
    
    shader->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);
    shader->addAttribute(kCCAttributeNameColor, kCCVertexAttrib_Color);
    shader->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);
    
    shader->link();
    
    shader->updateUniforms();
    
    this->setShaderProgram(shader);
    
    shader->release();
}
开发者ID:xiangry,项目名称:cocos2d-qrsprite,代码行数:17,代码来源:QRSprite.cpp

示例14: loadShaderVertex

void ShaderNode::loadShaderVertex(const char *vert, const char *frag)
{
    CCGLProgram *shader = new CCGLProgram();
    shader->initWithVertexShaderFilename(vert, frag);

    shader->addAttribute("aVertex", kCCVertexAttrib_Position);
    shader->link();

    shader->updateUniforms();

    m_uniformCenter = glGetUniformLocation(shader->getProgram(), "center");
    m_uniformResolution = glGetUniformLocation(shader->getProgram(), "resolution");
    m_uniformTime = glGetUniformLocation(shader->getProgram(), "time");

    this->setShaderProgram(shader);

    shader->release();
}
开发者ID:1vs1,项目名称:quick-cocos2d-x,代码行数:18,代码来源:CSShaderNode.cpp

示例15: init

//-------------------------------------------------------------------------
bool FKCW_RenderEx_SwayNode::init( const char* p_szSpriteFile )
{
	do{
		m_fTime = 0.0f;

		m_pSprite = CCSprite::create( p_szSpriteFile );
		if( m_pSprite == NULL )
		{
			break;
		}
		this->addChild( m_pSprite );

		// 加载顶点着色器和片元着色器
		CCGLProgram* pShader = new  CCGLProgram();
		pShader->initWithVertexShaderByteArray(ccPositionTextureA8Color_vert, szSwayShader );
		m_pSprite->setShaderProgram( pShader );
		pShader->release();
		CHECK_GL_ERROR_DEBUG();

		// 启用顶点着色器的attribute变量,坐标、纹理坐标、颜色
		m_pSprite->getShaderProgram()->addAttribute(kCCAttributeNamePosition, kCCVertexAttrib_Position);
		m_pSprite->getShaderProgram()->addAttribute(kCCAttributeNameTexCoord, kCCVertexAttrib_TexCoords);
		CHECK_GL_ERROR_DEBUG();

		// 自定义着色器链接
		m_pSprite->getShaderProgram()->link();
		CHECK_GL_ERROR_DEBUG();

		// 设置移动、缩放、旋转矩阵
		m_pSprite->getShaderProgram()->updateUniforms();
		CHECK_GL_ERROR_DEBUG();

		m_nTimeUniformLocation = glGetUniformLocation( m_pSprite->getShaderProgram()->getProgram(), "u_time" );

		m_pSprite->getShaderProgram()->use();

		// 开启帧更新
		this->schedule(schedule_selector(FKCW_RenderEx_SwayNode::UpdatePos));

		return true;
	}while(0);
	return false;
}
开发者ID:duzhi5368,项目名称:FKCocos2dxWrapper_2.x,代码行数:44,代码来源:FKCW_RenderEx_SwayNode.cpp


注:本文中的CCGLProgram::release方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。