• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ getShaderProgram函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中getShaderProgram函数的典型用法代码示例。如果您正苦于以下问题:C++ getShaderProgram函数的具体用法?C++ getShaderProgram怎么用?C++ getShaderProgram使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: CC_NODE_DRAW_SETUP

void TextureSprite::draw()
{
    if (!m_bVisible) return;

    CC_NODE_DRAW_SETUP();

    ccGLBlendFunc(m_sBlendFunc.src, m_sBlendFunc.dst);

    ccGLBindTexture2D(mTexture2D->getName());
    ccGLEnableVertexAttribs(kCCVertexAttribFlag_Position | kCCVertexAttribFlag_TexCoords);

    /// Time offset
    getShaderProgram()->setUniformLocationWith2f(mTimeLocation, mTime.x, mTime.y);
    /// Color
    getShaderProgram()->setUniformLocationWith4f(mColorLocation, mColor.r, mColor.g, mColor.b, mColor.a);
    /// Vertex
    glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, sizeof(ccVertex3F), (void*)&mVertexPos[0]);
    /// Texture coord.
    glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, sizeof(ccTex2F), (void*)&mTexCoords[0]);
    /// Available mode: GL_TRIANGLES, GL_TRIANGLES_STRIP and GL_TRIANGLE_FAN
    glDrawArrays(GL_TRIANGLES, 0, mVertexPos.size());

    /// Do NOT call glFlush or performance will decrease drastically!
    /// glFlush();

    CHECK_GL_ERROR_DEBUG();

    CC_INCREMENT_GL_DRAWS(1);
}
开发者ID:xoraphics,项目名称:yummyjump,代码行数:29,代码来源:texturesprite.cpp


示例2: initialize_buffers

// Wireframe OpenGL drawing
void 
Scene_polylines_item::draw_edges(Viewer_interface* viewer) const {

    if(!are_buffers_filled)
        initialize_buffers(viewer);

    vaos[0]->bind();
    attrib_buffers(viewer, PROGRAM_WITHOUT_LIGHT);
    program = getShaderProgram(PROGRAM_WITHOUT_LIGHT);
    program->bind();
    QColor temp = this->color();
    program->setAttributeValue("colors", temp);
    qFunc.glDrawArrays(GL_LINES, 0, static_cast<GLsizei>(positions_lines.size()/4));
    program->release();
    vaos[0]->release();
    if(d->draw_extremities)
    {
        vaos[2]->bind();
        attrib_buffers(viewer, PROGRAM_INSTANCED_WIRE);
        program = getShaderProgram(PROGRAM_INSTANCED_WIRE);
        program->bind();
        qFunc.glDrawArraysInstanced(GL_LINES, 0,
                                    static_cast<GLsizei>(positions_wire_spheres.size()/4), nbSpheres);
        program->release();
        vaos[2]->release();
    }

}
开发者ID:Huanglihan,项目名称:cgal,代码行数:29,代码来源:Scene_polylines_item.cpp


示例3: ccGLEnableVertexAttribs

void BloodFlashSprite::draw()
{
    ccGLEnableVertexAttribs(kCCVertexAttribFlag_PosColorTex);
    ccGLBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    getShaderProgram()->use();
    getShaderProgram()->setUniformsForBuiltins();

    ccGLBindTexture2D(getTexture()->getName());

    // attributes.
#define kQuadSize sizeof(m_sQuad.bl)
    long offset = (long)&m_sQuad;

    //vertex
    int diff = offsetof(ccV3F_C4B_T2F, vertices);
    glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff));

    // texCoods.
    diff = offsetof(ccV3F_C4B_T2F, texCoords);
    glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff));

    // color
    diff = offsetof(ccV3F_C4B_T2F, colors);
    glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff));

    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

    CC_INCREMENT_GL_DRAWS(1);
}
开发者ID:elloop,项目名称:cocos2d-x-cpp-demos-2.x,代码行数:30,代码来源:BloodFlashPage.cpp


示例4: setShaderProgram

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: initialize_buffers

// Shaded OpenGL drawing: only draw spheres
void
Scene_polylines_item::draw(Viewer_interface* viewer) const {

    if(!are_buffers_filled)
        initialize_buffers(viewer);
    if(d->draw_extremities)
    {
        if(viewer->extension_is_found)
        {
            vaos[1]->bind();
            program = getShaderProgram(PROGRAM_INSTANCED);
            attrib_buffers(viewer, PROGRAM_INSTANCED);
            program->bind();
            viewer->glDrawArraysInstanced(GL_TRIANGLES, 0,
                                          static_cast<GLsizei>(nb_spheres/3), nbSpheres);
            program->release();
            vaos[1]->release();
        }
        else
        {
            vaos[1]->bind();
            program = getShaderProgram(PROGRAM_WITHOUT_LIGHT);
            attrib_buffers(viewer, PROGRAM_WITHOUT_LIGHT);
            glPointSize(8.0f);
            glEnable(GL_POINT_SMOOTH);
            program->bind();
            viewer->glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(nb_centers/3));
            glDisable(GL_POINT_SMOOTH);
            program->release();
            vaos[1]->release();
        }
    }
}
开发者ID:haozzzzzzzz,项目名称:cgal,代码行数:34,代码来源:Scene_polylines_item.cpp


示例6: CC_NODE_DRAW_SETUP

void ShaderNode::draw()
{
    CC_NODE_DRAW_SETUP();

    float w = SIZE_X, h = SIZE_Y;
    GLfloat vertices[12] = {0, 0, w, 0, w, h, 0, 0, 0, h, w, h};

    //
    // Uniforms
    //
    getShaderProgram()->setUniformLocationWith2f(_uniformCenter, _center.x, _center.y);
    getShaderProgram()->setUniformLocationWith2f(_uniformResolution, _resolution.x, _resolution.y);


    // time changes all the time, so it is Ok to call OpenGL directly, and not the "cached" version
    glUniform1f(_uniformTime, _time);

    GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POSITION);

    glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);

    glDrawArrays(GL_TRIANGLES, 0, 6);

    CC_INCREMENT_GL_DRAWS(1);
}
开发者ID:ADoby,项目名称:Project_Space_Pirate,代码行数:25,代码来源:CCShaderNode.cpp


示例7: compute_elements

// Wireframe OpenGL drawing
void 
Scene_polylines_item::draw_edges(Viewer_interface* viewer) const {
    if(!are_buffers_filled)
    {
        compute_elements();
        initialize_buffers(viewer);
    }

    vaos[0]->bind();
    attrib_buffers(viewer, PROGRAM_WITHOUT_LIGHT);
    program = getShaderProgram(PROGRAM_WITHOUT_LIGHT);
    program->bind();
    program->setAttributeValue("colors", this->color());
    viewer->glDrawArrays(GL_LINES, 0, static_cast<GLsizei>(nb_lines/4));
    program->release();
    vaos[0]->release();
    if(d->draw_extremities)
    {
        if(viewer->extension_is_found)
        {
            vaos[2]->bind();
            attrib_buffers(viewer, PROGRAM_INSTANCED_WIRE);
            program = getShaderProgram(PROGRAM_INSTANCED_WIRE);
            program->bind();
            viewer->glDrawArraysInstanced(GL_LINES, 0,
                                          static_cast<GLsizei>(nb_wire/3), nbSpheres);
            program->release();
            vaos[2]->release();
        }
    }

}
开发者ID:NobodyZhou,项目名称:cgal,代码行数:33,代码来源:Scene_polylines_item.cpp


示例8: getShaderProgram

void MotionStreak::onDraw(const kmMat4 &transform, bool transformUpdated)
{
    getShaderProgram()->use();
    getShaderProgram()->setUniformsForBuiltins(transform);

    GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POS_COLOR_TEX );
    GL::blendFunc( _blendFunc.src, _blendFunc.dst );

    GL::bindTexture2D( _texture->getName() );

#ifdef EMSCRIPTEN
    // Size calculations from ::initWithFade
    setGLBufferData(_vertices, (sizeof(Vertex2F) * _maxPoints * 2), 0);
    glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, 0);

    setGLBufferData(_texCoords, (sizeof(Tex2F) * _maxPoints * 2), 1);
    glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, 0);

    setGLBufferData(_colorPointer, (sizeof(GLubyte) * _maxPoints * 2 * 4), 2);
    glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, 0);
#else
    glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, _vertices);
    glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_TEX_COORDS, 2, GL_FLOAT, GL_FALSE, 0, _texCoords);
    glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_UNSIGNED_BYTE, GL_TRUE, 0, _colorPointer);
#endif // EMSCRIPTEN

    glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)_nuPoints*2);
    CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, _nuPoints*2);
}
开发者ID:253627764,项目名称:WagonWar,代码行数:29,代码来源:CCMotionStreak.cpp


示例9: CC_NODE_DRAW_SETUP

void ShaderNode::draw()
{
    CC_NODE_DRAW_SETUP();

    float w = SIZE_X, h = SIZE_Y;
    GLfloat vertices[12] = {0,0, w,0, w,h, 0,0, 0,h, w,h};

    //
    // Uniforms
    //
    getShaderProgram()->setUniformLocationWith2f(m_uniformCenter, m_center.x, m_center.y);
    getShaderProgram()->setUniformLocationWith2f(m_uniformResolution, m_resolution.x, m_resolution.y);


    // time changes all the time, so it is Ok to call OpenGL directly, and not the "cached" version
    glUniform1f(m_uniformTime, m_time);

    ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );

    glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices);

    glDrawArrays(GL_TRIANGLES, 0, 6);
    
    CC_INCREMENT_GL_DRAWS(1);
}
开发者ID:1vs1,项目名称:quick-cocos2d-x,代码行数:25,代码来源:CSShaderNode.cpp


示例10: propertyNamed

void CCTMXLayer::parseInternalProperties()
{
    // if cc_vertex=automatic, then tiles will be rendered using vertexz

    CCString *vertexz = propertyNamed("cc_vertexz");
    if (vertexz) 
    {
        // If "automatic" is on, then parse the "cc_alpha_func" too
        if (vertexz->m_sString == "automatic")
        {
            m_bUseAutomaticVertexZ = true;
            CCString *alphaFuncVal = propertyNamed("cc_alpha_func");
            float alphaFuncValue = 0.0f;
            if (alphaFuncVal != NULL)
            {
                alphaFuncValue = alphaFuncVal->floatValue();
            }
            setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTextureColorAlphaTest));

            GLint alphaValueLocation = glGetUniformLocation(getShaderProgram()->getProgram(), kCCUniformAlphaTestValue);

			getShaderProgram()->use();
            // NOTE: alpha test shader is hard-coded to use the equivalent of a glAlphaFunc(GL_GREATER) comparison
            getShaderProgram()->setUniformLocationWith1f(alphaValueLocation, alphaFuncValue);
			CHECK_GL_ERROR_DEBUG();
        }
        else
        {
            m_nVertexZvalue = vertexz->intValue();
        }
    }
}
开发者ID:Infosfer,项目名称:cocos2d-x,代码行数:32,代码来源:CCTMXLayer.cpp


示例11: compute_elements

void Scene_c3t3_item::draw_points(CGAL::Three::Viewer_interface * viewer) const
{
  if (!are_buffers_filled)
  {
    compute_elements();
    initialize_buffers(viewer);
  }
  vaos[Edges]->bind();
  program = getShaderProgram(PROGRAM_WITHOUT_LIGHT);
  attrib_buffers(viewer, PROGRAM_WITHOUT_LIGHT);
  program->bind();
  program->setAttributeValue("colors", this->color());
  viewer->glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(positions_lines.size() / 3));
  vaos[Edges]->release();
  program->release();

  vaos[2]->bind();
  program = getShaderProgram(PROGRAM_WITHOUT_LIGHT);
  attrib_buffers(viewer, PROGRAM_WITHOUT_LIGHT);
  program->bind();
  program->setAttributeValue("colors", this->color());
  QMatrix4x4 f_mat;
  for (int i = 0; i<16; i++)
    f_mat.data()[i] = frame->matrix()[i];
  program->setUniformValue("f_matrix", f_mat);
  viewer->glDrawArrays(GL_LINES, 0, static_cast<GLsizei>(positions_grid.size() / 3));
  program->release();
  vaos[2]->release();
}
开发者ID:logtcn,项目名称:cgal,代码行数:29,代码来源:Scene_c3t3_item.cpp


示例12: getProperty

void TMXLayer::parseInternalProperties()
{
    // if cc_vertex=automatic, then tiles will be rendered using vertexz

    String *vertexz = getProperty("cc_vertexz");
    if (vertexz) 
    {
        // If "automatic" is on, then parse the "cc_alpha_func" too
        if (vertexz->m_sString == "automatic")
        {
            m_bUseAutomaticVertexZ = true;
            String *alphaFuncVal = getProperty("cc_alpha_func");
            float alphaFuncValue = 0.0f;
            if (alphaFuncVal != NULL)
            {
                alphaFuncValue = alphaFuncVal->floatValue();
            }
            setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST));

            GLint alphaValueLocation = glGetUniformLocation(getShaderProgram()->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE);

            // NOTE: alpha test shader is hard-coded to use the equivalent of a glAlphaFunc(GL_GREATER) comparison
            
            // use shader program to set uniform
            getShaderProgram()->use();
            getShaderProgram()->setUniformLocationWith1f(alphaValueLocation, alphaFuncValue);
            CHECK_GL_ERROR_DEBUG();
        }
        else
        {
            m_nVertexZvalue = vertexz->intValue();
        }
    }
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:34,代码来源:CCTMXLayer.cpp


示例13: CCGLProgram

void GrayMask::initProgram()
{
	std::string sharderStr = CCFileUtils::getInstance()->fullPathForFilename("Shaders/shader_gray.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();
}
开发者ID:ado137,项目名称:shader_cocos2dx,代码行数:25,代码来源:HelloWorldScene.cpp


示例14: getShaderProgram

void LayerColor::onDraw(const kmMat4& transform, bool transformUpdated)
{
    getShaderProgram()->use();
    getShaderProgram()->setUniformsForBuiltins(transform);

    GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_COLOR );
    //
    // Attributes
    //
#ifdef EMSCRIPTEN
    setGLBufferData(_noMVPVertices, 4 * sizeof(Vertex3F), 0);
    glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, 0);

    setGLBufferData(_squareColors, 4 * sizeof(Color4F), 1);
    glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, 0, 0);
#else
    glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, _noMVPVertices);
    glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, 0, _squareColors);
#endif // EMSCRIPTEN

    GL::blendFunc( _blendFunc.src, _blendFunc.dst );

    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

    CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,4);
}
开发者ID:253627764,项目名称:WagonWar,代码行数:26,代码来源:CCLayer.cpp


示例15: ccGLEnableVertexAttribs

void SpriteBlur::draw()
{
    ccGLEnableVertexAttribs(kCCVertexAttribFlag_PosColorTex );
    ccGLBlendFunc( m_sBlendFunc.src, m_sBlendFunc.dst );

    getShaderProgram()->use();
    getShaderProgram()->setUniformForModelViewProjectionMatrix();
    getShaderProgram()->setUniformLocationWith2f(blurLocation, blur_.x, blur_.y);
    getShaderProgram()->setUniformLocationWith4fv(subLocation, sub_, 1);

    ccGLBindTexture2D(  getTexture()->getName() );

    //
    // Attributes
    //
#define kQuadSize sizeof(m_sQuad.bl)
    long offset = (long)&m_sQuad;

    // vertex
    int diff = offsetof( ccV3F_C4B_T2F, vertices);
    glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, kQuadSize, (void*) (offset + diff));

    // texCoods
    diff = offsetof( ccV3F_C4B_T2F, texCoords);
    glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, kQuadSize, (void*)(offset + diff));

    // color
    diff = offsetof( ccV3F_C4B_T2F, colors);
    glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_UNSIGNED_BYTE, GL_TRUE, kQuadSize, (void*)(offset + diff));


    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

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


示例16: XFUNC_START

void XSpriteBatchNode::draw()
{
	XFUNC_START();
	CC_PROFILER_START("XSpriteBatchNode - draw");

	if (m_pobTextureAtlas->getTotalQuads() == 0)
	{
		return;
	}
	do 
	{
		ccGLEnable(m_eGLServerState);
		if (m_pShaderKTX)
		{
			CCGLProgram* pProg = m_pShaderKTX->GetProgram();
			if (pProg)
			{
				pProg->use();
				pProg->setUniformsForBuiltins();
			}
		}
		else
		{
			if (getShaderProgram())
			{
				getShaderProgram()->use();
				getShaderProgram()->setUniformsForBuiltins();
			}			
		}
		if(m_pShaderOnce)
		{
			m_pShaderOnce->use();
			m_pShaderOnce->setUniformsForBuiltins();
			if(m_pShaderOnce->m_pShader)
				m_pShaderOnce->m_pShader->RunBeforeDraw();
			m_pShaderOnce = NULL;
		}
		//else if(m_pobTextureAtlas->getTexture())
		//{
		//	static XShaderBloom stShaderBloom;
		//	stShaderBloom.UseShader();
		//	stShaderBloom.SetTexSize(SCRPIX_W, SCRPIX_H);
		//}
	} while (0);
	arrayMakeObjectsPerformSelector(m_pChildren, updateTransform, CCSprite*);
	ccGLBlendFunc(m_blendFunc.src, m_blendFunc.dst);
	if (m_pTexKtxAlpha)
	{
		ccGLBindTexture2DN(1, m_pTexKtxAlpha->getName());
		if (m_pShaderKTX)
		{
			m_pShaderKTX->RunBeforeDraw();
		}	
	}
	m_pobTextureAtlas->drawQuads();
	CC_PROFILER_STOP("XSpriteBatchNode - draw");
	
	XFUNC_END();
}
开发者ID:SLS-ACT,项目名称:TeamTest,代码行数:59,代码来源:XSpriteBatchNode.cpp


示例17: ccGLBlendFunc

void CCDrawNode::draw()
{
    ccGLBlendFunc(m_sBlendFunc.src, m_sBlendFunc.dst);
    
    getShaderProgram()->use();
    getShaderProgram()->setUniformsForBuiltins();
    
    render();
}
开发者ID:hgl888,项目名称:DialogGl,代码行数:9,代码来源:CCDrawNode.cpp


示例18: getShaderProgram

void PaintLayer::fillLineTriangles(LineVertex *vertices, int count, ccColor4F color)
{
    getShaderProgram()->use();
    getShaderProgram()->setUniformsForBuiltins();

    ccGLEnableVertexAttribs(kCCVertexAttribFlag_Position | kCCVertexAttribFlag_Color);

    ccColor4F fullColor = color;
    ccColor4F fadeOutColor = color;
    fadeOutColor.a = 0;

    for (int i = 0; i < count / 18; ++i)
    {
        for (int j = 0; j < 6; ++j)
        {
            vertices[i * 18 + j].color = color;
        }

        //! FAG
        vertices[i * 18 + 6].color = fadeOutColor;
        vertices[i * 18 + 7].color = fullColor;
        vertices[i * 18 + 8].color = fadeOutColor;

        //! AGD
        vertices[i * 18 + 9].color = fullColor;
        vertices[i * 18 + 10].color = fadeOutColor;
        vertices[i * 18 + 11].color = fullColor;

        //! BHC
        vertices[i * 18 + 12].color = fullColor;
        vertices[i * 18 + 13].color = fadeOutColor;
        vertices[i * 18 + 14].color = fullColor;

        //! HCI
        vertices[i * 18 + 15].color = fadeOutColor;
        vertices[i * 18 + 16].color = fullColor;
        vertices[i * 18 + 17].color = fadeOutColor;
    }

    glVertexAttribPointer(kCCVertexAttrib_Position, 3, GL_FLOAT, GL_FALSE, sizeof(LineVertex), &vertices[0].pos);
    glVertexAttribPointer(kCCVertexAttrib_Color, 4, GL_FLOAT, GL_FALSE, sizeof(LineVertex), &vertices[0].color);

    glBlendFunc(GL_SRC_ALPHA, GL_ONE);
    glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
    glDrawArrays(GL_TRIANGLES, 0, (GLsizei)count);

    for (unsigned int i = 0; i < circlesPoints->count() / 2;   ++i)
    {
        LinePoint *prevPoint = (LinePoint *)circlesPoints->objectAtIndex(i * 2);
        LinePoint *curPoint = (LinePoint *)circlesPoints->objectAtIndex(i * 2 + 1);
        CCPoint dirVector = ccpNormalize(ccpSub(curPoint->pos, prevPoint->pos));

        this->fillLineEndPointAt(curPoint->pos, dirVector, curPoint->width * 0.4f, color);
    }
    circlesPoints->removeAllObjects();
}
开发者ID:franklen,项目名称:smooth-drawing-cocos2dx,代码行数:56,代码来源:PaintLayer.cpp


示例19: getTexture

void BlurSprite::buildCustomUniforms()
{
    auto s = getTexture()->getContentSizeInPixels();
    
    blur_ = Point(1/s.width, 1/s.height);
    sub_[0] = sub_[1] = sub_[2] = sub_[3] = 0;
    
    subLocation = glGetUniformLocation( getShaderProgram()->getProgram(), "substract");
    blurLocation = glGetUniformLocation( getShaderProgram()->getProgram(), "blurSize");
}
开发者ID:ioyouj,项目名称:Hello-LWF-Cocos2d-x,代码行数:10,代码来源:ShaderTest2.cpp


示例20: getTexture

void LensFlareSprite::setCustomUniforms()
{
    _textureResolution[0] = getTexture()->getContentSizeInPixels().width;
    _textureResolution[1] = getTexture()->getContentSizeInPixels().height;
    
    _resolution[0] = getContentSize().width;
    _resolution[1] = getContentSize().height;
    
    getShaderProgram()->setUniformLocationWith2fv(_resolutionLoc, _resolution, 1);
    getShaderProgram()->setUniformLocationWith2fv(_textureResolutionLoc, _textureResolution, 1);
}
开发者ID:2youyou2,项目名称:ShaderLib,代码行数:11,代码来源:ShaderSprite.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ getShape函数代码示例发布时间:2022-05-28
下一篇:
C++ getShader函数代码示例发布时间:2022-05-28
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap