# 2012년 봄학기 그래픽스 프로그래밍 기말고사

2012년 봄학기 그래픽스 프로그래밍 기말고사 문제 1849271976.pdf
2012년 봄학기 그래픽스 프로그래밍 기말고사 답안5657020497.pdf

# OpenGL Blending

Blending Filter 예제
http://dis.dankook.ac.kr/lectures/cg08/entry/blending-filter-예제

//
Default (no blending) = Cs*1
glBlendFunc(GL_ONE, GL_ZERO)

// Draw background only = Cd*1
glBlendFunc(GL_ZERO,
GL_ONE)

// Addition Blending = Cs*1 + Cd*1
glBlendFunc(GL_ONE,
GL_ONE)

// Alpha blending (back-to-front) = Cs*As + Cd*(1-As)

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

// Brighten the scene = Cs*As +
Cd*1
glBlendFunc(GL_SRC_ALPHA, GL_ONE)

// Multiplicative blending = Cd*Cs
glBlendFunc(GL_ZERO,
GL_SRC_COLOR)

// darken the scene = Cd*As
glBlendFunc(GL_ZERO,
GL_SRC_ALPHA);

// Invert all the colors =
Cs*(1-Cd)
glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO)

# OpenGL Texture Generation

texture generation (OBJECT_LINEAR | EYE_LINEAR | SPHERE_MAP)

# 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);
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);

# OpenGL Texture Mapping

Texture binding
Texture generate
Texture filtering
Texture subimage
Texture mapping by procedural definition & using imagefile
Texture mipmapping
Texture environment setting (modulate/decal),
Texture distorting
Texture transformation
Flipbook animation, etc
http://dis.dankook.ac.kr/lectures/cg08/entry/texture-mapping-예제