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


C++ Cube::Unbind方法代码示例

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


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

示例1: Create


//.........这里部分代码省略.........
        -1.0f, 0, 0, // D-X
        0, 0, -1.0f, // E-Z
        0, -1.0f, 0, // E-Y
        -1.0f, 0, 0, // E-X
        0, 0, -1.0f, // F-Z
        0, -1.0f, 0, // F-Y
        +1.0f, 0, 0, // F+X
        0, 0, -1.0f, // G-Z
        0, +1.0f, 0, // G+Y
        +1.0f, 0, 0, // G+X
        0, 0, -1.0f, // H-Z
        0, +1.0f, 0, // H+Y
        -1.0f, 0, 0  // H-X
    };

    static const int Indices[] = {
        0, 9, 6, // +Z
        0, 3, 6,
        15, 18, 21, // -Z
        15, 12, 21,
        14, 23, 11, // +Y
        14, 2, 11,
        5, 8, 20, // -Y
        5, 17, 20,
        10, 22, 19, // +X
        10, 7, 19,
        1, 13, 16, // -X
        1, 4, 16
    };

    static const Scalar TexCoords[] = {
        0.995f, 0.005f, // A+Z
        0.005f, 0.995f, // A-Y
        0.995f, 0.005f, // A-X
        0.005f, 0.005f, // B+Z
        0.995f, 0.995f, // B-Y
        0.005f, 0.005f, // B+X
        0.005f, 0.995f, // C+Z
        0.995f, 0.005f, // C+Y
        0.005f, 0.995f, // C+X
        0.995f, 0.995f, // D+Z
        0.005f, 0.005f, // D+Y
        0.995f, 0.995f, // D-X
        0.005f, 0.005f, // E-Z
        0.005f, 0.005f, // E-Y
        0.005f, 0.005f, // E-X
        0.995f, 0.005f, // F-Z
        0.995f, 0.005f, // F-Y
        0.995f, 0.005f, // F+X
        0.995f, 0.995f, // G-Z
        0.995f, 0.995f, // G+Y
        0.995f, 0.995f, // G+X
        0.005f, 0.995f, // H-Z
        0.005f, 0.995f, // H+Y
        0.005f, 0.995f  // H-X
    };

    static const Scalar Positions[] = {
        -0.5f, -0.5f, +0.5f,
        -0.5f, -0.5f, +0.5f,
        -0.5f, -0.5f, +0.5f,
        +0.5f, -0.5f, +0.5f,
        +0.5f, -0.5f, +0.5f,
        +0.5f, -0.5f, +0.5f,
        +0.5f, +0.5f, +0.5f,
        +0.5f, +0.5f, +0.5f,
        +0.5f, +0.5f, +0.5f,
        -0.5f, +0.5f, +0.5f,
        -0.5f, +0.5f, +0.5f,
        -0.5f, +0.5f, +0.5f,
        -0.5f, -0.5f, -0.5f,
        -0.5f, -0.5f, -0.5f,
        -0.5f, -0.5f, -0.5f,
        +0.5f, -0.5f, -0.5f,
        +0.5f, -0.5f, -0.5f,
        +0.5f, -0.5f, -0.5f,
        +0.5f, +0.5f, -0.5f,
        +0.5f, +0.5f, -0.5f,
        +0.5f, +0.5f, -0.5f,
        -0.5f, +0.5f, -0.5f,
        -0.5f, +0.5f, -0.5f,
        -0.5f, +0.5f, -0.5f
    };

    Cube* C = new Cube;

    if(C->CreateBuffers() != BGE_SUCCESS) {
        delete C;
        return NULL;
    }

    C->SetPositionData(24, Positions);
    C->SetNormalData(24, Normals);
    C->SetTexCoordData(24, TexCoords);
    C->SetIndexData(36, Indices);

    C->Unbind();

    return C;
}
开发者ID:bakge,项目名称:bakge,代码行数:101,代码来源:Cube.cpp

示例2: Create


//.........这里部分代码省略.........
    Vertices[36] = -Width;
    Vertices[37] = -Height;
    Vertices[38] = -Length;
    Normals[38] = -1.0f;
    TexCoords[24] = 1;
    /* E-Y */
    Vertices[39] = -Width;
    Vertices[40] = -Height;
    Vertices[41] = -Length;
    Normals[40] = -1.0f;
    /* E-X */
    Vertices[42] = -Width;
    Vertices[43] = -Height;
    Vertices[44] = -Length;
    Normals[42] = -1.0f;

    /* F-Z */
    Vertices[45] = +Width;
    Vertices[46] = -Height;
    Vertices[47] = -Length;
    Normals[47] = -1.0f;
    /* F-Y */
    Vertices[48] = +Width;
    Vertices[49] = -Height;
    Vertices[50] = -Length;
    Normals[49] = -1.0f;
    TexCoords[32] = 1;
    /* F+X */
    Vertices[51] = +Width;
    Vertices[52] = -Height;
    Vertices[53] = -Length;
    Normals[51] = +1.0f;
    TexCoords[34] = 1;

    /* G-Z */
    Vertices[54] = +Width;
    Vertices[55] = +Height;
    Vertices[56] = -Length;
    Normals[56] = -1.0f;
    TexCoords[37] = 1;
    /* G+Y */
    Vertices[57] = +Width;
    Vertices[58] = +Height;
    Vertices[59] = -Length;
    Normals[58] = +1.0f;
    TexCoords[38] = 1;
    TexCoords[39] = 1;
    /* G+X */
    Vertices[60] = +Width;
    Vertices[61] = +Height;
    Vertices[62] = -Length;
    Normals[60] = +1.0f;
    TexCoords[40] = 1;
    TexCoords[41] = 1;

    /* H-Z */
    Vertices[63] = -Width;
    Vertices[64] = +Height;
    Vertices[65] = -Length;
    Normals[65] = -1.0f;
    TexCoords[42] = 1;
    TexCoords[43] = 1;
    /* H+Y */
    Vertices[66] = -Width;
    Vertices[67] = +Height;
    Vertices[68] = -Length;
    Normals[67] = +1.0f;
    TexCoords[45] = 1;
    /* H-X */
    Vertices[69] = -Width;
    Vertices[70] = +Height;
    Vertices[71] = -Length;
    Normals[69] = -1.0f;
    TexCoords[47] = 1;

    glBindBuffer(GL_ARRAY_BUFFER, C->MeshBuffers[MESH_BUFFER_POSITIONS]);
    glBufferData(GL_ARRAY_BUFFER, sizeof(Vertices[0]) * 72, Vertices,
                                                        GL_STATIC_DRAW);

    glBindBuffer(GL_ARRAY_BUFFER, C->MeshBuffers[MESH_BUFFER_NORMALS]);
    glBufferData(GL_ARRAY_BUFFER, sizeof(Normals[0]) * 72, Normals,
                                                        GL_STATIC_DRAW);

    glBindBuffer(GL_ARRAY_BUFFER, C->MeshBuffers[MESH_BUFFER_TEXCOORDS]);
    glBufferData(GL_ARRAY_BUFFER, sizeof(TexCoords[0]) * 48, TexCoords,
                                                        GL_STATIC_DRAW);

    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, C->MeshBuffers[MESH_BUFFER_INDICES]);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(Indices[0]) * 36,
                                            Indices, GL_STATIC_DRAW);

    C->Unbind();

    delete[] Vertices;
    delete[] Normals;
    delete[] Indices;
    delete[] TexCoords;

    return C;
}
开发者ID:jgcoded,项目名称:bakge,代码行数:101,代码来源:Cube.cpp


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