void OGL_Renderer_3_2::drawVertexArray(GLuint textureId, bool defaultTextureCoords){
clearScreen(0, 0, 0);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glUseProgram(mShaderManager->getShaderProgram());
getError();
mModelViewMatrix = glGetUniformLocation(mShaderManager->getShaderProgram(), "mvp");
getError();
glUniformMatrix4fv(mModelViewMatrix, 1, GL_FALSE, glm::value_ptr(ModelViewMatrix));
getError();
glBindVertexArray(mVertexArray);
getError();
glDrawArrays(GL_TRIANGLES, 0, 6);
getError();
glBindVertexArray(0);
getError();
glUseProgram(0);
getError();
glDisable(GL_BLEND);
}
/**
* Used internally to fill the vertex array with quad vertex information.
*/
void OGL_Renderer_3_2::fillVertexArray(GLfloat x, GLfloat y, GLfloat w, GLfloat h)
{
float *mVertexArrayData = new float[18];
mVertexArrayData[0] = static_cast<GLfloat>(x); mVertexArrayData[1] = static_cast<GLfloat>(y + h); mVertexArrayData[2] = 0;
mVertexArrayData[3] = static_cast<GLfloat>(x); mVertexArrayData[4] = static_cast<GLfloat>(y); mVertexArrayData[5] = 0;
mVertexArrayData[6] = static_cast<GLfloat>(x + w); mVertexArrayData[7] = static_cast<GLfloat>(y); mVertexArrayData[8] = 0;
mVertexArrayData[9] = static_cast<GLfloat>(x + w); mVertexArrayData[10] = static_cast<GLfloat>(y); mVertexArrayData[11] = 0;
mVertexArrayData[12] = static_cast<GLfloat>(x + w); mVertexArrayData[13] = static_cast<GLfloat>(y + h); mVertexArrayData[14] = 0;
mVertexArrayData[15] = static_cast<GLfloat>(x); mVertexArrayData[16] = static_cast<GLfloat>(y + h); mVertexArrayData[17] = 0;
glGenVertexArrays(1, &mVertexArray); // Create our Vertex Array Object
glBindVertexArray(mVertexArray); // Bind our Vertex Array Object so we can use it
glGenBuffers(1, &mVertexBufferObject); // Generate our Vertex Buffer Object
glBindBuffer(GL_ARRAY_BUFFER, mVertexBufferObject); // Bind our Vertex Buffer Object
glBufferData(GL_ARRAY_BUFFER, 18 * sizeof(GLfloat), mVertexArrayData, GL_STATIC_DRAW); // Set the size and data of our VBO and set it to STATIC_DRAW
glVertexAttribPointer((GLuint)0, 3, GL_FLOAT, GL_FALSE, 0, 0); // Set up our vertex attributes pointer
glEnableVertexAttribArray(0); // Disable our Vertex Array Object
glBindVertexArray(0); // Disable our Vertex Buffer Object
delete [] mVertexArrayData;
}