This is how I would think it should be done. Creating a red texture:
int width = 64;
int height = 64;
int size = width * height;
byte red = (byte) 0b11_00_00_11; // 2-bit per channel
ByteBuffer buffer = MemoryUtil.memAlloc(size);
for (int p = 0; p < size; p++) buffer.put(red);
texture = glGenTextures();
glBindTexture(GL_TEXTURE_2D, texture);
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA2, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer.flip());
MemoryUtil.memFree(buffer);
Run Code Online (Sandbox Code Playgroud)
and in the fragment shader:
// The …Run Code Online (Sandbox Code Playgroud)