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


C++ Renderable::getVertices方法代码示例

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


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

示例1: enqueue

void BatchRenderEngine::enqueue(Renderable r, GLuint * indices)
{
    // Check in regard to drawString function - error?

    unsigned int vertNum;
    unsigned int indNum;
    unsigned int i;
    const GLuint tid = (GLuint)r.getTid();
    float ts = 0.0f;

    vertNum = r.getVertices().size();
    indNum = (vertNum / 4) * 6;  // Assumes all input renderables are sprites - fix


    if (vertNum + _currVerts > MAX_VERTS || indNum + _currInds > MAX_INDICES || _currTextures >= MAX_TEXTURES) // we've reached our limit, draw everything and restart
    {
        endBatch();
        flush();
        startBatch();
    }

    // Error possibly here - incorrect textures
    if (tid > 0)
    {
        bool found = false;
        for (unsigned int i = 0; i < _currTextures; i++)
        {
            if (_textures[i] == tid)
            {
                ts = (float)i;
                found = true;
                break;
            }
        }

        if (!found)
        {
            if (_currTextures >= MAX_TEXTURES)
            {
                endBatch();
                flush();
                startBatch();
            }
            ts = _currTextures * 1.0f;
            _textures[_currTextures] = tid * 1.0f;
            _currTextures++;
        }
    }
    else
        ts = -1.0f;



    std::vector<Vertex *> verts = r.getVertices();

    if (indices == NULL)
    {
        indices = new GLuint[6];
        indices[0] = 0;
        indices[1] = 1;
        indices[2] = 2;
        indices[3] = 2;
        indices[4] = 3;
        indices[5] = 0;
        indNum = 6;
    }


    // Store all verts and attributes in arrays
    for (i = 0; i<vertNum; i++)
    {
        _vertices[_currVerts + i].pos = *(verts[i]->GetPos());
        _vertices[_currVerts + i].texCoord = *(verts[i]->GetTexCoord());
        _vertices[_currVerts + i].normal = *(verts[i]->GetNormal());
        _vertices[_currVerts + i].color = *(verts[i]->GetColor());
        _vertices[_currVerts + i].tid = ts;
    }

    // Store all indices in an array
    for (i = 0; i < indNum; i++)
    {
        _indices[_currInds + i] = indices[i] + _currVerts;
    }

    _currVerts += vertNum;
    _currInds += indNum;
}
开发者ID:Shajenko,项目名称:Game_Frmwrk,代码行数:87,代码来源:BatchRenderEngine.cpp


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