if I use this kind of mapping
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
my texture is working fine, but I want to get rid of pixel glitter effect like this
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, width, height, GL_RGB, GL_UNSIGNED_BYTE, data);
I tried with different sizes (1024x1024, 512x512, 256x256, 128x128, 64x64) with .jpg and .bmp and the effect is always something like this.
Assuming that your first version without mipmaps works and that you are using the same input data in both versions: The format parameter of gluBuild2DMipmaps
is wrong. It seems you have RGBA data but tell OpenGL that it is RGB.