我目前正在做一个需要加载图像的项目。我正在使用 SOIL 库加载 JPEG 图像。我必须在投影区域移动球。在没有加载图像的情况下,球的运动可以正常工作,但随着图像的加载,它会变得缓慢。我应该怎么做才能在图像仍然加载的情况下顺利更新图形。
GLuint tex_2d = SOIL_load_OGL_texture
(
"<image_path>ImageName.jpg",
SOIL_LOAD_AUTO,
SOIL_CREATE_NEW_ID,
SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT
);
glBindTexture(GL_TEXTURE_2D, tex_2d);
glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS);
glTexCoord3f(0.0f,0.0f,0.0f); glVertex3f(factor*BOARD_BREADTH/2,-factor*BOARD_LENGTH/2,0);
glTexCoord3f(0.0f,1.0f,0.0f); glVertex3f(factor*BOARD_BREADTH/2,factor*BOARD_LENGTH/2,0);
glTexCoord3f(1.0f,1.0f,0.0f); glVertex3f(-factor*BOARD_BREADTH/2,factor*BOARD_LENGTH/2,0);
glTexCoord3f(1.0f,0.0f,0.0f); glVertex3f(-factor*BOARD_BREADTH/2,-factor*BOARD_LENGTH/2,0);
glEnd();