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


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

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


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

示例1: Lines

Renderable* Renderable::Lines(const std::vector<Vec3f> &verts, Material *material) {
    Renderable *renderable;
    float *vertexBuffer;
    unsigned int *indexBuffer;
    unsigned int size;
    unsigned int i;

    size = (unsigned int)verts.size();

    renderable = new Renderable();

    vertexBuffer = new float[size * 3];
    indexBuffer = new unsigned int[size];

    for(i=0; i < size; i++) {
        vertexBuffer[3*i  ] = verts[i].x;
        vertexBuffer[3*i+1] = verts[i].y;
        vertexBuffer[3*i+2] = verts[i].z;

        indexBuffer[i] = i;
    }
    
    renderable->setMaterial(material);
    renderable->setAttribBuffer("position", size, GL_FLOAT, 3, &vertexBuffer[0]);
    renderable->setIndexBuffer(size, &indexBuffer[0]);
    renderable->setDrawMode(GL_LINE_STRIP);

    delete vertexBuffer;
    delete indexBuffer;

    return renderable;
}
开发者ID:datalurkur,项目名称:Ghastly,代码行数:32,代码来源:Renderable.cpp

示例2: OrthoBox

Renderable* Renderable::OrthoBox(const Vec2f &pos, const Vec2f &dims, bool texCoords, bool normals, Material *material, float z) {
    Renderable *renderable = new Renderable();

    Vec2f disp = pos + dims;

    // Incorrect - the view matrix is set by the scene node anytime the scene node's affine matrix changes
    //renderable->setViewMatrix(Matrix4::MakeTranslation(Vec3f(pos.x, pos.y, z)));
    renderable->setMaterial(material);

    // Determine if the vertex order needs to be flipped to preserve proper winding order
    bool flipped = ((dims.x < 0) != (dims.y < 0));

    // Set the verts
    if(flipped) {
        float verts[4 * 3] = {
            pos.x,  disp.y, z,
            disp.x, disp.y, z,
            disp.x, pos.y,   z,
            pos.x,  pos.y,   z
        };
        renderable->setAttribBuffer("position", 4, GL_FLOAT, 3, &verts[0]);
    } else {
        float verts[4 * 3] = {
            pos.x,  pos.y,  z,
            disp.x, pos.y,  z,
            disp.x, disp.y, z,
            pos.x,  disp.y, z
        };
        renderable->setAttribBuffer("position", 4, GL_FLOAT, 3, &verts[0]);
    }

    // Set the texture coordinates
    if(texCoords && flipped) {
        float texCoords[4 * 2] = {
            0, 1,
            1, 1,
            1, 0,
            0, 0
        };
        renderable->setAttribBuffer("texcoord", 4, GL_FLOAT, 2, &texCoords[0]);
    } else if(texCoords) {
        float texCoords[4 * 2] = {
            0, 0,
            1, 0,
            1, 1,
            0, 1
        };
        renderable->setAttribBuffer("texcoord", 4, GL_FLOAT, 2, &texCoords[0]);
    }

    // Set the normals
    if(normals) {
        float normals[4 * 3] = {
            0, 0, 1,
            0, 0, 1,
            0, 0, 1,
            0, 0, 1
        };
        renderable->setAttribBuffer("normal", 4, GL_FLOAT, 2, &normals[0]);
    }

    // Set the indices
    unsigned int indices[4] = { 0, 1, 3, 2 };
    renderable->setIndexBuffer(4, &indices[0]);

    return renderable;
}
开发者ID:datalurkur,项目名称:Ghastly,代码行数:67,代码来源:Renderable.cpp


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