# 기말고사 정답

모두들 수고 하셨습니다. 2014년 그래픽스 프로그래밍 기말고사 정답입니다.9064432742.pdf

# Line Drawing Algorithm

line drawing algorithm
-DDA (Digital Differential Analyzer)
-Bresenham’s Line Drawing Algorithm

# OpenGLTextureBlendingGeometry

OpenGLTextureBlendingGeometry4900012935.zip

# OpenGL Blending Filter

OpenGL Blending Filter

14.OpenGLBlendingFilter.zip

glEnable(GL_BLEND);
if (g_filter == 0)                     // Default (no blending) = Cs*1
glBlendFunc(GL_ONE, GL_ZERO);
else if (g_filter == 1)                // Draw background only = Cd*1
glBlendFunc(GL_ZERO, GL_ONE);
else if (g_filter == 2)                // Cs*1 + Cd*1
glBlendFunc(GL_ONE, GL_ONE);
else if (g_filter == 3)                // Alpha blending (back-to-front) = Cs*As + Cd*(1-As)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
else if (g_filter == 4)                // Additive blending (brighten the scene) = Cs*As + Cd*1
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
else if (g_filter == 5)                // Multiplicative blending = Cd*Cs
glBlendFunc(GL_ZERO, GL_SRC_COLOR);
else if (g_filter == 6)                // darken the scene = Cd*As
glBlendFunc(GL_ZERO, GL_SRC_ALPHA);
else if (g_filter == 7)                 // Invert all the colors = Cs*(1-Cd)
glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);

# OpenGLTextureGeometry

OpenGLTextureGeometry3932810397.zip

# Texture Animation

Texture Animation

// init 중간생략..

for (int i=0; i<7; i++)
{
char filename[255];
sprintf(filename, “tacgun0%d.rgb”, i);
texture[i] = InitTexture(filename);
}

// draw 중간생략..

glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture[currentTex]);
drawSquare();
glBindTexture(GL_TEXTURE_2D, 0);

// update

void update()
{
static int currentTime, deltaTime, prevTime = 0;
currentTime = glutGet(GLUT_ELAPSED_TIME);
deltaTime = currentTime – prevTime;
prevTime = currentTime;
currentTex = (GLuint) ((float)currentTime * 0.01) % 7;
glutPostRedisplay();
}