Though the viewport coordinates go from negative one to one [-1, 1)
, texture coordinates go from zero to one [0,1)
. Therefore three quarters of your viewport are filled with black according to the GL_CLAMP_TO_BORDER
policy.
You need to fix your VAO coordinates as follows:
GLfloat vertices[4 * 5]{
// Positions // Textures
-1.0f, -1.0f, 0.0f, 0.0f, 0.0f,
1.0f, 1.0f, 0.0f, 1.0f, 1.0f,
-1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
1.0f, -1.0f, 0.0f, 1.0f, 0.0f
};
EDIT: Also your texture coordinates offset is incorrect. It should be:
// Texture coord
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)(3*sizeof(float)));
Without the proper offset it is using the X and Y of the position for the texture coordinates.
CLICK HERE to find out more related problems solutions.