Skip to main content
gamedev.net
🔒 Locked

Mip Mapping Problem

Started by Geometrian Aug 30, 2008 at 5:53 PM 1 replies 950+ views
Original Post
Geometrian
Geometrian
Hi, I'm almost done with a game I'm writing. It is networked via my own custom library, has complex lighting effects, and has real physics. It occurred to me that the floor has nasty artifacts over it, but unfortunately, I'm stuck on mipmapping it. On the left, you can see the the game as it currently is, and the game after I added mipmapping: Obviously, there are some problems here. The floor's overall color seems to have changed dramatically, and of course there are the red/green/blue artifacts near the camera. Here is the relevant texture code for mipmapping:

def Texture(surface,filters):
    #surface is a pygame.Surface; in the case of the floor, filters = ["mipmap","wrap"]
    texture = glGenTextures(1)
    Data = pygame.image.tostring(surface,"RGBA",1)
    glBindTexture(GL_TEXTURE_2D,texture)
    glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,surface.get_width(),surface.get_height(),0,GL_RGBA,GL_UNSIGNED_BYTE,Data)
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
    if filters == None:
        return texture
    for f in filters:
        if f == "filter":
            glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
            glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
        elif f == "wrap":
            glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
            glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
        elif f == "mipmap":
            glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE )
            gluBuild2DMipmaps(GL_TEXTURE_2D,3,surface.get_width(),surface.get_height(),GL_RGB,GL_UNSIGNED_BYTE,Data)
            if "filter" in filters:
                glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR)
                glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
            else:
                glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST)
                glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
    return texture
How should I fix these problems? Thanks, Geometrian
[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]
V-man
V-man
http://www.opengl.org/wiki/index.php/Common_Mistakes#Texture_Upload
Geometrian
Geometrian
Thanks. The problem was both RBG/RBGA inconsistency and the absence of
glPixelStorei(GL_UNPACK_ALIGNMENT,1)
I had just figured it out.
[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.