openglvisual-c++jpegtexturing

OpenGL slow processing while loading a jpeg image using SOIL


I am working on a project to texture a sphere with a jpeg image and with some keyboard navigation keys for the user that rotates the sphere right or left. The problem is i tried using SOIL to load the image and it was successfully loaded, but the probelm is the slow processing for the sphere rotation... any help!

this is how i load the jpeg image in a seoarate method called once in the main method

void loadtexture()
{
    tex_2d[0] = SOIL_load_OGL_texture(
        "filename",
        SOIL_LOAD_AUTO,SOIL_CREATE_NEW_ID,
        SOIL_FLAG_MIPMAPS);
    printf( "Image loaded successfully.. ");
    if(tex_2d[0]==0 ) {
        printf( "SOIL loading error: '%s'\n", SOIL_last_result() );
    }
glBindTexture(GL_TEXTURE_2D, tex_2d[0]);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);//GL_NEAREST
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
}

and this is how i create my sphere and apply the texture to it

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, tex_2d[0]);
GLUquadricObj* esphere2 = gluNewQuadric();
gluQuadricTexture(esphere2, true);
gluQuadricNormals(esphere2, GLU_SMOOTH);
glEnable(GL_CULL_FACE);
gluSphere(esphere2, 4, 50, 50);
gluDeleteQuadric(esphere2); 

Solution

  • The problem is i tried using SOIL to load the image and it was successfully loaded, but the probelm is the slow processing for the sphere rotation

    This reads as if you're re-loading the texture for each and every frame draw. Why would you do this? Just load the texture once and be done with it.