Texture Animation

Texture Animation
5974008442.zip
// 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();
}

Leave a Reply

Your email address will not be published. Required fields are marked *