Mipmapping
[opengl.git] / material.cpp
index 85ff7d7ce803f4ebe9ecff8f10c6ae33775acadc..a1d44beb6d07929865ee5309b6916f4ab109d951 100644 (file)
@@ -49,6 +49,15 @@ Material::Texture::Texture(const aiString fileName, const aiScene &scene) {
                glTexImage2D(GL_TEXTURE_2D, 0, img.internalFormat(), img.width(), img.height(), 0, img.format(), img.type(), img.data());
        }
 
+       // magnifying - no bigger mipmap available, so use linear filtering
+       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+       // minifying - use a linear blend of two mipmaps
+       // which are themselves filtered linearly
+       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+    
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+    
        glGenerateMipmap(GL_TEXTURE_2D);
 }