I'm trying to load a texture into a sphere created by glutSolidSphere with soil.lib
This is what i'm trying:
GLuint texture[1];
/* load an image file directly as a new OpenGL texture */
texture[0] = SOIL_load_OGL_texture("Terra.bmp", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y);
printf("%d ", texture[0]);
if (texture[0] == 0) {
printf("Error loading texture \n");
return 0;
}
// Typical Texture Generation Using Data From The Bitmap
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glutSolidSphere(20, 20, 20);
I think that I´m losing something, but i don't no what.
Thanks.
答案 0 :(得分:0)
glutSolidSphere没有纹理坐标,将gluSphere()与gluQuadricTexture结合使用。还有一个生成球体的选项,并通过三角形/四边形对其进行纹理化。例如:http://www.codeincodeblock.com/2011/06/texture-map-in-solid-sphere-using.html