OpenGL Texture Mapping

사용자 삽입 이미지/// init texture
void initTexture(char *filename, GLuint& textureID, GLint param=GL_REPEAT)
{
// 중간 생략
  glGenTextures(1, &textureID);
  glBindTexture(GL_TEXTURE_2D, textureID);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, param);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, param);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  glTexImage2D(GL_TEXTURE_2D, 0, numComponents == 3 ? GL_RGB : GL_RGBA, imageWidth, imageHeight,
      0, numComponents == 3 ? GL_RGB : GL_RGBA, GL_UNSIGNED_BYTE, imageBuffer);
  glBindTexture(GL_TEXTURE_2D, 0);
}

/// Draw
void draw()
{
 glBindTexture(GL_TEXTURE_2D, texID1);
 glBegin(GL_QUADS);
  glNormal3f(0, 0, 1);
  glTexCoord2i( __________________ );
  glVertex3f(-2.0, -1.0, 0.0);
  glTexCoord2i(__________________);
  glVertex3f(-0.1, -1.0, 0.0);
  glTexCoord2i(__________________);
  glVertex3f(-0.1, 1.0, 0.0);
  glTexCoord2i(__________________);
  glVertex3f(-2.0, 1.0, 0.0);
 glEnd();
}

Leave a Reply

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