3

I am developing a project using GLUT, and when i want to use GlTexture, to add a texture, it only works if the height and width are base 2(2^n, ex: 128-64,256-256...). Someone here experienced the same problem?

My Example:

    GLuint textureID;
    char caminho2[1000]= "C:\\....";
glEnable(GL_TEXTURE_2D);



ilInit();
unsigned int t[2], tw, th;
unsigned char *texData;
ilGenImages(2,t);
ilBindImage(t[0]);
ilLoadImage((ILstring) caminho2);
    tw = ilGetInteger(IL_IMAGE_WIDTH);
th = ilGetInteger(IL_IMAGE_HEIGHT);
ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE);
texData = ilGetData();


glGenTextures(1,&textureID); // unsigned int texID  - variavel global;

glBindTexture(GL_TEXTURE_2D,textureID);
glTexParameteri(GL_TEXTURE_2D,  GL_TEXTURE_WRAP_S,      GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D,  GL_TEXTURE_WRAP_T,      GL_REPEAT);

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, GL_RGBA, tw, th, 0, GL_RGBA, GL_UNSIGNED_BYTE, texData);

    glBindTexture(GL_TEXTURE_2D,textureID);
    draw..........
glBindTexture(GL_TEXTURE_2D,0);
4

0 回答 0