Skip to main content
gamedev.net
🔒 Locked

weird texture behaviour

Started by back2newbelf 2 replies 500+ views
Original Post
back2newbelf
back2newbelf
using the code from nehe's lesson 10 i load the same texture in multiple ways and switch between modes with pressing "f".

glGenTextures(3, &texture[0]);
	 
    // mode 1
    glBindTexture(GL_TEXTURE_2D, texture[0]);   // 2d texture (x and y size)
    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, 3, image1->w, image1->h, 0, GL_RGB, GL_UNSIGNED_BYTE, image1->pixels);

    // mode 2
    glBindTexture(GL_TEXTURE_2D, texture[1]);   
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); 
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR); 
    glTexImage2D(GL_TEXTURE_2D, 0, 3, image1->w, image1->h, 0, GL_RGB, GL_UNSIGNED_BYTE, image1->pixels);

    // mode 3
    glBindTexture(GL_TEXTURE_2D, texture[2]);   
    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, 3, image1->w, image1->h, GL_RGB, GL_UNSIGNED_BYTE, image1->pixels);
it starts out with GL_NEAREST for MAG- and MIN-FILTER(mode 1). notice that mode 2 and mode 3 are the exact same. but when i press "f" once (going in mode 2 then) all textures become white. but if i press "f" a second time i'm in mode 3 (which should be the same as mode 2) everything looks fine again. why does that happen? also: my app runs faster in fullscreen. why?
Lord Faron
Lord Faron
Mode 2 requires mipmaps. You set GL_TEXTURE_MIN_FILTER to GL_LINEAR_MIPMAP_LINEAR so you need to specify the mipmaps like in mode 3. If any of them is missing the texturing won't work (hence the white texture).
if (time() == $) { $ = 0; }
godmodder
godmodder
Your app runs faster in fullscreen, because the window that in runs in doesn't need to be blitted on top of the desktop/other windows anymore.

Hope I was able to help,
Jeroen

Topic Locked

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

Sign in to reply to this topic.