I am trying to learn VBOs and I have them sort of working but I wanted to get some clarification regarding glVertexPointers and glTexCoordPointers.
bool OGL_Renderer::drawImage(Image *image, int x, int y, float scale = 1.0f)
{
if(image)
{
GLfloat vertices[8] = {
x, y,
x + image->getWidth(), y,
x + image->getWidth(), y + image->getHeight(),
x, y + image->getHeight()
};
GLfloat texture[8] = {
0.0f, 0.0f,
1.0f, 0.0f,
1.0f, 1.0f,
0.0f, 1.0f
};
glColor4ub(255, 255, 255, 255);
glBindBuffer(GL_ARRAY_BUFFER, mVertexBufferObject);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices) + sizeof(texture), NULL, GL_STATIC_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices);
glBufferSubData(GL_ARRAY_BUFFER, sizeof(vertices), sizeof(texture), texture);
glBindBuffer(GL_ARRAY_BUFFER, mVertexBufferObject);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_TEXTURE_2D);
glBindTexture(mTextureTarget, getTextureId(image));
glVertexPointer(2, GL_FLOAT, 0, vertices);
glTexCoordPointer(2, GL_FLOAT, 0, texture);
glDrawArrays(GL_QUADS, 0, 4);
glDisable(mTextureTarget);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
return true;
}
return false;
}
The last parameter of both should be the arrays that the coords are stored into right? I seem to have some confusion in this area.