Example #1
0
void HelloGLSL::onRender()
{
    glslProgram.use();

    glBindVertexArray(vao);

    glDrawArrays(GL_TRIANGLES, 0, 3);

    glslProgram.unUse();
    glBindVertexArray(0);
}
Example #2
0
void OgroInvasion::onRender()
{
	glslProgram.use();

	glBindVertexArray(vaoID);

	glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, nullptr);

	glBindVertexArray(0);

	glslProgram.unUse();
}
Example #3
0
GLuint Model::getVAOForContext(GLSLProgram &shader, QGLContext *context){

    if (!vaoHashContainer_.contains(context)) {

        glGenVertexArrays(1, &vaoID_);
        glBindVertexArray(vaoID_);

        shader.use();
            glBindBuffer (GL_ARRAY_BUFFER, vboVerticesID_);

            glEnableVertexAttribArray(shader["vVertex"]);
            glVertexAttribPointer(shader["vVertex"], 3, GL_FLOAT, GL_FALSE,sizeof(Vertex),0);

            if (shader.isActive(shader["vNormal"])) {
                glEnableVertexAttribArray(shader["vNormal"]);
                glVertexAttribPointer(shader["vNormal"], 3, GL_FLOAT,
                        GL_FALSE, sizeof(Vertex), (const GLvoid*)(offsetof(Vertex, normal)) );
            }

            if (shader.isActive(shader["vUV"])) {
                glEnableVertexAttribArray(shader["vUV"]);
                glVertexAttribPointer(shader["vUV"], 2, GL_FLOAT,
                        GL_FALSE, sizeof(Vertex), (const GLvoid*)(offsetof(Vertex, uv)) );
            }

            if (materials_.size()==1)
                glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboIndicesID_);

            glBindVertexArray(0);
            glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,0);

            vaoHashContainer_.insert(context, vaoID_);
        shader.unUse();
    }

    return vaoHashContainer_[context];
}