Example #1
0
void WireCube::draw(Shader *shader, bool drawEdges)
{
    if (!mReady) {
        std::cerr<<"Warning: Cube not ready for rendering" << std::endl;
        return;
    }

    glBindVertexArray(mVertexArrayObject);

    if(mShader->id() != shader->id()){
        specifyVertexData(shader);
    }

    glDrawElements(GL_LINES, 24*sizeof(int),  GL_UNSIGNED_INT, 0);

    glBindVertexArray(0);
}
void draw(Shader *shader, bool drawEdges = false){

    if (!mReady) {
        cerr<<"Warning: Mesh not ready for rendering" << endl;
        return;
    }

    glBindVertexArray(mVao);

    if(mShader->id() != shader->id()){
        specifyVertexData(shader);
    }

    drawEdges ? glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ) : glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ) ;
    glDrawElements(GL_LINE, mIndicesEdges.size()*sizeof(Vector3i),  GL_UNSIGNED_INT, 0);

    glBindVertexArray(0);

}
Example #3
0
void WireCube::init(Shader *shader)
{
    glGenVertexArrays(1, (GLuint *)&mVertexArrayObject);

    glBindVertexArray(mVertexArrayObject);

    glGenBuffers(1, &mEdges);
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mEdges);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(int)*24, edges,  GL_STATIC_DRAW);

    glGenBuffers(1, &mPosBuffer);
    glBindBuffer(GL_ARRAY_BUFFER, mPosBuffer);
    glBufferData(GL_ARRAY_BUFFER, sizeof(float)*24, vertices, GL_STATIC_DRAW);

    specifyVertexData(shader);

    glBindVertexArray(0);

    GL_TEST_ERR;

    mReady = true;
}