0

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.

Xhark
  • 781
  • 1
  • 9
  • 24

1 Answers1

0

glutSolidSphere does not have texture coordinates, use gluSphere() in combination with gluQuadricTexture. There is also an option to generate the sphere and texture it by triangles/quads. e.g like in: http://www.codeincodeblock.com/2011/06/texture-map-in-solid-sphere-using.html