Why is the following code generating GL_INVALID_OPERATION?
int8_t bytes[256];
for (int i = 0; i < 256; i++)
bytes[i] = (int8_t) i;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_1D, texture);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage1D(GL_TEXTURE_1D, 0, GL_R8I, 256, 0, GL_RED, GL_BYTE, bytes);
/* Here I get GL_INVALID_OPERATION */
glBindTexture(GL_TEXTURE_1D, 0);
I found the answer myself! Apparently one must use the suffix
_INTEGERon the format specifier (GL_RED_INTEGER) when transferring pixels to a texture using integral format. More information here: Pixel Transfer