How to get Mipmaps working?

Started by Chuck, September 02, 2011, 03:31:09

Previous topic - Next topic

Chuck

I've tried gluBuild2DMipmaps, I've tried GL_GENERATE_MIPMAP, I've tried glGenerateMipmap, and no matter what I do, I can't use GL_LINEAR_MIPMAP_LINEAR or GL_LINEAR_MIPMAP_NEAREST I get just a completely blank texture (actually, looks like no texture at all since it takes on glColor when I turn off lighting).

Here's where I set up the texture.  Other filters work just fine, it's just the mipmap ones that fail
        Texture tex = return TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream(texPath), true);
        tex.bind();
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL14.GL_GENERATE_MIPMAP, GL11.GL_TRUE);


Does anyone have a simple working example of using mipmaps?

ra4king

Try the glGenerateMipmap(GLenum) function?
-Roi

Chuck

Aha, looks like glGenerateMipmap worked.  I was having trouble with it before because I forgot to comment out the version using GL_GENERATE_MIPMAP.  Reading more on GL_GENERATE_MIPMAP, it looks like it doesn't *actually* generate mipmaps until you otherwise start altering mipmaps or something or other ...  Whatever, I'm perfectly fine with requiring OpenGL 3.0 I guess.

abcdef

Sorry to bump this thread, I had a similar problem to this. There is another way to solve this using GL 1.2 code. Just add

GL11.glTexParameteri (GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, mipMapCount-1);

To your code. This fixes the rendering issue too. Depends if you want an opengl 3 dependency or not.