OpenGL Texture Mapping Filtering & Environment Parameters

Wrapping parameters (REPEAT | CLAMP)

//(왼쪽)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);

//(오른쪽)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

 glBindTexture(GL_TEXTURE_2D, texID1);
glBegin(GL_QUADS);
glNormal3f(0, 0, 1);
glTexCoord2i(-1,-1);
glVertex3f(-2.0, -1.0, 0.0);
glTexCoord2i(3,-1);
glVertex3f(-0.1, -1.0, 0.0);
glTexCoord2i(3,3);
glVertex3f(-0.1, 1.0, 0.0);
glTexCoord2i(-1,3);
glVertex3f(-2.0, 1.0, 0.0);
glEnd();



사용자 삽입 이미지

Magnification/Minification filter parameters (NEAREST | LINEAR)

//(위왼쪽)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);

//(위오른쪽)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

//(아래왼쪽)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

//(아래오른쪽)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);




사용자 삽입 이미지
사용자 삽입 이미지사용자 삽입 이미지Environment parameters (MODULATE | DECAL | BLEND | REPLACE)

// (위왼쪽) GL_RGB modulate = texture color * framebuffer color
 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

// (위오른쪽) GL_RGB decal = texture color
 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);

// (아래왼쪽)
// GL_RGB blend = framebuffer color * (1 – texture color) + blend color * texture color
GLfloat blendcolor[] = {0.0, 1.0, 0.0, 0.5};
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, blendcolor);

// (아래오른쪽)
GL_RGB replace = texture color
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
 



사용자 삽입 이미지