Hi…
I have a problem with a program.I’ve used the same code,with some difference,of the tutorial for loading milkshape model written by nehe…
My problem is that the program don’t show the texture and the mesh appear totally white!!
here the resume of the texturing code
if ( materialIndex >= 0 )
{
glMaterialfv( GL_FRONT, GL_AMBIENT,model->m_pMaterials[materialIndex].m_ambient );
glMaterialfv( GL_FRONT, GL_DIFFUSE, model->m_pMaterials[materialIndex].m_diffuse );
glMaterialfv( GL_FRONT, GL_SPECULAR, model->m_pMaterials[materialIndex].m_specular );
glMaterialfv( GL_FRONT, GL_EMISSION, model->m_pMaterials[materialIndex].m_emissive );
glMaterialf( GL_FRONT, GL_SHININESS, model->m_pMaterials[materialIndex].m_shininess );
if(model->ID_Texture>=100)
{
glEnable( GL_TEXTURE_2D );
glBindTexture(GL_TEXTURE_2D, model->ID_Texture);
}
else
glDisable(GL_TEXTURE_2D);
}
else
{
// Material properties?
glDisable( GL_TEXTURE_2D );
}
void CJtpOglTextureMgr::LoadTextures(IJtpModel *model,jchar* filename)
{
model->ID_Texture=IDTemp;
CreateTextureBmp(filename,model->ID_Texture);
IDTemp++;
};
void CJtpOglTextureMgr::CreateTextureBmp( jchar* strFileName, juint textureID)
{
AUX_RGBImageRec *pBitmap = NULL;
if(!strFileName)
return;
pBitmap = auxDIBImageLoad(strFileName);
if(pBitmap == NULL)
exit(0);
glGenTextures(1, &textureID);
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
glBindTexture(GL_TEXTURE_2D, textureID);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, pBitmap->sizeX, pBitmap->sizeY, GL_RGB, GL_UNSIGNED_BYTE, pBitmap->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR_MIPMAP_LINEAR);
if (pBitmap)
{
if (pBitmap->data)
{
free(pBitmap->data);
}
free(pBitmap);
}
}
IJtpModel* model=rendermgr->AddModel("soldier.ms3d",1);
rendermgr->AddTexture(model,"GH.bmp");
void CJtpRenderMgr::AddTexture(IJtpModel* model,jchar* filename)
{
SoftMgr->LoadTexture(model,filename);
};
void CJtpOglMgr::LoadTexture(IJtpModel* model,jchar* filename)
{
texturemgr.LoadTextures(model,filename);
};
there is somithing wrong in this chunks???
If the problem aren’t here can anyone tell me where i could find it??
PS i have just checked all the glEnable(like texture2d,materialcolor) and relative gldisable(lighting)…
tnx very much