Hi
I’ve read some tutorials and tried to write a 3ds file loader. It should support models and textures, but the textures doesn’t appear. I don’t think it’s the loader that is the problem. Maybe the problem is in this area:
void createTextures(UINT textureArray[], LPSTR fileName, int textureID)
{
AUX_RGBImageRec *pBitmap = NULL;
if (!fileName) return;
pBitmap = auxDIBImageLoad(fileName);
if (pBitmap == 0) exit(0);
glGenTextures(1, &textureArray[textureID]);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glBindTexture(GL_TEXTURE_2D, textureArray[textureID]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, pBitmap->sizeX, pBitmap->sizeY, GL_RGB, GL_UNSIGNED_BYTE, pBitmap->data);
if (pBitmap)
{
if (pBitmap->data)
{
free(pBitmap->data);
}
free(pBitmap);
}
}
I’ve tried to check with glGetError() but it always returns invalid operation so I don’t know if it really creates the texture.
The whole source is here .
i can’t offer much help, but just in case, have you checked that you’re loading textures after a rendering context has been created? textures in gl can’t be built until this is done, if i’m not mistaken. i used to do this absentmindedly all the time.
edit: i just checked your engine. you’re loading the model prior to creating an opengl window. that’s the problem. just move that code below and you should be fine.