Line Drawing Algorithm
line drawing algorithm
-DDA (Digital Differential Analyzer)
-Bresenham’s Line Drawing Algorithm
lecture18
OpenGLTextureBlendingGeometry
OpenGL TimeVaryingAlphaTexture
OpenGL TimeVaryingAlphaTexture
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);
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);
lecture17
OpenGLTextureGeometry
OpenGL Multi-Texturing
http://dis.dankook.ac.kr/lectures/cg12/entry/OpenGL-Multi-Texturing
ADD
Single Pass Multi-Texturing (Activating Multiple Texture Coordinates using GLSL)
Multi-Pass Multi-Texturing (Using Blending)
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);
}
{
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);
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();
}
{
static int currentTime, deltaTime, prevTime = 0;
currentTime = glutGet(GLUT_ELAPSED_TIME);
deltaTime = currentTime – prevTime;
prevTime = currentTime;
currentTex = (GLuint) ((float)currentTime * 0.01) % 7;
glutPostRedisplay();
}